SEC Finance RAG
Citation-backed answers over 25,000 SEC filings, with the guardrails that make them trustworthy.
- <500ms
- Median query latency, cache missmeasured in repo
- >0.80
- RAGAS faithfulnessmeasured in repo
- <0.20
- DeepEval hallucination ratemeasured in repo
- 60–70%
- Production cache hit ratemeasured in repo
The problem
A financial analyst asking “what were Microsoft's cloud segment margins in FY2023?” needs the number and the filing it came from. Naive RAG over SEC documents fails in a specific way: it retrieves plausible text from the wrong company or the wrong fiscal year, then states it with total confidence. The hard part is not generation. It is making retrieval precise enough that generation has nothing to invent.
Architecture
Ten stages, each with a fallback. Filings are scraped concurrently from EDGAR, parsed format-aware (iXBRL through Unstructured.io, PDFs through PyMuPDF), and chunked with sentence-window splitting that keeps tables atomic — a table split down the middle is worse than no table. Retrieval is hybrid: BM25 catches exact ticker and line-item matches that embeddings miss, dense BGE vectors catch semantic ones. A self-query step extracts metadata filters before search runs, so a question about FY2023 never retrieves FY2021. Cohere's cross-encoder reranks what survives.
What broke
Reranking is the single biggest quality lever and also the most fragile dependency — it is an external API in the hot path. The fallback to plain cosine similarity keeps the system answering when Cohere is unavailable, but answers measurably degrade, and the system does not currently tell the user that it is running degraded. The demo index is also one company deep (1,876 Apple chunks) rather than the full 503-company corpus, so latency numbers reflect a smaller index than production would carry.
Results
RAGAS faithfulness above 0.80 and answer relevancy above 0.75, with DeepEval hallucination below 0.20 — measured, not asserted. Median latency stays under 500ms on a cache miss, and 60–70% of production queries hit cache. Coverage spans 503 S&P 500 companies, four filing types, five years.