RAG without the hype
Retrieval-augmented generation that stays operable — chunking, evals, and failure modes that actually show up in production.
RAG demos look magical. Production RAG looks like data contracts, eval harnesses, and boring monitoring.
Chunking is product design
Chunk size is not a hyperparameter you copy from a blog. It depends on:
- document structure (policies vs chat logs)
- citation UX (can a human verify the snippet?)
- latency budget for retrieval + generation
A simple relevance score
For a query embedding and chunk embedding :
Rank by , then filter with a floor threshold so the model is not forced to invent from noise.
Minimal retrieval loop
async function answer(query: string) {
const hits = await vector.search(query, { k: 8 });
const context = hits
.filter((h) => h.score > 0.72)
.map((h) => h.text)
.join("\n---\n");
return llm.chat([
{ role: "system", content: "Cite only from context. If missing, say so." },
{ role: "user", content: `Context:\n${context}\n\nQuestion: ${query}` },
]);
}Eval before polish
Track at least:
| Metric | What it catches |
|---|---|
| Groundedness | Hallucinations |
| Recall@k | Bad chunking / index drift |
| Latency p95 | Infra regressions |
Closing
Ship the evaluation loop first. Fancy agents can wait.