Production RAG · SEC 10-K filings
Every sentence cited. Or no answer at all.
Ask about ten companies' annual reports and get an answer that points to the exact passage it came from, or a refusal when the filings don't say. Every pull request is graded, and blocked if quality drops.
How fast did Microsoft's cloud business grow in fiscal 2026?
Microsoft Cloud revenue increased 27% to $214.4 billion in fiscal 2026 . Azure and other cloud services revenue increased 41% .
- Microsoft Cloud revenue increased 27% to $214.4 billion.
- Commercial remaining performance obligation increased 84% to $678 billion.
- Microsoft 365 Commercial cloud revenue increased 17%.
- Azure and other cloud services revenue increased 41%.
See it run
Why
A 10-K is a company's annual report to the SEC: a hundred-plus pages of risk factors, segment tables and footnotes. A chatbot over them is easy to demo and hard to trust, because it will happily make up a number that sounds right.
This one answers only from the filings of Apple, Microsoft, NVIDIA, Tesla, Amazon, Alphabet, Meta, JPMorgan, Netflix and AMD. Each sentence points to the passage it came from, a checker deletes any sentence it can't back up, and it says so when the answer isn't there.
What makes it production-grade is measurement: a hand-built test set, an independent grader, and a CI gate that fails the pull request when quality slips.
How it works
- 1Read the filings
Download each 10-K from SEC EDGAR, keep the page and the section (Item 1A. Risk Factors) for every line, and cut it into 500-token chunks that overlap by 100.
- 2Search two ways
Keyword search finds exact terms like "CET1" or "MI308"; vector search finds meaning ("head office" → "headquarters"). Reciprocal Rank Fusion merges the two rankings.
- 3Re-rank closely
A cross-encoder reads the question and each of the 20 candidates together and keeps the best 5. If even the best is irrelevant, the system refuses without calling the LLM.
- 4Answer, then check
Claude writes an answer with a chunk id after each sentence. A checker drops any sentence whose cited chunk doesn't contain its numbers and most of its words.
- 5Gate every change
On each pull request, GitHub Actions rebuilds the index, runs the test set and fails the build if any score falls under its threshold.
Results
Test set: 63 questions, written and checked against the filings. 52 have an answer, each tied to an exact quote; 11 must be refused (future years, companies not in the corpus, investment advice). An independent model, Claude Opus 5.5, grades the answers through RAGAS.
Re-ranking is the largest single gain. It costs about 0.75 s per question, close to half the answer time.
| Full system | Score |
|---|---|
| Faithfulness: answer claims supported by the sources | 98% |
| Context recall: reference answer found in what was retrieved | 93% |
| Answer correctness vs. the reference | 83% |
| Sentences with a valid, supported citation | 99% |
| Refused exactly when it should | 95% |
| Answer time, median / 95th percentile | 1.7 / 2.8 s |
All three refusal mistakes were answerable questions whose source chunk was never retrieved; the model then correctly said it couldn't answer. Retrieval, not generation, is what to improve next.
The quality gate
To prove the gate works, a deliberately bad prompt that drops the grounding, citation and refusal rules was run through the same GitHub Actions check as the normal one (3 companies, 39 questions).
| Prompt | Faithful | Top 5 | Refusals | Cited | Build |
|---|---|---|---|---|---|
| answer_v2 | 99% | 93% | 100% | 95% | Pass |
| answer_broken_demo | n/a | 93% | 28% | n/a | Fail |
The broken prompt stopped citing, so the checker refused every answer and refusal accuracy fell to 28%. Retrieval stayed at 93%, so the scores point at the part that broke. See the blocked pull request. Thresholds: 85% for faithfulness, refusals and citations; 80% for top 5.
What went wrong
- Microsoft's sections came out wrong
Its 10-K repeats "Item 1" as a header on every page, so the parser took a page header for the section start. Now it takes the first line that has a section title and isn't a table-of-contents row.
- The re-ranker was marked wrong for being right
JPMorgan states its CET1 ratio in three places and only one was labelled. Test labels are now computed from evidence quotes, and a question can list several.
- Short correct answers were refused
"Cupertino, California [AAPL-2026-00056]" was too short to count as a claim, so the checker found nothing to keep. Anything with a citation now counts; a unit test caught it.
- A metric scored perfect answers 0
RAGAS FactualCorrectness returned 0 even for exact matches in this setup. Checked by hand against known answers, then switched to AnswerAccuracy, which graded them correctly.
Stack
Retrieval
- bge-small-en-v1.5Local embeddings
- ChromaDBVector store on disk
- rank-bm25Keyword search
- bge-reranker-baseCross-encoder re-ranker
Generation and evals
- Claude Haiku 5.5Answers, versioned prompts
- RAGAS + Claude Opus 5.5Independent grader
- GitHub ActionsQuality gate on every PR
- FastAPI + StreamlitAPI and UI