Ask My Docs

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.

Question

How fast did Microsoft's cloud business grow in fiscal 2026?

Answer

Microsoft Cloud revenue increased 27% to $214.4 billion in fiscal 2026 . Azure and other cloud services revenue increased 41% .

[1] Microsoft Corp · FY2026 · Item 7. MD&A · p.34MSFT-2026-00068
  • 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%.
Out of scope
What will Apple's revenue be in 2030?refused
I can't answer that from the documents.
Real output. Tap a citation to see the exact line in the filing that supports it.
89%right source in top 5
98%faithfulness
11 / 11out-of-scope refused
1.7 smedian answer time

See it run

Screen recording: a question about Microsoft's cloud growth gets a cited answer, opening the source shows the line it came from, and a question about Apple's 2030 revenue is refused.
Recorded from the real app. The highlight on the cited line was added for the recording.

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

  1. 1
    Read 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.

  2. 2
    Search 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.

  3. 3
    Re-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.

  4. 4
    Answer, 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.

  5. 5
    Gate 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.

Query pipeline: keyword and vector search, rank fusion, re-ranking, relevance gate, Claude, citation check, answer or refusal Question Keyword search BM25 · top 20 Vector search bge-small · top 20 Reciprocal Rank Fusion merge by rank, not score Cross-encoder re-rank bge-reranker-base · top 5 Relevance gate < 0.05 Refuse Claude Haiku 5.5 versioned prompt answer_v2 Citation check each sentence cited and supported too few left Answer + [citations]
The query path. Everything above Claude runs locally; the two refusal exits keep made-up answers off the screen.

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 scores on 63 questions
Full systemScore
Faithfulness: answer claims supported by the sources98%
Context recall: reference answer found in what was retrieved93%
Answer correctness vs. the reference83%
Sentences with a valid, supported citation99%
Refused exactly when it should95%
Answer time, median / 95th percentile1.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).

PromptFaithfulTop 5RefusalsCitedBuild
answer_v299%93%100%95%Pass
answer_broken_demon/a93%28%n/aFail

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

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