Example numbers and stories
Example numbers (teacher's RAG project)
Interviewers trust concrete numbers. This is what a strong numbers table looks like; build the same for your own project.
| Part | What I used | Value |
|---|---|---|
| Stack | FastAPI, PostgreSQL 17 + pgvector, Ollama (local, offline) | — |
| Generator | qwen3:8b, temperature | 0.0 |
| Embedder | qwen3-embedding:4b, normalized, 2560 dims, query instruction prefix | 2560 |
| Chunks | max tokens / overlap (cut at a line break when possible) | 1800 / 150 |
| Retrieval | dense top-k, plus keyword search on rare words only | k = 12 |
| Rare word | appears in at most this share of chunks | ≤ 5% |
| Fusion | Reciprocal Rank Fusion, | k = 60 |
| Context | chunks sent to the LLM | 6 |
| Threshold | min cosine similarity; measured gap: answerable ≥ 0.575, off-topic ≤ 0.408 | 0.50 |
| Keyword gate | a chunk that matched a rare word passes at | 0.35 |
| Answer check | every paragraph must cite [E1]… and share content words with that evidence | — |
| Tests | offline unit tests / live eval questions (incl. world questions it must refuse) | 23 / 23 |
| Tracing | every question logged: intent, model, chunk ids, latency | — |
| Tez fine-tune | Qwen3.5-4B QLoRA, 38,258 rows; right answers on 1,410 test requests (tez8 had 1,066) | 1,298 |
| Analytics assistant | MCP server, read-only Postgres, statement timeout | 10 s |
the chunk's position in the dense list (1 = top)
its position in the keyword list
the constant k: it keeps rank 1 from dominating everything
Example stories (problem → what was measured → fix → result)
- The chunker bug. Every page longer than about 7,200 characters was chunked wrong. A start offset of −1 broke the split. I found it from missing answers, wrote tests with long single-paragraph, blank-line and indented pages, fixed it, and re-indexed.
- The refusal that was wrong. "Zaxarova nima dedi?" was refused even though the article existed. A name is a rare exact word, and dense search alone scored it under 0.5. I added keyword search on rare words (in ≤5% of chunks), fused with RRF, and let keyword-matched chunks pass at 0.35. The question was answered correctly and the world-question refusals still held.
- Never answer from world knowledge. The threshold alone wasn't enough, so I added a check after generation: each paragraph must cite real evidence IDs and share content words with them, otherwise the system returns the refusal. Verified with the 23 live questions.
- Numbers never pass through the model. In an analytics assistant, the model only picks the tool and its arguments. The database computes, and the sentence with numbers is built from the tool result. That removes the classic "LLM changed the number" bug.
- Fine-tuning a small model. In Tez, the 2B base model planned 20 of 40 tasks correctly and the 4B model 34 of 40. I fine-tuned Qwen3.5-4B with QLoRA on 38,258 generated and execution-checked rows. On 1,410 test requests, right answers rose from 1,066 (tez8) to 1,298 (tez17) and silent wrong answers fell from 138 to 55. The model plans in JSON, DuckDB computes.
How to practise this week
- Write every yellow box by hand once. Writing makes it stick.
- Say each one out loud with a timer, 30–45 seconds, then add the blue story.
- Draw the diagrams from chapters 5, 11 and 12 from memory.
- Rehearse the 5 stories until each takes about a minute.
- Then do a mock interview with Claude: one question at a time, feedback after each answer.
Questions about this chapter?
The course, homework review and the other five books are in Uzbek. Questions in English are welcome on Telegram.