Eval Framework + Small LLMs improvements
Merged
SO
1y ago+11028+11028+01234567890123456789012345678901234567890123456789-43-43-01234567890123456789
Key changes
- Removed response_format: { type: "json_object" } for localLLMs
- Simplified prompts with few-shot examples that the smaller model could follow
- Flexible JSON parsing that can extract JSON from various response formats
- Fuzzy category matching to handle minor naming variations
- Smaller batch sizes (5 instead of 25) to reduce context length
Extra changes:
Options: "strict", "json_object", "none"
LLM_JSON_MODE=json_object bin/rails 'evals:run[...]'
JSON Modes Explained
| Mode | Description | Use Case |
|---|---|---|
| strict | Full JSON schema with strict: true | OpenAI API, large models with schema support |
| json_object | Simple { type: "json_object" } format | Models with basic JSON mode (e.g., some vLLM setups) |
| none | No response format constraint | Local LLMs without JSON mode support |
Results
| Metric | Before | After | Improvement |
|---|---|---|---|
| Accuracy | 15.0% | 89.0% | +74 points |
| Precision | 100.0% | 88.37% | (slightly lower but with much higher coverage) |
| Recall | 2.3% | 98.7% | +96.4 points |
| F1 Score | 4.5 | 93.25 | +88.75 points |
| Easy | 2.86% | 94.29% | +91.4 points |
| Medium | 2.94% | 94.12% | +91.2 points |
| Hard | 5.26% | 63.16% | +57.9 points |
| Edge Cases | 100% | 100% | Maintained |
BEFORE:
By Difficulty:
easy: 2.86% accuracy (1/35)
medium: 2.94% accuracy (1/34)
hard: 5.26% accuracy (1/19)
edge_case: 100.0% accuracy (12/12)
AFTER:
By Difficulty:
easy: 94.29% accuracy (33/35)
medium: 94.12% accuracy (32/34)
hard: 63.16% accuracy (12/19)
edge_case: 100.0% accuracy (12/12)
Summary by CodeRabbit
-
New Features
- Full evaluation toolkit: create/manage datasets, run evaluations (categorization, merchant detection, chat), export/trace to Langfuse, experiment orchestration, comparison reports, and CLI tasks.
-
Data
- Multiple golden benchmark datasets added (categorization, merchant detection, chat; light and v2 variants).
-
Documentation / UI
- OpenAI JSON Mode setting with UI control and translations.
-
Chores (DB)
- New evaluation schema/tables and added alternative_match column.
-
Tests
- New tests for dataset import and runner behavior.
✏️ Tip: You can customize this high-level summary in your review settings.