Ask My Docs

RAG · Hybrid retrieval · Re-ranking · RAGAS evals · CI

Questions about ten companies' 10-K annual reports, answered with a citation for every sentence — or refused when the filings don't say. Every pull request is graded, and blocked if quality drops.

Ask My Docs: an answer with citation chips next to the highlighted source passage

Example

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.34 MSFT-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?

I can't answer that from the documents.

Real output. Tap a citation to see the exact line in the filing that supports it.

At a glance

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

    Ingest

    Download each 10-K from SEC EDGAR, keep the page and section (Item 1A. Risk Factors) for every line, and cut it into 500-token chunks that overlap by 100.

  2. 2. Search two ways

    Hybrid

    Keyword search finds exact terms like "CET1" or "MI308"; vector search finds meaning, so "head office" finds "headquarters". Reciprocal Rank Fusion merges the two rankings.

  3. 3. Re-rank closely

    Cross-encoder

    A cross-encoder reads the question with each of the 20 candidates and keeps the best 5. If even the best is irrelevant, it refuses without calling the LLM.

  4. 4. Answer, then check

    Guardrails

    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

    CI

    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 path

Keyword and vector search, rank fusion, re-ranking, relevance gate, Claude, citation check, then an answer or a 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
Everything above Claude runs locally. The two refusal exits keep made-up answers off the screen.

Results

Test set: 63 questions I wrote 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). Claude Opus 5.5 grades the answers through RAGAS.

Right source in the top 5

Re-ranking is the largest single gain. It costs about 0.75 s per question, close to half the answer time.

Where it fails. All three refusal mistakes were answerable questions whose source was never retrieved; the model then correctly said it couldn't answer. Retrieval, not generation, is what to improve next.

Quality gate

To prove the gate works, I wrote a deliberately bad prompt that drops the grounding, citation and refusal rules, and ran both prompts through the same CI check (3 companies, 39 questions).

Why it failed. The broken prompt stopped citing, so the checker refused every answer. Retrieval stayed at 93%, so the scores point at the part that broke. 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