Metadata-Aware RAG
Turning natural-language questions into database filters before search ever runs.
- 100%
- Precision on filtered queriesmeasured in repo
- top 2
- Chunks surfaced per querymeasured in repo
The problem
Semantic similarity has no concept of “wrong company” or “wrong year”. Ask about Apple's 2023 revenue and a pure vector search will happily return a structurally identical passage from Microsoft's 2021 filing, because in embedding space those two sentences are neighbours. Similarity is the wrong tool for a constraint that is categorical.
Architecture
A 70B model converts the question into structured metadata filters — company, year, filing type — which are applied in Qdrant before vector search runs, so semantically similar but categorically wrong documents are never candidates. A multi-query step then rewrites the question from several angles, searches all variants, deduplicates, and keeps the top two chunks. A memory step rewrites pronoun-bearing follow-ups into standalone queries first, so “and the year before?” resolves correctly.
What broke
“100% precision on filtered queries” is a narrower claim than it sounds, and I should be precise about it: it means the filter never admits a document from the wrong company or year. It says nothing about recall, and there is no benchmark against a baseline in the repo. Self-querying also introduces a failure the naive system does not have — when the filter extraction misreads the question, the correct document is excluded before search, and the system confidently answers from the wrong subset.
Results
Categorical constraints are enforced structurally rather than hoped for. The two-stage design keeps the fast 8B model on generation and reserves the 70B model for the filter extraction where reasoning quality actually matters.