Model Evaluation Lab
The Model Evaluation Lab is the system SanaMente uses to decide which AI models and prompts reach a clinical record. It began in August 2026 as a standalone web app for benchmarking speech-to-text on a Spanish therapy session, and grew into two connected tools: a transcription lab in Python and Streamlit, and a clinical-note harness in TypeScript inside the SanaMente codebase. The question behind all of it: can a cheaper model or prompt do this job without losing clinical quality?
At a glance
- Role
- Product & Solo Build (AI-Assisted)
- Timeline
- Aug 2026 – present
- Team
- Solo
- Status
- In use for every SanaMente model and prompt decision
- What I owned
- Everything: problem framing, test design, both tools, and the write-ups
- Results
-
- 5 speech-to-text providers wired; 86 models tracked
- Transcription scored against a 3,002-word human Spanish transcript
- 70 synthetic trap cases (30 held out) and a five-condition ship gate
- Showed the Pro plan's margin falls from 28% to negative when sessions move online
At a design-partner clinic's volume, the Pro plan's margin falls from 28% to negative when sessions move online. Model choice decides whether the product makes money.
/ The Challenge
AI is most of SanaMente's variable cost: every 50-minute session is transcribed and then turned into a note. The usual way to choose a model is vendor marketing and a few spot checks, which isn't good enough for a signed clinical record: a note that invents a plan, inverts a denial or drops a question about suicide that went unanswered is a patient-safety and NOM-004 problem, not a quality blip. The constraints: no real patient data, single-digit dollars per study, write-ups a non-engineer founder can decide from, and reproducibility.
/ Approach
- 01
One schema for every stage. Five speech-to-text providers are wired (OpenAI, AssemblyAI, Deepgram, Google Cloud and Azure), and the lab tracks 86 models, with only the recommended subset running by default.
- 02
Score against a human, and price it exactly. Transcription is scored with WER and CER against a 3,002-word human Spanish transcript. Unverified rates are flagged in the UI, and an estimate is shown before anything is spent.
- 03
For notes, write the traps first. The note harness runs 70 synthetic es-MX sessions with fictional people, each built around deliberate traps. Each case carries three kinds of check, all run in code: sections that must stay empty, content that must not appear (invented, inverted or injected), and facts that must appear.
- 04
A ship gate, not a leaderboard. A candidate replaces production only if, run in the same invocation as production (same cases, same repeats, same day), it meets all five conditions. Cost and latency decide only among candidates that pass.
- 05
Every study becomes a case study. Each study that informs a decision gets a dated write-up with a fixed structure. They report what lost as plainly as what won.
The trap list, ship-gate conditions and lab mechanics are in the Technical deep dive below.
/ In the App
/ The Studies
| # | Study (Nov 2026) | Question | Result | Decision |
|---|---|---|---|---|
| 1 | Cheaper note prompt | Can a shorter prompt keep the source-only prompt's safety? | Three variants: none invented anything, and none passed the gate. The lean prompt F cost 22% less, ran faster (3.4 s instead of about 5 s) and was twice as consistent between runs, but left out 19 serious facts against production's 15 | Production unchanged; F became the candidate |
Total API spend for the five note studies: about US$26.
/ Outcomes
-
Production decisions made from evidence — the source-only prompt stays in production, the lean prompt went to staging only, the unanswered-questions mechanism is on in staging, and the transcription engine choice was explained, not overturned.
-
Six documented studies — one on transcription and five on notes, each with a decision and a revenue and margin section, all readable from the admin portal.
-
70 synthetic clinical cases — 30 of them held out, plus 10 role-play scripts for testing on real audio.
-
A five-condition ship gate — written down before the results, including a blind human read.
-
Low cost — US$0.49 for the full transcription benchmark, and about US$26 across five note studies.
-
No real patient data has entered any evaluation.
Technical deep dive Architecture, implementation details, and the problems along the way ~6 min read
~6 min read
/ Approach, in detail
One schema for every stage. In the transcription lab, every stage emits the same Record, so the cost, metrics and reporting layers never care which stage or vendor produced a row. Adding a provider takes one adapter file and one row in the pricing table.
Score against a human, and price it exactly. The lab also measures self-consistency (each chunk is transcribed twice) and disagreement between models, which puts the most contested chunks first in line for a human to check. Every cost is calculated from the usage the provider returns, multiplied by a pricing table checked against each vendor's published rates.
For notes, write the traps first. The note harness runs 70 synthetic es-MX sessions with fictional people, each built around deliberate traps:
- negations and hedging;
- questions the patient dodged;
- injected instructions spoken by the "patient";
- swapped or unknown speakers;
- medications, diagnoses and risk;
- sessions where no plan was agreed and a section has to stay blank.
Thirty of the 70 cases are held-out sets, each written and committed before the change it tests, and each set is spent once its failures have been read.
A ship gate, not a leaderboard. A candidate replaces production only if, run in the same invocation as production (same cases, same repeats, same day), it meets all five conditions:
- Zero serious forbidden content, across every repeat.
- No more wrongly filled sections than production.
- Required facts within 1 point of production.
- No more than one extra serious omission.
- A side-by-side human read of 10 notes.
Cost and latency decide only among candidates that pass. A cheaper prompt that fails the gate isn't a candidate at any price.
Every study becomes a case study. Each study that informs a decision gets a dated write-up with a fixed structure:
- background, hypothesis, method and threats to validity;
- results, with concrete failures;
- the decision and next steps;
- its impact on revenue and margin, at 0, 50 and 100% online sessions, for both plans.
The write-ups are published in the admin portal next to the methodology. They report what lost as plainly as what won.
/ The Studies
| # | Study (Nov 2026) | Question | Result | Decision |
|---|---|---|---|---|
| 0 | Transcription engines (Aug) | Which speech-to-text engine is most accurate on Spanish therapy audio? | gpt-4o-mini-transcribe led (WER 0.101), ahead of gpt-4o-transcribe (0.111), AssemblyAI Universal-3 Pro (0.126), Whisper (0.149) and Deepgram Nova-3 (0.490, which under-transcribed by about 40%) | Production kept AssemblyAI: the lab removes speaker labels before scoring, and the note needs therapist and patient labels. Speaker accuracy now gets its own test on role-play recordings |
| 2 | Fixing F's misses (F3) | Do prompt rules aimed at F's misses fix them? | No. F3 still missed the facts it targeted and did worse on held-out cases (18 serious omissions against 15). F alone tied production on serious omissions | F3 dropped |
| 3 | Side-by-side read | Do F's differences matter clinically? | F's extra filled sections were cosmetic (true facts in the wrong section). Omissions ran both ways. One critical gap (an unanswered self-harm question) appeared in both prompts | F went to staging only; production is decided on role-play recordings |
| 4 | Dodged questions | Can a mechanism catch unanswered risk questions where prompt rules failed? | A second small call (gpt-4o-mini) only labels which clinical questions went unanswered, and code writes the sentence. On new held-out cases, serious omissions fell from 32 to 12 with production's prompt and from 33 to 14 with lean. Nothing was invented. Extra cost: US$0.0024 a note | Kept behind a flag; two wording problems found |
| 5 | Neutral wording | Fix the wording without losing the gain | The sentence now quotes the question and gives no topic label. Short follow-up questions now count. On a third held-out set, omissions fell from 36 to 22 (production) and from 34 to 15 (lean), and no code-written sentence was wrong. Production's prompt with this addition passes the gate on both sets | On in staging for the role-play transcripts |
/ Selected Technical Challenges
A judge that was too expensive, then no judge at all. The first version graded outputs with a Claude rubric judge, checked against human scores. With extended thinking on, the judge was the most expensive part of a run; turning thinking off cut that cost with no loss in grading. For clinical notes, though, a model judging a model wasn't good enough evidence. The note harness grades with checks written in code, fixed before the run (regex patterns matched without accents or case, plus required-blank sections), followed by a human read. When a check wrongly rejects correct wording, it's fixed and the saved notes are re-scored with no new API calls, and the case study names every check that changed.
Mechanisms beat instructions. Adding prompt rules ("record explicit denials", "say when a question went unanswered") never closed the gaps, in production's prompt or the lean one. What worked was a mechanism that doesn't rely on the model following instructions: every sentence cites a verbatim quote or a line number, and code drops any sentence whose citation isn't really in the transcript; unanswered questions are classified by a small model and written by code from fixed wording. The harness imports production's prompt code directly, so the arm being tested is exactly what ships, and a variant whose edit anchor has disappeared throws an error rather than comparing against a prompt nobody runs.
Honest numbers on a small budget. Each arm runs two or three times, and the report shows the spread and counts the cases that change between repeats; when two arms fall within that spread, it calls it noise rather than naming a winner. Prices are checked against each vendor's published rate and dated, and a pricing table run from memory is treated as a bug. A slow metric (TER on a whole document, roughly quadratic, which could stall a re-scoring for nearly an hour) became opt-in. Every result is re-priced at 0, 50 and 100% online sessions before it's called a win.
Offline-first, then secure. Committed runs render with no API keys and no spend; the metric and cost layers read cached runs exactly the way they read live ones. For a hosted version, the lab runs in a container on Render, because Streamlit needs a persistent WebSocket server and a full run takes 20–30 minutes with ffmpeg. It opens only with a 10-minute HMAC-signed pass that SanaMente gives to its evaluation admins, and every finished run is posted to SanaMente's admin API and appears in the admin portal.
A new vendor is a data processor. Synthetic cases can go to any vendor. Role-played recordings, made by real people, can't go to a new vendor until four things are in place: zero data retention and no training on SanaMente's data, in writing; a data-processing agreement reviewed by the attorney; the processing region recorded; and the privacy notice updated. That's why the cheaper speech vendor with built-in speaker labels is still waiting on legal review rather than shipping on the strength of its benchmark.
/ What Changed From the First Version
The August 2026 version was a dual-mode app that also ran a Spanish-to-English translation study: cascaded speech-to-text then translation, against a direct audio-to-English lane, scored with BLEU, chrF++ and TER and a Claude rubric judge. Claude Sonnet (literal) led translation at BLEU 42.7 and chrF++ 72.2, and the direct audio lane came within about 1 BLEU of the best cascade. That full reference run cost US$2.67, of which US$0.49 was transcription.
On 17 November 2026 the translation study was removed, and the lab became SanaMente's evaluation engine. The removed code and results remain in the repository's history. The clinical-note stage the first version listed as "next" was built in the SanaMente codebase instead, where it can import the production prompt directly.