HeadlinesBriefing favicon HeadlinesBriefing.com

Rethinking RAG Retrieval: From Cosine to Structured Filtering

Towards Data Science •
×

Towards Data Science’s latest Enterprise Document Intelligence note dismantles the textbook RAG pipeline that relies on cosine similarity. The authors argue that retrieval should treat documents as structured tables rather than bag‑of‑words chunks, using SQL‑like filters on line and TOC data. They back the claim with six “untaught” lessons that overturn the cosine‑first reflex.

Lesson one reframes retrieval as a boolean filter: a question maps to columns, a document to rows, and the join returns exact matches, eliminating the opaque top‑k cutoff. Subsequent lessons separate anchor from context, run cheap keyword scans before any embedding fallback, and use co‑occurrence instead of BM25 on narrow corpora. A LLM call over the TOC resolves paraphrased headings that plain keyword search misses.

The three‑signal pattern—keyword on line_df, reasoning on toc_df, embedding fallback—appears in insurance, contracts, and other enterprise texts, delivering deterministic audit trails and cost savings by avoiding unnecessary cosine calculations. The authors provide runnable notebooks on GitHub, inviting practitioners to replace the default embed‑then‑rank approach with a filter‑first architecture that delivers clearer, reproducible results and scales across multiple language models without rewrites.