Data Intelligence · RAG · Observability · Evals

Latency collects itself, relevance does not: instrumenting retrieval quality

Published · Updated

A retrieval dashboard fills itself with volume and latency and never shows a miss. The metric that matters needs labels you write yourself, plus an exact-search run to separate index loss from corpus gaps.

A retrieval dashboard is easy to fill. Query volume, latency, how many chunks came back, how often the index was hit. All of it collects itself, and none of it contains a miss. When a semantic search returns twenty chunks and the right one is not among them, nothing errors and nothing retries. The row looks identical to a good answer. The dashboard is complete and blind.

The metric needs something the logs don't have

Anthropic's contextual retrieval work uses 1 minus recall@20 as its evaluation metric, measuring the percentage of relevant documents that fail to be retrieved within the top 20 chunks. Read that definition as a requirement rather than a result. It needs a query, and it needs to be known in advance which documents are relevant to that query. Production logs supply the query and the returned chunks. The relevance labels have to come from somewhere else.

Build the query set before you build the panel

A labelled set is a small, unglamorous artefact: questions a user would plausibly ask, each paired with the chunks that should answer them. Keep the measurement depth aligned with what the model actually receives. If the prompt is given twenty chunks, measure at twenty, because a number computed over a deeper slice describes a system nobody shipped. The set is the instrument here, and the dashboard is only the readout.

Exact search is the oracle you already have

By default, pgvector performs exact nearest neighbour search, which provides perfect recall. An index buys speed and trades some recall for it, with HNSW giving a better speed-recall trade-off than IVFFlat at the cost of slower builds and more memory. Run the labelled set twice, once exact and once through the index. The gap between the two runs is attributable to the index, not to the corpus or the embeddings.

Two failures that share one row

If a labelled chunk is missing from both runs, the index is not the culprit: the embedding never placed that chunk near that question. Embedding models excel at capturing semantic relationships but can miss crucial exact matches, which is where a tsvector column and Postgres full-text search earn their keep. If the chunk is missing only from the indexed run, the dynamic candidate list for search, 40 by default, is the first dial to inspect.

Nobody is going to report the miss

On Tatano Energy, eight SEO articles publish every day across four separately indexed country domains in seven languages, with manual intervention required: 0. The Matthieu Pesesse platform publishes articles autonomously, daily, with weekly content operations time of about zero hours. Unsupervised publishing removes the detector most teams lean on without noticing it: a person reading the output and saying that answer was wrong. Scheduled evaluation is not extra rigour there; it is the only detector left.

What the panel should carry

Three numbers are enough to act on: 1 minus recall@20 on the labelled set, the exact-versus-index gap on that same set, and the share of labelled queries that only the full-text index satisfies. Rerun them on the rhythm the corpus moves, since a corpus that grows daily quietly ages its own labels. Volume and latency stay on the page, lower down, where they belong.

When the number moves, what you change

The available responses are ordered, not interchangeable. Contextual retrieval can reduce failed retrievals by 49%, and by 67% when combined with reranking, so there is real headroom in how chunks are prepared and ranked before the index gets blamed for anything. And if the knowledge base is smaller than 200,000 tokens, about 500 pages, the entire base can go into the prompt with no need for RAG or similar methods.

Treat retrieval quality as an instrument you build, not a signal you observe. The logs will never contain a miss, so write the questions down, write the expected chunks down, run the set exact and indexed, and watch the gap at the cadence your corpus changes. Without labels, a retrieval dashboard reports uptime for a system whose entire job is relevance.

Sources

pgvector (GitHub) — Open-source vector similarity search for Postgres — https://github.com/pgvector/pgvector

Anthropic — Introducing Contextual Retrieval — https://www.anthropic.com/engineering/contextual-retrieval

PostgreSQL 18 Documentation — Full Text Search: 12.1. Introduction — https://www.postgresql.org/docs/current/textsearch-intro.html

Neurolinks case study — Four markets, one codebase — https://neurolinks.be/work/tatano-energy

Neurolinks case study — A personal brand that publishes itself — https://neurolinks.be/work/matthieu-pesesse-media

Working on a project where these methods apply?