HeadlinesBriefing favicon HeadlinesBriefing.com

Row-Level Table Chunks for RAG Retrieval

Towards Data Science •
×

When a question targets a single row inside a table, retrieving the entire table forces the generation model to filter 39 irrelevant rows. The unit that matches the question is one row, not the whole rectangle. This article builds a row-level index that turns each body row into its own retrievable chunk, so a query like "cap for vehicle theft?" returns exactly the one row plus its column headers.

The serialize_table_rows function scans the parser's line_df, groups contiguous pipe lines into tables, reads the header row above the separator, and emits one output row per body line. Each chunk is serialized as col: val | col: val, which an LLM reads naturally and which composes with existing keyword and embedding retrievers without changes.

The row-level index is a second scale, not a replacement. A dispatcher routes targeted lookups to the row-level index, synthesis questions fire across all rows of the same table (detected via shared table_id), and mixed queries combine both. Downstream retrievers that never enable row-level indexing keep working unchanged, while those that do read the second frame explicitly.

Runnable code is available in doc-intel/notebooks-vol1, demonstrating serialize_table_rows on Table 1 of the Attention paper and returning one row instead of the whole table.