TuBrief
Subscribed Channels
Videos
Community

Modernizing Legacy Document Processing Pipelines and Reducing Costs

TuBrief Editorial
April 22, 2026
0
Computing/Software

Written with AI assistance from the source video. The video is the authority.

English한국어Español中文हिन्दीالعربيةDeutschFrançaisPortuguêsРусскийBahasa Indonesia日本語

Related Video

Stop Building RAG Pipelines Like This... Use MarkItDown Instead6:17

Stop Building RAG Pipelines Like This... Use MarkItDown Instead

Better Stack

More from the community

사내 시스템에 llm api 붙일 때 마주하는 현실적인 한계와 대응법

September 13, 2026

레거시 백엔드에 GPT-6 Astra 붙일 때 예산 승인과 보안 통과를 먼저 끝내는 법이 있습니다

September 13, 2026

에이전트끼리 대화하다 6천만 원 청구서가 나오는 이유

September 13, 2026

사내 RAG 벡터 검색에 Okta 권한 필터를 직접 거는 방법

September 13, 2026

브라우저 에이전트에게 내 구글 계정을 통째로 넘기면 안 되는 이유

September 12, 2026

Apple Won the AI Race

September 12, 2026

Comments (0)

Log in to leave a comment

No posts yet

© 2026 . All rights reserved.

TuBrief
Subscribed Channels
Videos
Community
Log in

Modernizing Legacy Document Processing Pipelines and Reducing Costs

Reducing Maintenance by Consolidating Markdown Conversion Logic

If you are spending five hours of overtime every week stuffing hundreds of PDF, PPT, and Excel files into your RAG system, the root cause is fragmented parsing libraries. The existing structure of mixing PyPDF2 and openpyxl only increases code complexity. Adopting Microsoft's MarkItDown can eliminate complex branching logic.

When refactoring the pipeline, use the Processor Factory pattern:

  1. Remove libraries scattered by format and unify the calling interface with MarkItDown's convert() function.
  2. Branch processing methods based on document complexity. Use lightweight parsers for simple text and choose MarkItDown for complex documents with many tables.
  3. Isolate all dependencies in Docker containers (Python 3.11 or higher) and deploy via FastAPI.

This structure allows for independent scaling of the parsing engine. Preserving table structures reduces table retention errors by 34% when LLMs read documents (based on Microsoft 2024 announcement).

Saving 30% on API Costs through Markdown Preprocessing

Embedding token costs are directly proportional to the length of the Markdown file. Results extracted by MarkItDown often contain metadata or noise that doesn't necessarily need to be sent to the LLM. Filtering this out alone can reduce API costs by 30%.

Build an efficient filtering logic:

  1. Use Python's re module to reduce consecutive newlines (\n{3,}) to two, and remove repetitive footer copyright notices or HTML tags using regular expressions.
  2. Use MarkdownHeaderTextSplitter to chunk by header. Managing child chunks for search and parent chunks for context improves search accuracy.
  3. Use MD5 hashes to prevent redundant embedding of identical reports at the source.

Optimizing token efficiency can noticeably lower monthly enterprise API costs.

Managing Data Quality with Snapshot Testing

When library versions change, parsing results also shift slightly. Stop having engineers manually open and verify files one by one. Introducing snapshot testing allows you to catch quality degradation immediately.

Create a unit test environment to prevent regressions:

  1. Install the pytest-regressions plugin and save well-converted Markdown as a golden master file.
  2. Ensure the test script compares the conversion result with the golden master every time. If a difference (diff) occurs, send an immediate notification.
  3. Use a sentence transformer model to measure the cosine similarity between the original and the converted version. You can configure it to log only when the format preservation rate is less than 0.9.

This automation framework eliminates the manual cross-checking tasks that used to eat up five hours every week.

Increasing Batch Job Speed with Parallel Processing

Processing thousands of documents sequentially is a waste of system resources. By using concurrent.futures.ProcessPoolExecutor to parallelize batch processing, you can finish tasks that used to take days in just a few hours.

Implement the parallelization architecture as follows:

  1. If the server has 16GB of memory, limit workers to 20-25. Excessive scaling will only lead to memory errors.
  2. Split files into batches of 50-100 and force garbage collection after each batch to catch memory leaks.
  3. Separate large PDFs exceeding 10MB into a dedicated queue for high-performance workers to handle.

This approach helps maintain data freshness while using system resources efficiently.