Model Evaluation — Systematic LLM Quality Assessment
Evaluation Framework
5 Dimensions (Always Test All)
| Dimension |
What to Measure |
How |
| Factual Recall |
Specific numbers, dates, thresholds |
Known-answer questions |
| Calculation |
Step-by-step math, correct final answer |
Problems with verifiable solutions |
| Edge Cases |
Ambiguous scenarios requiring judgment |
Tricky questions with nuanced answers |
| Citation |
References real sources (IRC §, IRS Pub) |
Check every citation exists |
| Coherence |
Well-structured, complete, no degeneration |
Length, structure, readability |
Scoring
PASS: Correct answer, well-reasoned, properly cited
PARTIAL: Correct concept, wrong number or missing citation
FAIL: Wrong answer, hallucinated citation, or degenerated output
Comparison Methodology
Side-by-Side Evaluation
# Run same question through both models
for question in eval_set:
response_a = query(model_a, question)
response_b = query(model_b, question)
# Score independently on 5 dimensions
Regression Detection
When fine-tuning iterations:
- Run eval BEFORE training (baseline)
- Run eval AFTER training (candidate)
- Compare dimension-by-dimension
- Any dimension regression → investigate before deploying
Overfit Detection Signs
- Model outputs dots, repeating characters, or gibberish
- Responses are exact copies of training examples
- Model can't handle questions outside training distribution
- Response length dramatically changes (too short or infinite)
Root cause: Too many epochs on too little data.
Fix: Reduce epochs, add more diverse training data.
Evaluation Set Design
For Domain-Specific Models (e.g., Tax)
| Category |
Count |
Purpose |
| Factual (known answers) |
10 |
Tests memorization of current facts |
| Calculation |
5 |
Tests reasoning + arithmetic |
| Scenario-based |
5 |
Tests application of rules |
| Edge cases |
5 |
Tests judgment under ambiguity |
| Out-of-domain |
3 |
Tests guardrails (should refuse/deflect) |
| Total |
28 |
Minimum viable eval set |
Question Quality Rules
- Every question must have a verifiable correct answer
- Include the year in factual questions (tax rates change)
- Calculation questions must have worked solutions for comparison
- Edge cases should have multiple valid perspectives
- Out-of-domain questions test that the model doesn't hallucinate expertise
Evaluation Tooling
evaluate.py Pattern
def evaluate(models: list[str], questions: list[dict]) -> list[dict]:
results = []
for q in questions:
row = {"question": q["text"], "expected": q["answer"], "responses": {}}
for model in models:
response = query_ollama(model, q["text"])
row["responses"][model] = {
"text": response,
"tokens": token_count,
"latency_ms": latency,
"matches_expected": check_answer(response, q["answer"]),
}
results.append(row)
return results
Automated Scoring (Where Possible)
- Factual: Extract numbers, compare to expected
- Calculation: Extract final answer, compare to expected
- Citation: Regex for IRC §, IRS Pub — verify they exist
- Coherence: Check length > 100 chars, no repeated tokens
- Edge cases: Requires human review
Training Data vs Model Quality Correlation
Quality = f(data_quality × data_quantity × model_size) / epochs²
More data → linear improvement
Better data → exponential improvement
More epochs → diminishing returns → overfit
Bigger model → better reasoning, same fact accuracy
Production Deployment Checklist
Before deploying a fine-tuned model:
1---2name: model-evaluation3description: LLM evaluation methodology — side-by-side comparison, domain-specific benchmarking, regression detection for fine-tuned models. Trigger on: "evaluate model", "benchmark", "model comparison", "A/B test models", "model quality", "accuracy test", "regression test model", or any discussion about measuring LLM output quality.4---56# Model Evaluation — Systematic LLM Quality Assessment78## Evaluation Framework910### 5 Dimensions (Always Test All)1112| Dimension | What to Measure | How |13|-----------|----------------|-----|14| **Factual Recall** | Specific numbers, dates, thresholds | Known-answer questions |15| **Calculation** | Step-by-step math, correct final answer | Problems with verifiable solutions |16| **Edge Cases** | Ambiguous scenarios requiring judgment | Tricky questions with nuanced answers |17| **Citation** | References real sources (IRC §, IRS Pub) | Check every citation exists |18| **Coherence** | Well-structured, complete, no degeneration | Length, structure, readability |1920### Scoring2122```23PASS: Correct answer, well-reasoned, properly cited24PARTIAL: Correct concept, wrong number or missing citation25FAIL: Wrong answer, hallucinated citation, or degenerated output26```2728## Comparison Methodology2930### Side-by-Side Evaluation31```python32# Run same question through both models33for question in eval_set:34 response_a = query(model_a, question)35 response_b = query(model_b, question)36 # Score independently on 5 dimensions37```3839### Regression Detection40When fine-tuning iterations:411. Run eval BEFORE training (baseline)422. Run eval AFTER training (candidate)433. Compare dimension-by-dimension444. **Any dimension regression → investigate before deploying**4546### Overfit Detection Signs47- Model outputs dots, repeating characters, or gibberish48- Responses are exact copies of training examples49- Model can't handle questions outside training distribution50- Response length dramatically changes (too short or infinite)5152**Root cause:** Too many epochs on too little data.53**Fix:** Reduce epochs, add more diverse training data.5455## Evaluation Set Design5657### For Domain-Specific Models (e.g., Tax)5859| Category | Count | Purpose |60|----------|-------|---------|61| Factual (known answers) | 10 | Tests memorization of current facts |62| Calculation | 5 | Tests reasoning + arithmetic |63| Scenario-based | 5 | Tests application of rules |64| Edge cases | 5 | Tests judgment under ambiguity |65| Out-of-domain | 3 | Tests guardrails (should refuse/deflect) |66| **Total** | **28** | Minimum viable eval set |6768### Question Quality Rules691. Every question must have a **verifiable correct answer**702. Include the **year** in factual questions (tax rates change)713. Calculation questions must have **worked solutions** for comparison724. Edge cases should have **multiple valid perspectives**735. Out-of-domain questions test that the model **doesn't hallucinate** expertise7475## Evaluation Tooling7677### evaluate.py Pattern78```python79def evaluate(models: list[str], questions: list[dict]) -> list[dict]:80 results = []81 for q in questions:82 row = {"question": q["text"], "expected": q["answer"], "responses": {}}83 for model in models:84 response = query_ollama(model, q["text"])85 row["responses"][model] = {86 "text": response,87 "tokens": token_count,88 "latency_ms": latency,89 "matches_expected": check_answer(response, q["answer"]),90 }91 results.append(row)92 return results93```9495### Automated Scoring (Where Possible)96- **Factual:** Extract numbers, compare to expected97- **Calculation:** Extract final answer, compare to expected98- **Citation:** Regex for IRC §, IRS Pub — verify they exist99- **Coherence:** Check length > 100 chars, no repeated tokens100- **Edge cases:** Requires human review101102## Training Data vs Model Quality Correlation103104```105Quality = f(data_quality × data_quantity × model_size) / epochs²106107More data → linear improvement108Better data → exponential improvement109More epochs → diminishing returns → overfit110Bigger model → better reasoning, same fact accuracy111```112113## Production Deployment Checklist114115Before deploying a fine-tuned model:116- [ ] Run full eval set (28+ questions)117- [ ] Compare against baseline on all 5 dimensions118- [ ] No dimension regression119- [ ] Overfit check: test 5 out-of-domain questions120- [ ] Coherence check: 10 random prompts, all produce structured output121- [ ] Latency check: <5s for typical responses122- [ ] VRAM check: fits in target GPU with room for inference