Files
Sprachmittler/docs/MODEL_EVALUATION.md
schihei 0ab5ae78bf feat(m7-m8): evaluation harness, privacy self-test, localisation and release
M7: corpus manifest loader/validation, chrF/BLEU/token/numeric metrics, raw-output and report.md/report.json writer, and sprachmittler-cli languages/detect/eval. A synthetic 4-segment run with the 7B validated the harness; the private-corpus and 1.8B evaluation and the default-model ADR remain open.

M8: privacy-check root fixture + seeded self-test wired into make verify; English/German localisation for the app shell; end-user USER_GUIDE; release.sh (unsigned archive, Developer ID sign, notarise/staple, DMG, --dry-run); idle CPU/memory and warm 7B measurements in PERFORMANCE.

Docs: PROGRESS M7–M8, MODEL_EVALUATION results log/gate status, PERFORMANCE measurements, TESTING evaluation cases, ADR-008 status. Compatibility/VoiceOver/notarisation gates remain manual.

Verified: make verify green (format, strict lint, privacy self-test, Debug+Release signatures, 227 package tests); CLI languages/detect/eval run; release dry-run.
2026-11-26 14:16:21 +01:00

91 lines
5.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Model evaluation
Status: Draft v1.0. Module: `SprachmittlerEval` (CLI only). Agent: `translation-evaluator`. Skill: `translation-quality`.
The default model is the one that works best on **your** texts on **your** Mac, at an acceptable speed. Publisher benchmarks (FLORES-200, WMT26, IFMTBench, WildMTBench) are context, not evidence for the default.
## 1. Corpus
- Manifest: `evaluation/corpus.json` (copy from `evaluation/corpus.example.json`; schema `evaluation/corpus.schema.json`).
- Texts: `evaluation/corpus/` (git-ignored, denied to agents). Use texts you are allowed to process; prefer public or your own.
- Size: about 60 segments. Suggested mix:
| Category | Segments | What it tests |
|---|---|---|
| `en-de-prose` | 10 | baseline EN→DE |
| `de-en-prose` | 10 | baseline DE→EN |
| `technical` | 8 | compounds, units, acronyms |
| `legal` | 4 | formality, terms |
| `ui` | 6 | short strings, buttons, placeholders |
| `markdown` | 5 | structure, links, code spans |
| `json` | 4 | keys vs values |
| `placeholders` | 5 | `{{var}}`, `%s`, `${x}`, URLs, e-mails |
| `numbers` | 4 | decimals, thousands, units |
| `idioms` | 4 | non-literal meaning |
| `long` | 2 | chunking and context |
| `cjk` | 3 | CJK direction, character density |
| `rtl` | 2 | Arabic/Hebrew direction |
- References: human translations written or corrected by you. For public texts, a published translation may be used with attribution. Mark `referenceKind: "human"` or `"public"`.
- Never commit private corpus material. The manifest is shared; the texts and results are not.
## 2. Procedure
1. Record hardware (chip, memory), macOS, Ollama version, model digests, `num_ctx`, sampling, prompt policy.
2. For each model: unload (`keep_alive: 0`), run one warm-up, then all segments warm, in manifest order.
3. Run 3 times at temperature 0.7 to measure variance; one run at 0.2 for comparison.
4. Compare 7B vs 1.8B. Compare default vs Structured Data 1 on the `markdown`, `json` and `ui` categories only.
5. Store raw outputs and metrics under `evaluation/results/<ISO date>/<model-slug>/`.
6. Generate `report.md` and `report.json`.
7. Review a sample in the panel and record correction minutes in `corrections.csv` (`segmentID,model,minutes,notes`).
Do not run other heavy workloads during measurement.
## 3. Metrics
| Metric | Definition |
|---|---|
| Failure rate | Share of segments with empty, truncated, loop, preamble or transport failure |
| chrF | Character n-gram F-score against the reference (primary, language-agnostic) |
| BLEU | SacreBLEU-style corpus BLEU (secondary; tokenisation documented) |
| Protected-token retention | Share of URLs, e-mails, placeholders and code spans present in the output; must be 1.0 |
| Numeric consistency | Share of normalised numeric values present; locale separators normalised |
| Structure | Paragraph/sentence count match; Markdown/JSON key preservation on structured categories |
| First-token latency | Median and p90 from request to first delta |
| Warm s/segment | Median and p90 total time |
| Cold load | `load_duration` of the first request after unload |
| Memory | `size` and `size_vram` from `/api/ps` after the first request |
| Human rating | 1–5 adequacy + fluency, or correction minutes |
chrF and BLEU are implemented in `SprachmittlerEval` with hand-computed unit tests. Do not add a Python dependency.
## 4. Report format
`report.md` starts with the environment block, then one table per direction/category:
| Model | Temp | Segments | Fail % | chrF | BLEU | Token retention | Num. consistency | First token p50/p90 | Warm s/seg p50/p90 |
|---|---|---|---|---|---|---|---|---|---|
Followed by "Observations" (max 10 bullets, no quotations above 15 words) and "Limitations".
## 5. Default-model gate (T7.5)
Write ADR "Default model and sampling" with:
- report location and date, corpus size per category, hardware;
- chosen default and Fast preset, with the numbers that justify them;
- rule used, for example: "no model may be default if protected-token retention < 1.0 or failure rate > 2%; then highest chrF on `en-de-prose` + `de-en-prose` + `technical`, then highest human rating, then lowest first-token latency";
- the chosen temperature and prompt policy;
- what triggers re-evaluation (new model version, Ollama upgrade, prompt change, user complaints).
Until the ADR is accepted, the 7B remains labelled provisional and the app may ask the user to pick a model on first run if both are installed.
Status 2026-11-26: the manifest, metrics and report harness are complete and validated on a synthetic manifest. T7.4 and T7.5 remain open because the private corpus is not present in this checkout and the 1.8B model is not installed. Do not select a default from the synthetic run.
## 6. Results log
| Date | Report | Models | Decision |
|---|---|---|---|
| 2026-11-26 | kit reference only | 7B Q4_K_M | 246 output tokens, 6.52 s, 44.6 tok/s; no corpus evaluation yet |
| 2026-11-26 | synthetic harness validation | 7B Q4_K_M | Harness only (4 synthetic segments, 1 run): fail 0%, chrF 96.34/61.27/94.81/80.84, token retention 1.0, first token 57–102 ms, 0.45–0.91 s/segment. This is not a default-model decision. |