HandoffLens is a research and engineering project for source-grounded information extraction from hospital discharge-summary-style text. It asks a practical reliability question:
How do you make an LLM extraction system prove where its claims came from, and fail visibly when it cannot?
The project is aimed at engineers and data scientists building LLM systems over long, messy, high-stakes documents. It is a portfolio/research artifact, not a medical product.
This repository is my independent work. It does not represent the views, strategies, or endorsement of Cohere or any other model provider.
Structured output is not the same thing as grounded output.
The current public benchmark result is a 207-row ACI-Bench note-generation run with Command A+ plus a deterministic attribution-repair diagnostic:
| Run | Rows | ROUGE-L F1 | Source-token support | Cases with unsupported sentences | Mean output tokens |
|---|---|---|---|---|---|
| Command A+ generated notes | 207 | 0.2550 | 0.6945 | 100.0% | 250.6 |
compact_extractive attribution repair |
207 | 0.2324 | 1.0000 | 24.6% | 435.9 |
The selected repair keeps 91.2% of the raw Command A+ ROUGE-L score while reducing unsupported-sentence case rate by 75.4 percentage points. The tradeoff is output length: repaired notes are 73.9% longer on average. The 1.0000 lexical support score is expected by construction because the repair emits source-dialogue spans; it is a useful gate diagnostic, not proof of semantic factuality.
Two caveats matter. First, this 0.2550 ROUGE-L result is a reproduced public-JSON diagnostic, not an official ACI-Bench leaderboard submission; it should not be compared directly to published full-note scores without matching the official scorer, preprocessing, and split protocol. Second, compact_extractive is treated as a pre-specified repair policy. The four-method repair table is an ablation over the reported rows, not a same-row winner-selection proof.
Earlier development runs explain why this matters. In a 400-case engineering run, roughly 88% of baseline LLM outputs passed JSON schema validation, but only about 10% survived an exact-source provenance check. The baseline produced 5,467 generated quotations that could not be found verbatim in the source text.
That low provenance pass rate is the finding: valid-looking structured output can still be ungrounded.
HandoffLens responds with a candidate-first architecture. Instead of asking the model to freely extract and summarize, the system:
- deterministically identifies source candidates;
- preserves exact source quotations and stable identifiers;
- asks the model to classify ambiguous candidates;
- applies deterministic provenance and consistency gates;
- abstains when evidence is insufficient;
- materializes final labels and summaries only from accepted evidence.
In the fresh June 23 validation rerun, candidate-first v4 passed the deterministic provenance gate on 19 of 20 development cases, with one principled abstention. The remaining open question is whether its higher item count reflects recovered evidence or over-extraction; that is prepared for factual review.
For a quick review, these are the most useful files:
- Public Benchmark Run Results - ACI-Bench, attribution repair, BioScope assertion runs, and explicit non-claims.
- Scientific Write-up - problem framing, architecture, findings, and limitations.
- Claims Register - allowed and prohibited interpretations.
- Reproducibility - commands, private-input boundaries, and artifact handling.
- Benchmark Adapter and Scoring - ACI adapter, scoring, source-support proxies, and BioScope runners.
- Records Adapter Contract - dataset adapter input schema and publishing rules.
- Model Card - intended use, non-use, and limitations.
This public repository contains:
- deterministic provenance gates and validation checks;
- candidate-first extraction and evidence-indexing code;
- structured-output schemas and prompt variants;
- a browser-only synthetic demo;
- aggregate validation summaries;
- source-fidelity and review-packet tooling;
- archived selective-routing/conformal experiments using proxy labels;
- config-driven extraction profiles for discharge summaries and dialogue-like records;
- a benchmark manifest scaffold that blocks unsupported public benchmark claims;
- ACI-Bench and BioScope public benchmark adapters/scorers, including ACI extractive note baselines, Command A+ note evaluation, attribution repair diagnostics, source-support proxies, BioScope same-task baselines, and explicit non-claim boundaries.
It does not contain source clinical records, private cohorts, case-level private outputs, reviewer packets, API keys, or completed human annotations.
The browser demo is intentionally small and safe: it is a deterministic baseline extractor running on synthetic text, with no network calls and no API key.
It also includes precomputed synthetic pipeline snapshots that illustrate the full system behavior:
- accepted evidence with an attached source quote;
- structured abstention when source support is insufficient;
- an audit failure showing why generated summaries need source-fidelity checks.
The full LLM/provenance pipeline is represented in the validation reports and can be run locally only with private inputs and API credentials.
The public artifact is containerized for both the static demo and reproducible validation.
docker compose --profile demo up --build
docker compose --profile eval run --rm eval
docker compose --profile benchmark run --rm benchmarkdemoserves the browser-only synthetic demo athttp://localhost:8080.evalbuilds a clean Node validation image and runsnpm run check:allwithout local result mounts.benchmarkruns the public benchmark unit path and can mount ignored local benchmark/output directories.
External benchmark files should be placed under the ignored local benchmark_data/ directory and mounted read-only at /benchmarks. For example, after placing BioScope XML files under benchmark_data/bioscope/, run:
docker compose --profile benchmark run --rm benchmark npm run benchmark:bioscope:conformal -- --input "/benchmarks/bioscope/abstracts.xml;/benchmarks/bioscope/full_papers.xml" --alpha 0.10 --out results/bioscope-conformal-public-text.jsonThe Docker image does not copy .env, raw clinical data, benchmark corpora, generated samples, or results/.
| Component | Status | Interpretation |
|---|---|---|
| ACI-Bench Command A+ note run | Public benchmark-shaped result | 207/207 rows completed; generated notes beat deterministic extractive baselines on ROUGE but still contain unsupported lexical content |
| Attribution repair diagnostic | Public benchmark-shaped result | Pre-specified compact_extractive retains most ROUGE-L while reducing unsupported-sentence case rate; high lexical support is by construction, not semantic factuality proof |
| BioScope assertion evaluation | Adjacent-domain component result | Sentence-level cue classification on biomedical literature, not clinical notes or BioScope scope-boundary resolution |
| Structured-output baseline | Completed | High schema validity, poor exact-source provenance |
| Candidate-first v4 | Strongest current architecture | 19/20 deterministic-gate pass on fresh rerun; one abstention |
| Extractive rematerialization | Added after audit | Removed unsupported numeric details from model-written summaries |
| Stability testing | Completed on development subset | Passed gates; ambiguous candidate selection is not perfectly repeatable |
| Source-fidelity review packets | Prepared | Human factual review is pending |
| Handoff atoms and safety typing | Added | Repairs atom/category projection failures and exposes typed safety misses |
| Conformal/selective routing | Archived appendix | Uses proxy labels for escalation-policy research, not clinical safety |
The public figure set is reproducible from eval/public_results_summary.json by running python3 scripts/make-results-figure.py after python3 -m pip install -r requirements.txt.
HandoffLens does not claim clinical accuracy, clinical safety, harmful-error reduction, deployment readiness, patient outcome improvement, or generalization to external hospitals.
The evidence supports engineering claims about schema reliability, source provenance, abstention behavior, stability, cost/latency, and review readiness. Clinical claims would require independent factual labels, qualified clinical review, and external validation.
Two measurements would most improve the project without expanding its scope into a product:
- Entailment-backed source support. The current ACI repair metric is lexical: it asks whether output text is recoverable from source tokens. A stronger faithfulness result would run an entailment or factual-consistency scorer, such as MiniCheck, AlignScore, or a clinical NLI model when available, over generated and repaired note claims, then manually review a small disagreement slice.
- In-domain clinical assertion validation. BioScope gives adjacent-domain assertion evidence on biomedical literature. The HandoffLens-specific target-aware item-quote checks still need an in-domain clinical benchmark or private adjudicated clinical gold, such as i2b2/n2c2 when data-use access permits.
scripts/- evaluation, gating, routing, review, and analysis programsprompts/- prompt variants and extraction instructionseval/- public schemas, rubrics, manifests, and synthetic fixturesprofiles/- note-type/domain profiles used by candidate-first extractiondocs/- canonical public write-up, benchmark results, claims, reproducibility, and archived audit trailbenchmark_data/- ignored local mount point for externally downloaded public benchmark filesapp.js,index.html,styles.css- static synthetic demoreview.*- local blinded-review interfaceMODEL_CARD.md- intended use, non-use, and limitations
Portfolio and research demonstration. Not licensed for reuse or redistribution.


