Skip to main content
Engineering

RAG Performance Starts with Preprocessing, Not Retrieval

Originally published on Medium

What Most Teams Get Wrong

When building a RAG pipeline, most engineers focus on retrieval and chunking strategies and reranking models first. This approach can produce visible improvements in the short term. But in production environments where data is constantly updated, these advanced techniques alone cannot deliver stable performance.

Engineers who have built and optimized RAG systems in production know that the quality of your pre-processing determines how quickly you reach your target performance. If your pre-processing is poor, your RAG system will underperform regardless of what retrieval methods you use.

Pre-processing has four stages.

  • Load & Parse
  • Chunk
  • Embed
  • Store in Vector DB.

Each stage has its own challenges. But for financial documents like SEC 10-Ks, the first stage, Load & Parse, is where most problems start. Our team is focusing on that stage, specifically on parsing tables and wants to share what we learned.

Why Financial Report Tables Are Hard to Parse

SEC 10-K filings are among the hardest documents to parse. They do not contain just narrative text. A single 10-K includes hundreds of financial tables with complex header structures, merged cells, and columns that change from year to year. All of this information is mixed together in the same document.

The problem is clear.

Standard PDF and HTML parsers cannot handle these tables. When you run a 10-K through a typical parser, the table structure breaks. Rows and columns lose their alignment. Numbers appear in a flat list without any indication of what they mean or what time period they belong to.

When you feed this broken data to an LLM, you get wrong answers. It does not matter how capable the model is. Bad input produces bad output. This is the fundamental problem with financial RAG systems.

For What RAG Engineers Spend Most of Time

For RAG engineers working with financial data, the biggest challenge is reconstructing table structure after parsing. Tables are not just collections of text. They encode structural relationships. A specific number belongs to a specific metric (revenue, net income, etc.). That number corresponds to a specific time period (Q1 2025, FY 2024). These structural relationships are what make the data meaningful. Without them, the numbers are useless.

To preserve this structure, engineers spend lots of hours on table reconstruction, semantic chunking, and embedding optimization. They manually fix broken tables. They write custom logic to split tables into meaningful chunks. They experiment with different embedding approaches to capture table semantics.

This has a direct cost. Time spent on preprocessing is time not spent on developing new chunking strategies or testing different retrieval methods.

How LucyData Solves This Bottleneck

With our machine-readable datasets, our team eliminates this preprocessing bottleneck. We don’t just convert documents to text. It preserves the logical structure of tables in JSON format. Row-column relationships remain intact. The output is structured data, not broken text.

Here is an example of how LucyData structures table data:

{
"type": "table",
"value": {
"rows": [[ {"pos": {"col": 0, "row": 0}, "v": ""},
{"colspan": 6, "pos": {"col": 1, "row": 0}, "v": "Amount"},
{"colspan": 4, "pos": {"col": 7, "row": 0}, "v": "Increase/(decrease)"}
]]
}
}

Once we had JSON data with clearly defined row-column relationships, the time we previously spent on table parsing dropped dramatically.

Applying Structured JSON in a RAG Pipeline

Our team tested the following pipeline with structured JSON tables:

JSON Table → Serialization → Embedding → Retrieval → Inject original JSON into prompt

We did not simply convert the JSON to a flat string. We provided interpretation guides and specific examples (few-shot) so the LLM could understand and interpret the table structure correctly. We then compared this approach against raw HTML parsing under identical conditions.

The results were clear. The structured JSON approach showed consistent improvements in both precision and recall compared to HTML parsing. The improvements were statistically significant across multiple test runs.

The conclusion is straightforward: when engineers do not have to spend time on parsing problems and repetitive preprocessing, they reach target RAG performance faster.

Ongoing Experiments to Improve JSON Tables

Our team is currently working to improve JSON tables in two ways: increasing their quality as context for LLMs, and reducing the time engineers spend on serialization. We are running multiple experiments and measuring whether they produce meaningful improvements in RAG performance. Here is one of our main experiments.

  1. Testing Semantically Complete JSON Structures

We are testing JSON structures optimized for retrieval efficiency. These structures have two key properties:

  • Meaning is explicit in key strings. Instead of listing data by position, each value’s meaning is stated directly in its key. This helps the LLM understand relationships between data points more accurately.
  • Each row is semantically complete. A single row contains all the context needed to understand it. The row can stand alone as an independent unit of meaning.

Here is an example of this structure:

{
"type": "table",
"headers": [
"Union",
"Percent of our Total Workforce Represented",
"Status of Major Agreements with Union"
],
"rows": [
{
"Union": "The International Association of Machinists (IAM)",
"Percent of our Total Workforce Represented": "21%",
"Status of Major Agreements with Union": "Two agreements; IAM District 837 (Missouri) expiring July 2025, IAM District 751 (Washington) expiring September 2028."
},
{
"Union": "Society of Professional Engineering Employees (SPEEA)",
"Percent of our Total Workforce Represented": "10%",
"Status of Major Agreements with Union": "Two agreements; SPEEA Professional and SPEEA Technical, both expiring October 2026."
}
]
}

2. Performance Enhancement through XBRL Integration

We are also experimenting with integrating normalized financial information based on XBRL (eXtensible Business Reporting Language) into our RAG pipeline. By linking unstructured data with structured financial data, we are verifying improvements in the following areas:

  • Response Accuracy and Consistency: We are tracking the reduction in error rates for numerical queries when the LLM references XBRL’s standardized concepts.
  • Quality of Citations: We are testing whether we can provide more sophisticated evidence to users by matching the grounds for an answer to specific XBRL Fact units rather than simple text snippets.

Example:

{"facts": [
{
"concept": "CommonStockSharesAuthorized",
"context_ref": "c-7",
"description": "The maximum number of common shares permitted to be issued by an entity’s charter and bylaws.",
"label": "Common Stock Shares Authorized",
"namespace": "http://fasb.org/us-gaap/2024",
"origin": "us-gaap",
"period": {
"end": "2023-12-31",
"start": "2023-12-31"
},
"qualified_concept": "us-gaap:CommonStockSharesAuthorized",
"source": "0000063908-25-000012:f-224",
"unit": "SHARES",
"value": 3500000000
}
]}

Summary

LucyData is providing well-suited datasets for RAG engineering organized by item, text blocks in markdown format, and image summaries that provide semantic context.

For tables, our parsing accuracy is high and we include XBRL linkage. But we are continuing to improve table structures specifically for RAG pipelines.

The current position-based JSON structure requires serialization for embedding and re-injection of original JSON for generation. This creates complexity.

The key-value JSON structure with row-level semantic completeness solves these problems. It provides chunking flexibility and improves usability within RAG pipelines.

#XBRL #SEC #10-K #table-parsing

Originally published on Medium by Jong-bok Lee, AI Researcher at LucyData, December 28, 2025.