This article describes something that does not exist. The retriever running today ranks chunks by counting shared terms. Its successor is fully specified, down to the constants and the rule for accepting it, and is waiting on two decisions. I am writing it up because the specification is where the engineering judgement is, and because a portfolio that only showed finished work would hide the part I am least sure about.
The problem
The current selection has two steps: chunks that verified fields cite, then chunks ranked by how many of the task’s terms they contain. It fails in a predictable way. A customer asks for an article about “sensitive skin”, and the brand’s page says “gentle enough for daily use on reactive skin”. No term matches. The chunk that answers the task is never selected.
A dense retriever fixes that case and introduces another. Embeddings are good at meaning and poor at exact strings. Brand content is full of exact strings: a model name, a certification number, an ingredient code. A dense model happily returns a passage about a similar product.
Neither kind alone is right, which is the usual argument for a hybrid. The less usual question is how to know the hybrid is better on this data before putting it in front of generators.
The running config and the specified one

The running config is a dictionary in the loader. The specified one would replace it in the same place. Written in the same form, it would read as follows. This block is the specification, not code from the repository.
# specified, not implemented
RETRIEVAL_CONFIG = {
"name": "rc-1",
"filters": ["workspace_id", "brand_id", "language", "product_key", "page_type"],
"k_sparse": 50,
"k_dense": 50,
"fusion": {"method": "rrf", "k": 60},
"per_source_max": 2,
"top_k": 8,
"max_chars": 6000,
"rerank": None,
}
| Part | Specification | Reason |
|---|---|---|
| Filters | workspace and brand are mandatory, then language, product and page type; policy pages are excluded by default | the filter is the tenancy boundary, so it is applied before any ranking |
| Sparse | a BM25 index with k1 1.2 and b 0.75, over Korean stems plus syllable bigrams, with Latin and digit tokens kept whole | exact strings must match exactly, and Korean compounds need the bigrams |
| Dense | a local embedding model on the product’s own server | customer text does not go to another vendor for embedding |
| Fusion | reciprocal rank fusion with k = 60 over the two top-50 lists | needs no score calibration between two very different scorers |
| Per source | at most two chunks from one page | one long page should not fill the context |
| Reranker | none | start without one, and add one only if it wins the offline comparison |
The dense stage was first specified with a remote embedding API. A day later that was changed to local models, and the design lists three candidate pairings of a dense model with a sparse one to compare. Which one is not decided.
Choosing by measurement
A retrieval config is easy to argue for and hard to justify. The specification commits to how the choice will be made before any result exists.
A query set built from the corpus. For each of ten sample brands, up to 50 active chunks are sampled, spread across page types. For each chunk a model writes two queries that the chunk answers: one phrased as a natural question and one as keywords. The chunk is the gold answer for both. Twenty of these are checked by a person, and each query carries a status that says whether it was machine-made, human-checked or made stale by the chunk changing.
Content-hash chunk ids are what make this set durable. A gold label is a chunk id. If the page is re-read and that passage is unchanged, the id is unchanged and the label still holds. With positional ids every re-read would invalidate the whole set.
Three systems, three metrics. Sparse alone, dense alone and the hybrid are run on the same queries and compared on recall at 5, recall at 10 and mean reciprocal rank at 10.
A rule fixed in advance. The system with the higher recall at 5 becomes rc-1, on one condition: no single brand’s recall at 5 may drop by more than 0.1 compared with the alternative. An average that improves while one customer’s retrieval gets clearly worse is not an improvement I want to ship. The design states that no target value was set before measuring, so the result cannot be bent toward one.
The reranker waits. The paper behind this lineage reports that adding modules to a retrieval pipeline does not reliably help and that a reranker can lower quality. So the first config has none. A reranker would be evaluated the same way and added only if it wins.
Why it is not built
Two decisions are open, and both are about operations more than retrieval.
| Open decision | The tension |
|---|---|
| Which process builds the index | The API process already runs measurement, scheduling and recovery on a server whose memory is shared. An embedding model loaded there competes with all of them. A separate process is another thing to deploy and watch |
| Which models | Three pairings are specified. Choosing needs the evaluation, and the evaluation needs an index, which needs the first decision |
Until those are made, the right amount of code is none. The seam is ready: select_evidence is the only function that would change, the config is already versioned, and every trace already records which config produced it. Swapping the retriever would show up in the data as a change of version string on a known date.
Failure modes the specification anticipates
| Risk | How the specification handles it |
|---|---|
| A filter is forgotten and one brand’s chunks reach another’s prompt | workspace and brand are required fields of the filter, not optional arguments |
| The dense model returns a near-duplicate product | the sparse list and the fusion keep the exact match in play |
| One page dominates the context | at most two chunks per source |
| The query set rots as pages change | labels are chunk ids, and a query whose chunk changed is marked stale |
| The index is behind the store | the design gives the context an index status, so a generator can tell it was served from an older index |
| The average hides a regression | the per-brand floor of 0.1 |
Limits I know about
This is a plan, and plans are cheap. Nothing here has met real data. The constants are borrowed from the systems I read, where they were tuned on other corpora.
Generated queries are easier than real ones. A question that a model writes from a chunk can reuse the chunk’s words, which would favour the sparse index. The keyword variant and the human-checked sample reduce that bias and do not remove it.
Ten brands is a small sample chosen by me. A rule about per-brand regressions is only as good as the brands it is checked on.
