Across layers · read in stack order
Retrieval vs fine-tuning vs prompt optimisation: fixing wrong answers
A model giving wrong answers can be fixed at three different depths of the stack, and they are not interchangeable. Retrieval changes what the model can see, fine-tuning changes how it behaves, and prompt optimisation changes what it is asked. Picking the wrong depth is the most expensive mistake in this index.
Short answer
Diagnose before choosing. If the right fact was never in the context, that is a retrieval problem and no amount of prompting or training fixes it.
By Lattice editorial · Licence and cost facts verified · method
- pgvectorLayer 03 · Band II StateChanges what the model can see.
- UnslothLayer 04 · Band II StateChanges how the model behaves.
- DSPyLayer 08 · Band III ControlChanges what the model is asked.
| Dimension | pgvector | Unsloth | DSPy |
|---|---|---|---|
| What it changes | The context available at question time | The weights — the model's default behaviour | The instructions and examples it is given |
| Fixes | Missing, private or recent facts | Format, tone and narrow-task behaviour a prompt cannot hold | Underspecified instructions and weak examples |
| Does not fix | A model that ignores the context it is given | Missing knowledge — weights are a poor database | Facts the model has never seen |
| Needs from you | A corpus, a chunking strategy and a ranking you can inspect | Curated training examples and a GPU | Labelled examples and a metric that scores them |
| Cost of being wrong | Low — re-index and retry | High — a training run, and a model you now have to serve | Low — prompts are text and revert cleanly |
| Adopt first when | The right facts are absent or out of date | Prompting has plateaued on a narrow, stable task | The facts are present but the model uses them badly |
Scroll the table sideways to see every tool.
What this table is not. These are editorial judgements, not benchmarks: Lattice has not run these tools head to head, and no cell uses GitHub stars or vendor benchmark claims as evidence. Licence and cost facts are re-checked on a schedule the build enforces — the receipt is public.
The order
Which should you adopt first: pgvector, Unsloth or DSPy?
Diagnose before choosing. If the right fact was never in the context, that is a retrieval problem and no amount of prompting or training fixes it. If the fact was there and the model ignored or misused it, optimise the prompt first, because it is cheap to try and cheap to undo. Fine-tune last, for narrow and stable tasks where prompting has measurably plateaued — it is the only one of the three that leaves you with a new artefact to serve and retrain.
Rules of thumb
- Read the retrieved context before touching the prompt. Most “the model is wrong” bugs are “the ranking is wrong” bugs.
- Fine-tuning teaches behaviour, not facts. If the answer changes monthly, it belongs in retrieval.
- All three need a scored example set to know whether they worked. Build it first; it is shared.
Quick answers
- When should you use pgvector, and when should you skip it?
- Use pgvector when: under a few million vectors, or when retrieval joins rows you already have. Skip it when: vector search has become the workload rather than a side feature.
- When should you use Unsloth, and when should you skip it?
- Use Unsloth when: LoRA fine-tuning on a single GPU, with memory and time roughly halved. Skip it when: you need a training stack you can audit line by line.
- When should you use DSPy, and when should you skip it?
- Use DSPy when: compiling prompts into optimised programs from labelled examples. Skip it when: you have no examples and no way to score them.