KatInterview

RAG Service for Cited Q&A Over Long Regulatory Filings

Machine LearningModel answer
MediumModel answerMachine Learningragretrievalcitations

Last updated

Design a retrieval-augmented assistant that answers multi-document questions over long regulatory filings with paragraph-level citations, streaming, and hallucination guards.

Answer questions across a large corpus of long regulatory filings, with every claim cited

A product team wants a chat assistant for analysts working with dense, highly structured corporate disclosures (annual reports, quarterly reports, registration statements, material-event filings). A user types a natural-language question and gets back a written answer where every factual claim is linked to the exact passage it came from — the specific filing, section, page, and character range — so the analyst can click through and verify in seconds.

Functional requirements

  • Cross-document synthesis. Questions like "How did the risk disclosures of Company A and Company B change between FY2022 and FY2023?" must be answered by combining evidence from several filings.
  • Citation fidelity. Each sentence of the output must be traceable to a specific passage (page/paragraph). Claims with no supporting passage must be dropped or explicitly marked as unsupported.
  • Agentic routing. The system must decide per query whether a single retrieval pass suffices or whether it needs a multi-step, iterative search plan before answering.
  • Refusal behavior. When the evidence isn't in the corpus, the system says so rather than inventing an answer.

Non-functional requirements

  • Scale. Index on the order of millions of pages, growing by thousands of new filings per day, with the index catching up within roughly an hour.
  • Latency. Simple lookups should start streaming tokens within ~2 seconds; long analytical jobs may run for minutes but must show progress and partial results.
  • Reliability. Enforce a strict "answer only from retrieved context" constraint and validate citations before release.

Deliverables

  1. High-level architecture: ingestion pipeline, retrieval mechanism, and agent orchestration flow.
  2. A data model for parsed documents, section structure, chunks, and citation metadata/embeddings.
  3. A latency strategy for long-running analysis that doesn't tie up or time out the user-facing request.
  4. Discussion of the precision-vs-recall trade-off when domain jargon and abbreviations are common, and how you'd tune retrieval for it.

Hints

Hint 1

Pin down the citation contract (filing id, section code, page, character offsets) first and design every stage backward from it — if a chunk can't be cited, it can't be used as evidence.

Hint 2

Structure is your biggest precision lever: filings are organized into labeled sections (risk factors, MD&A, financial statements), so resolve tickers/years/section codes into hard metadata filters before touching the vector index.

Hint 3

Decouple the job from the HTTP request: return a job id immediately, run retrieval/generation on a durable queue, and stream plan → per-document progress → tokens → citations over a reconnecting event stream.

Hint 4

Combine dense embeddings with a sparse keyword index (BM25/SPLADE) because exact tokens like accounting-standard codes and segment names must match literally; then re-rank with a cross-encoder.