treatment-status-de-authored / preregistration_v1.md
Mehran-NixiAI's picture
Place dataset files at repo root (v1)
2555418
|
Raw
History Blame Contribute Delete
12 kB
# Preregistration — Calibration & Treatment-Status Benchmark for German Clinical Text (Local LLMs)
**Version:** 1.0 · **Status:** PREREGISTERED (to be frozen by git commit before any model is run)
**Date:** 2026-06-13 · **Scope:** Phase 1 — language models only (Nixi AI product evaluation is out of scope, separate study).
> This document commits every analysis choice *before* inference. The authoritative
> timestamp is the git commit. Companion frozen artifacts: `annotation_guideline_v1_1.md`,
> `grascco_scan_v2.py`. Nothing below may be changed after the first model is run; permitted
> exceptions are logged guideline clarifications (v1.x) that do **not** retroactively relabel data.
> **Public-release note (v1, authored arm).** This public release covers the authored arm only.
> The GraSCCo arm and its tooling (`grascco_scan_v2.py`, `frozen_eval_set.csv`) are deferred to a
> later version and are not included here. The annotation guideline ships as
> `annotation_guideline_v1.2.md`, the adjudicated/clarified version of the v1.1 referenced below;
> the binary safety definition is unchanged across v1.1→v1.2.
---
## 1. Background & rationale
In clinical documentation the dangerous error is not a low score — it is a *confident wrong
answer*. A drug that was *discussed and declined*, *planned*, *stopped*, or only *historical*
must not be recorded as *administered* (a §630a/§630f BGB documentation-liability problem). We
measure not just accuracy but **calibration**: whether a local open-weight LLM's confidence is
trustworthy when it classifies the **current administration status** of a treatment in German
clinical text. Everything runs **on-prem**; no patient data leaves the machine (data-sovereignty
thesis demonstrated, not asserted).
---
## 2. Research question & hypothesis
**Primary question.** Can local open-weight LLMs correctly classify whether a treatment mentioned
in German clinical text is *currently being administered*, and is their confidence well-calibrated —
especially on the hard cases (negation, refusal, "discussed", paused/stopped, cross-sentence reversal)?
**Primary hypothesis (falsifiable).** Accuracy and calibration **diverge**: models look fine on
plainly affirmative administration but are **overconfident** on the epistemically hard classes, and
the worst error — **confidently asserting current administration when there is none** — clusters in
those hard cases. A clean opposite result (well-calibrated) is a valid, reportable finding.
---
## 3. Primary endpoint
**High-confidence false-administration rate** = the proportion of truly *not-given* treatment
mentions that a model labels **given** with confidence **≥ 0.90**.
- **"given" is defined as CURRENT administration/continuation** at the time of documentation
(Option A). A drug that is **paused, stopped, planned, discussed, refused, withheld, historical,
or merely listed is not given**, even if administered earlier in the episode.
- Reported **two ways**: (a) overall; (b) split into **active not-given** (refused / withheld /
paused / stopped / planned — clinically dangerous to call given) vs **historical/background**
(episode-scoping slip). The **active** number is the headline safety figure.
- Every endpoint figure is reported with a **bootstrap 95% CI, resampled at the document level**
(mentions are clustered within letters; one letter contributes up to 214 mentions).
---
## 4. Secondary questions
Does bigger help (Qwen 7→14→32B; Llama 8→70B) · does German-tuning help (SauerkrautLM vs Llama-3.1-8B)
· does medical-tuning help (OpenBioLLM, Med42 vs Llama-3.1-8B; BioMistral cross-base) · error
*direction* (do models lean toward "given") · can confidence discriminate right from wrong · is
miscalibration fixable with a single temperature parameter · position/letter bias (option permutation)
· operational deployability (latency, VRAM) · do models fail on the same items (error correlation) ·
cross-lingual replication (**deferred** — see §6).
---
## 5. Label scheme (governed by `annotation_guideline_v1_1.md`)
**Annotation = 9 leaves**, each with a fixed binary value; the model is graded on **binary** (primary)
and a **6-class** mid-level (error taxonomy). Binary uses the Option-A current-administration rule.
| Leaf | Binary | 6-class |
|---|---|---|
| GIVEN · CONTINUED-active | given | GIVEN |
| PLANNED | not_given | PLANNED |
| DISCUSSED | not_given | DISCUSSED |
| REFUSED (+AMA modifier) | not_given | REFUSED |
| WITHHELD/CONTRAINDICATED · PAUSED · STOPPED | not_given | WITHHELD |
| HISTORICAL / background | not_given | HISTORICAL |
| DROP (not a treatment mention) | — | — |
**Phenomena tagged for breakdown:** negation · refusal · discussion-only · cross-sentence reversal ·
PRN/bei Bedarf · paused · stopped · contraindication/allergy · historical (Z. n.) · conditional
(falls…dann) · frustran.
Section-heading routing, the home-med rule, the "kein = finding" DROP rule, and the validated
ambiguous-heading handling ("Aktuelle Medikation" → line-by-line, 48/48 no verb in corpus) are
specified in the frozen guideline.
---
## 6. Datasets & sample size
| Dataset | Lang | Role | N (target) | Status |
|---|---|---|---|---|
| **GraSCCo** (synthetic discharge letters) | DE | Primary natural result | ~500–600 labelable items (label all valid mentions from 63 letters) | downloaded, scanned |
| **Authored minimal-pair set** | DE | Controlled hard-class arm | ~150, weighted to deficient classes | to build |
| *i2b2/n2c2 2010* | EN | Cross-lingual replication | — | **deferred** (access unavailable) |
| *BRONCO150* | DE | Real-German validation | — | future phase |
**Authored-set targets** (natural GraSCCo is GIVEN-scarce and historical-heavy):
REFUSED ~40 (0 natural) · GIVEN ~30 · PAUSED ~20 · STOPPED ~20 · PRN ~20 · DISCUSSED ~15 ·
cross-sentence ~25 · WITHHELD controls ~15–20.
**Reporting rule:** GraSCCo labeled as-found = the **natural (imbalanced)** distribution; the
authored set = the **stratified** arm with guaranteed per-class denominators. The two are reported
**separately, never silently merged**.
**Scope note:** Phase 1 is **synthetic German + controlled authored German**. Real English (i2b2)
and real German (BRONCO) are the planned next phases; this sequencing is stated as a limitation, not hidden.
---
## 7. Annotation & label quality
- Primary annotator labels the full set off the cleaned pre-fill (`grascco_candidate_mentions`).
- **Independent human second annotator (a German-speaking clinician, not the primary)** labels
a **20–30% stratified sample (~120–180 mentions)**, **blind** to the primary's labels.
- Report **Cohen's κ per leaf and for the binary** (targets: binary ≥ 0.80; per-leaf 0.60–0.80
acceptable; < 0.60 → guideline clarification before reliance). Rare leaves will have few items → κ
interpreted cautiously.
- Adjudicate disagreements, record resolutions, then **freeze** the eval set.
- An AI labeling pass, if done, is reported **only** as an exploratory third signal — never as the κ rater.
---
## 8. Models (frozen list)
All open-weight, Ollama-runnable on 48 GB, commercial-safe, clean single-token emitters (no
reasoning/CoT models). Verify exact tag, quant, and license on pull; record Ollama version.
| # | Model | Role | Base | Size | Primary quant |
|---|---|---|---|---|---|
| 1 | Llama 3.1 8B Instruct | general baseline (+fp16 anchor) | Llama-3 | 8B | fp16 |
| 2 | SauerkrautLM-8B | German-tuning probe (vs #1) | Llama-3 | 8B | fp16/Q8 |
| 3 | OpenBioLLM-8B | medical-tuning probe (vs #1) | Llama-3 | 8B | fp16/Q8 |
| 4 | Med42-v2 8B | medical-tuning probe #2 | Llama-3 | 8B | fp16/Q8 |
| 5 | Qwen2.5-7B Instruct | size ladder | Qwen2.5 | 7B | fp16/Q8 |
| 6 | Qwen2.5-14B Instruct | workhorse + calibration ref | Qwen2.5 | 14B | Q8 |
| 7 | Qwen2.5-32B Instruct | size step | Qwen2.5 | 32B | Q8 |
| 8 | Gemma 2 27B IT | family diversity | Gemma 2 | 27B | Q8 |
| 9 | BioMistral-7B | cross-base medical | Mistral | 7B | fp16/Q8 |
| 10 | Llama 3.3 70B Instruct | large anchor ("does bigger help?") | Llama-3.3 | 70B | Q4_K_M (caveat) |
**Comparison matrix:** bigger → Qwen 7/14/32 + Llama 8/70; German-tuning → #2 vs #1; medical-tuning
→ #3,#4 vs #1, #9 cross-base. **Fairness:** Q8 (≤32B) / fp16 (≤8B); the 70B is Q4-only on 48 GB — a
**documented caveat**, not a fair-comparison point.
---
## 9. Inference protocol (frozen)
- **Task A (primary):** binary forced choice (given / not-given).
- **Task B (secondary):** 6-class forced choice (GIVEN/PLANNED/DISCUSSED/REFUSED/WITHHELD/HISTORICAL).
- **Forced choice, "answer with one letter only."** Aggressive single-letter prompt for verbose
medical models so preamble does not pollute first-token logprobs.
- **Decoding:** temperature 0, fixed seed, `top_logprobs = 20`, Ollama ≥ 0.12.11.
- **Confidence rule:** probability of the chosen letter **renormalized over the valid option letters
only** (A–E), not raw vocabulary softmax.
- **Passes:** one deterministic pass for primary metrics; an **N ≥ 20** repeat pass for the determinism layer.
- **Pre-run check:** confirm on one model that Ollama honors the seed and returns logprobs before pulling the rest.
---
## 10. Metrics (frozen; all with document-level bootstrap 95% CIs)
- **Calibration:** ECE (equal-width + adaptive), MCE, Brier, log loss, calibration slope+intercept,
temperature T + post-scaling ECE, class-wise ECE.
- **Discrimination / abstention:** risk–coverage, accuracy@{.7,.8,.9,.95}, AUROC, AUPRC (false-given),
AURC/E-AURC.
- **Classification:** accuracy, balanced accuracy, macro-F1, per-class F1, MCC, Cohen's κ vs gold,
full confusion matrix, directional error rates (false-given vs false-not-given).
- **Operational:** latency p50/p95, tokens/sec, VRAM peak, load time, clean-emission/parse-fail rate.
- **Robustness:** flip rate, modal agreement, position-bias (option permutation), prompt-paraphrase variance.
**Primary analysis:** compute the high-confidence false-administration rate (§3) per model, overall and
split active-vs-historical, with document-level bootstrap CIs. The reliability diagram and the headline
rate lead the report; note explicitly if the best-F1 model is not the best-calibrated.
---
## 11. Honesty & validity (to be stated in the write-up)
- Phase 1 = **synthetic German + authored German**; real English (i2b2) and real German (BRONCO) are
named next phases, not hidden weaknesses.
- German labels are **our** judgments until the κ pass; κ is reported.
- Forced choice removes the option to abstain; the risk–coverage view (and a future verbalized-confidence
arm) partially address this.
- Report **unweighted** numbers even if a safety-weighted score is also shown.
- Pin all versions (Ollama, model tags, quant, seed) for reproducibility.
---
## 12. Deliverables checklist
- [x] Preregistered protocol (this file — commit to freeze)
- [x] Frozen annotation guideline (`annotation_guideline_v1_1.md`)
- [x] Extraction/scan tooling (`grascco_scan_v2.py`), cleaned pre-fill CSV
- [ ] Frozen eval sets: GraSCCo-labeled + authored minimal pairs
- [ ] Second-annotator κ reported
- [ ] Inference + scoring code (versions pinned)
- [ ] Metrics tables with CIs + figures (reliability diagram, "where it breaks", risk–coverage)
- [ ] The post (models-only), with limitations and links
---
## 13. What is frozen vs. changeable
**Frozen now (no change after first model run):** research question, primary endpoint + Option-A
"given" definition, secondary questions, 9-leaf scheme + binary/6-class mappings, phenomena list,
datasets + N targets + reporting rule, model list + comparison matrix, inference protocol, confidence
rule, metric list, bootstrap method.
**Permitted:** guideline clarifications logged as v1.x (no retroactive relabeling); recording exact
model tags/quant/Ollama version on pull; extending the determinism N if flip rate is high.