Every change below was measured with the same scripts before
and after, on the same questions. Some were kept, many were
not. The full notes are in SESSION-LOG.md in the
repository.
The test sets used throughout (sizes and the test machine are in What it was tested on):
| Test set | What it is | Questions |
|---|---|---|
| Handbook | A handwritten 20-section employee handbook, including 5 near-duplicate sections meant to confuse the search | 58 |
| 4 documents | Four longer policy documents (handbook, IT security, engineering, legal), about 117 chunks | 55 |
| Resume |
A fictional one-page resume, as .txt and
.pdf
|
14 |
"Right first" means the passage that holds the answer was the first search result.
Kept
1. Task prefixes
nomic-embed-text expects the label
search_query: before questions and
search_document: before passages. Adding them
was the biggest single improvement on the project, and costs
nothing.
2. A measured relevance threshold
The cut-off of 0.63 comes from running answerable and general-knowledge questions and placing it in the gap between their scores (0.640 vs 0.567). See Finding the right passages.
3. Keeping headings with their text
A splitting bug could cut a long section inside its own
## marker, leaving chunks with nothing but a
heading.
4. Automatic title headers
Documents with fewer than two headings get a "Title › Section" label embedded above each chunk.
On structured documents the same label cost one refusal per test set, which is why it's only added when a document has no headings of its own.
5. Whole small documents, neighbours for big ones
The model reads short documents whole, and long ones as matching passages plus the passages around them, with the title page and a 1,200-token cap per document. See Answering.
6. Rewriting follow-up questions
Questions like "tell me more about her" are rewritten into standalone questions before searching, with guard rails against wrong rewrites. See Follow-up questions.
Built, measured, not the default
7. Hybrid search (vector + keyword)
Still in the code (RETRIEVE_MODE=hybrid), but it
never beat plain vector search. Common words, plural forms and
terms like "401(k)" pulled the keyword side to wrong sections.
See
Why plain vector search.
8. A different way to merge hybrid results (DBSF)
The default merge uses rank positions only. DBSF combines the actual scores instead, which should let a confident vector result win. It fixed some questions and broke about as many others.
Removed
9. Semantic chunking
Cuts where the topic seems to change between sentences. It
only cuts at ., ! or ?,
so bullet lists were glued together, and the handbook became
48 scraps. It needs one AI call per sentence.
Recursive stays the default because semantic never answered better: about the same ranking on the handbook but one wrong refusal, clearly worse on the resume, and one AI call per sentence. (Semantic is still available through the API.)
10. Detecting headings from plain lines
Treating short Title Case or ALL CAPS lines as headings, for
documents without # markers. On its own it made
the resume slightly worse and changed nothing elsewhere; too
easy to mistake an ordinary line for a heading.
11. Bigger chunks (800 characters) with small leftovers merged
Fewer, larger chunks, so each one carries more context. It blurred the section boundaries of structured documents, and the model started refusing questions it could answer.
12. AI-written context for each chunk (Contextual Retrieval)
llama3 wrote a sentence of context for every
chunk. Better at putting the right passage first, but far too
slow on a CPU, and one vague sentence pushed its chunk out of
the results entirely.
The top-5 number decides whether the model can see the answer at all, so this one lost where it matters. The simple title header was kept instead.
How quality is measured explains the scripts behind these numbers.