Establish source scope before building retrieval
I begin with a source registry. For each source, it records the owner, authority, audience, access policy, refresh cadence, retention rule, and current status. This prevents archived or unofficial documents from competing with the approved answer. Scope resolution should happen before retrieval. User identity, business context, document status, language, and effective date can determine which corpus is valid. Applying those constraints only after semantic search risks exposing data or grounding an answer in the wrong version. The ingestion pipeline then needs observable stages:- collect the approved source and preserve its identity;
- parse text, tables, structure, and attachments;
- normalize metadata and access attributes;
- split content according to document structure;
- create searchable representations;
- publish a versioned index and ingestion report.
Design retrieval as a measurable ranking system
I evaluate retrieval before generation. If the evidence is missing, a stronger model usually produces a more convincing unsupported answer. A practical retrieval stack can combine:- metadata and permission filters;
- lexical search for exact identifiers and domain terminology;
- vector search for semantic similarity;
- query rewriting for ambiguous or conversational requests;
- reranking for better ordering of the candidate set;
- diversity or parent-document expansion when fragments lose context.
Constrain answer generation with evidence
The answer layer should receive traceable evidence and explicit response rules. I define how the system cites sources, handles conflicting documents, expresses uncertainty, and refuses when evidence is insufficient. A refusal is a valid outcome when the alternative is an unsupported claim. I distinguish between answer quality and evidence quality. A fluent response with an invalid citation is a failure. A correct statement supported by an obsolete document is also a failure. Citation checks should therefore verify that the referenced passage exists, is accessible to the user, and actually supports the claim. The system should also expose safe fallbacks: refine the query, ask a clarifying question, suggest an approved source, or route the request to a human owner. It must not silently answer from model memory when the product promises source-grounded behavior.Observe the pipeline and classify failures
End-to-end traces connect the user request to scope resolution, query transformation, retrieved items, reranking, model calls, guardrails, citations, latency, and cost. This makes failures attributable:- source failure: the required content is absent, obsolete, or unauthorized;
- parsing failure: structure, tables, or text were corrupted;
- retrieval failure: valid evidence exists but was not selected;
- synthesis failure: the model misread sufficient evidence;
- policy failure: the system answered, refused, or escalated incorrectly;
- runtime failure: latency, timeout, or integration behavior broke the journey.