Sub topic 14
Maintenance and common failure modes
This chapter assumes you have read the earlier chapters on prompting, RAG, and fine-tuning. It also assumes you have an evaluation set. Choosing an approach is a one-time decision, but keeping it working is ongoing. Each approach breaks in its own way, and you need a routine that catches the breakage.
What changes over time
Three things drift after launch:
- The world. Prices, policies, and product names change.
- The inputs. Users start asking questions you did not expect.
- The model. A provider updates a hosted model, or you switch to a new base model.
Each approach is exposed to these in a different place.
| Approach | What you maintain | Typical failure |
|---|---|---|
| Prompting | Prompt text, few-shot examples | A model update changes how the prompt is read. Examples go stale. |
| RAG | Documents, chunks, embeddings, index | Stale or missing documents. Retrieval returns the wrong chunks. |
| Fine-tuning | Training data, tuned weights | The tuned model falls behind the base model. Facts it learned become outdated. |
Failure modes by approach
Prompting
Long prompts grow by accretion. Someone adds a rule to fix one bug, and another rule now conflicts with it. Keep the prompt in version control and run the evaluation set after every edit. Few-shot examples also need review. If your labels or style change, old examples silently teach the old behavior.
RAG
Most RAG bugs are retrieval bugs, not model bugs. Check these in order:
- Stale index. The source document changed, but the stored chunks and vectors did not. Re-embed on change, and record a timestamp on each chunk.
- Wrong chunks. Chunks that are too small lose context. Chunks that are too large dilute the match. Look at what was actually retrieved before blaming the model.
- Embedding mismatch. If you change the embedding model, every stored vector must be recomputed. Vectors from two models cannot be compared.
- Ungrounded answers. The model ignores the context and answers from memory. Keep the "say you don't know" instruction and test it with questions that have no answer in your documents.
Fine-tuning
A fine-tuned model is a snapshot. It encodes the data and the base model from the day you trained it. Common problems:
- Stale facts. If you trained facts into the weights, they cannot be updated without retraining. This is why facts belong in RAG.
- Regression on other tasks. Narrow training can degrade general ability. Test a few tasks you did not train on.
- Base model retirement. When the provider retires the base model, your tuned version may go with it. Keep your training data and scripts, because the data outlasts any set of weights.
- Parameter-efficient tuning (LoRA). The adapter is small and cheap to retrain, but it is tied to one base model version. Store the base model version next to each adapter.
A regression loop
The same evaluation set protects all three approaches. Run it on a schedule and before every change.
A minimal runner looks like this:
def run_eval(answer_fn, eval_set, baseline=0.9):
failures = []
for case in eval_set:
output = answer_fn(case["input"])
if case["expected"].lower() not in output.lower():
failures.append(case["input"])
score = 1 - len(failures) / len(eval_set)
return score >= baseline, score, failures
eval_set = [
{"input": "What is the refund window?", "expected": "30 days"},
{"input": "Who do I contact about invoices?", "expected": "billing"},
]
def stub_answer(question):
return "Refunds are accepted within 30 days. Contact billing for invoices."
passed, score, failures = run_eval(stub_answer, eval_set)
print(passed, score, failures)Monitoring in production
Log the question, the retrieved chunks (for RAG), the prompt version, the model version, and the answer. When quality drops, these records show which of the three drifts caused it.
Exercise
Six months after launch, a RAG support bot starts quoting an old return policy. The evaluation set still passes. Give two likely causes and one fix for each.
Show answer
First, the index is stale: the policy document changed but its chunks were not re-embedded. Fix it by re-indexing on document change and storing a timestamp per chunk. Second, the evaluation set is outdated and does not contain the new policy question. Fix it by adding cases from recent traffic that cover the current policy.