Skip to content

Research notes compiled 2026-10-09 for ticket #27. Labels: [S] sourced, [I] inference, [E] estimate, [NP] not published.

Gating improvised virtual-patient answers before they are spoken

Researched 2026-10-09. Labels: [S] = sourced (ref number given), [I] = my inference, [E] = estimate to be measured, [NP] = not published or page not reachable.

1. What Jev and Clef are

TypeSafe Jev

  • What it is. TypeSafe's first "System One Model". The post calls it "a frontier-intelligence function call": you send unstructured state plus typed questions and get back calibrated, typed decisions. It does not generate free-form text. [S1]
  • Architecture. A new architecture with a parallel sampler, trained with "Reinforcement Learning for Calibrated Decisions" (RLCD). All option probabilities come out of one parallel query. Parameter count [NP]. [S1]
  • Tasks. Classify, route, score, extract and branch. The post also lists verification uses: "scoring, judging, guardrailing", plus jailbreak detection. Up to 255 options per question. [S1]
  • API. Requests carry a state and questions. Question types are choice (choice + probabilities + confidence), score, and noul (a 0–1 probability). Questions are evaluated in parallel, and the docs say adding more "barely changes the response time". Python and JS SDKs exist. Endpoint, limits and rate limits are not on the public index pages [NP]. [S1, S2, S3]
  • Latency. The vendor claims 70–500 ms end to end, measured from West Coast laptops, with no p50/p95 published by TypeSafe [S1]. Cloudflare measured Jev at median 524.1 ms, p95 536.0 ms across 43 benchmarks, with no method details [S5]. A secondary source reports Vercel's CEO saying it was "up to 18x faster (p95)" in a safety-review step [S7, secondary].
  • Pricing. $0.042 per million input tokens, output free. TypeSafe says it cannot prove this pricing is not subsidised. [S1]
  • Context. 32k tokens per Cloudflare [S5]. TypeSafe does not state it [NP].
  • Languages. Not stated anywhere I could find, including Hindi [NP]. Jev is text only [S5].
  • Hosting and licence. Hosted SaaS based on the US West Coast, no named provider, no self-hosting, and no stated licence [S1]. [I] From India this adds a transpacific round trip of roughly 200–300 ms [E] on top of the inference time.
  • Maturity. Early access. The blog's displayed date is 15 Sep 2026, but its metadata says 8 Oct 2026. All benchmarks are self-published [S1]. A secondary review reports about 68% accuracy on TypeSafe's own four workflows [S7].

Cloudflare Clef and Clef-flash

  • What they are. Open-weight decision models released 1 Oct 2026 [S5]. They take a state (text, JSON or images) and 1–64 typed questions (noul, choice, score), and return a probability for every allowed option. The API is Jev-compatible. [S4, S5, S6]
  • Architecture. Clef is 27B: a frozen Qwen3.8-27B backbone with its vision encoder, plus a small "joint schema head" that scores all options of all questions in one forward pass. It has no text generation. Clef-flash is 9B, built on Qwen3.5-9B. Both use rank-256 LoRA adapters. [S5, S6, S8]
  • Invocation. Inside a Worker: env.AI.run("@cf/cloudflare/clef", {state, questions}). Over REST: POST /client/v4/accounts/{id}/ai/run/@cf/cloudflare/clef. Responses contain answers keyed by question id, plus usage. [S4]
  • Latency (vendor, 43 benchmarks, method not described). Clef: median 209.3 ms, p95 238.6 ms. Clef-flash: median 38.8 ms, p95 122.4 ms. [S5, S6, S8, I] These look like model-side times. Network time from India to whichever Cloudflare GPU location serves the request is extra and unpublished.
  • Quality notes. BANKING77 macro-F1: Clef 94.20, Clef-flash 90.93, Jev 79.74. On out-of-scope detection (CLINC150+OOS), Clef-flash scores 66.77 against Clef's 97.43. [S5, I] Out-of-scope detection is close to the "new clinical fact" check we need, so Clef-flash should not be trusted for it without evaluation.
  • Pricing. Clef costs $0.24 per million input tokens and Clef-flash $0.09. Output is not billed. [S4, S9]
  • Context. 65,536 tokens on Workers AI, and long state is truncated [S4, S9]. The Hugging Face encoder defaults to 16,384 tokens [S6].
  • Rate limits. Workers AI LLM-category models get 300 requests per minute, or 20 per minute for paid models on standard billing [S10]. [I] Check which category Clef falls in before planning load.
  • Languages. Not stated on any Clef page [NP]. [I] The Qwen3 family officially covers 119 languages, including Hindi, Bengali, Marathi, Tamil and Telugu [S11]. But Clef's backbone is Qwen3.8 or 3.5, whose language lists I did not verify, and the decision head's training data is undisclosed. Hindi, Hinglish and Devanagari quality is unknown and must be measured.
  • Hosting. Workers AI runs "at the edge", with no region list [S5]. I found no source confirming GPU inference inside India, and Workers AI limits pages do not mention data residency [S10, NP]. The weights are on Hugging Face under Apache-2.0, tested on a single H200 [S6, S8], so self-hosting in an Indian region is possible.
  • Maturity. About one week old. Fine-tuning is a hands-on design-partner programme, and Cloudflare writes "We're still early here" [S5].

2. Comparable low-latency options

Option Size / type Latency Hindi / Devanagari Fit for "no new clinical fact"
Current lexicon + regex Python <1 ms [E] Only as good as the term lists High precision on digits and named terms. Misses paraphrase such as "seene mein bhaari lagta hai".
Clef-flash 9B decision head 38.8 / 122.4 ms p50/p95 [S5] Unknown [NP] Good API shape (noul). Weak on out-of-scope detection [S5].
Clef 27B decision head 209 / 239 ms [S5] Unknown [NP] Best quality claimed. Adds about 0.2 s.
Jev Undisclosed 524 / 536 ms (Cloudflare) [S5] Unknown [NP] US-hosted, slower than Clef. Not recommended.
Llama Guard 4 12B 12B generative safety classifier Not published [NP] Hindi listed [S12] Fixed 14-category harm taxonomy, with no custom categories mentioned [S12]. Wrong task: it flags harm, not clinical-fact invention.
Prompt Guard 2 86M / 22M mDeBERTa classifier 92.4 / 19.3 ms on an A100 [S13] Hindi evaluated (86M only) [S13] Detects injection and jailbreaks. Useful on trainee input, not for this check.
ShieldGemma 2B/9B/27B Yes/No probability from logits Not published [NP] English only [S14] Supports custom policies, but is "highly sensitive" to policy wording [S14]. Not suitable for Hindi.
NeMo Guardrails Orchestration framework Depends on the rail model Depends on the rail model Streaming output rails buffer chunk_size tokens (default 200). stream_first: false withholds text until it passes [S15]. A pattern, not a model.
MuRIL fine-tune BERT-base, Apache-2.0 ~10–20 ms on GPU, tens of ms on CPU [E] 17 Indian languages plus their transliterated forms, including Hindi [S16] Best Hinglish and romanised-Hindi prior. Needs our own labelled data.
IndicBERT v2 278M, MIT Similar to MuRIL [E] 23 Indic languages + English. Romanised text not stated [S17] Same role as MuRIL. Weaker on romanised Hinglish [I].
Gemini Flash-Lite (3.5 / 3.1) with JSON output Small generative LLM No official time to first token found [NP]. A few hundred ms [E] Gemini family supports Hindi [S18] Can generate the sentence and self-label it. It is not an independent check.
Groq-hosted small LLMs Pricing page gave no speeds or regions [NP, S19] Model-dependent Same role as Flash-Lite.

3. Architecture options for the Gemini Live path

What the Live API documents [S18, S20]: - Output transcription exists, but its timing relative to audio chunks is not documented. - On barge-in, generation "is canceled and discarded" and the client must flush queued audio. - send_client_content with turn_complete=true "unconditionally interrupts generation". - 3.8 Live defaults to async (NON_BLOCKING) function calls, with SILENT, WHEN_IDLE and INTERRUPTED scheduling. The legacy 3.1 Live model waited for the tool response before speaking. - There is no documented way to make Live speak verbatim text. - The default end-of-speech silence is about 800 ms, with 500–800 ms recommended.

In contrast, Gemini 3.8 TTS "treats the text field strictly as a verbatim transcript", supports Hindi and streams 24 kHz PCM [S21]. Sarvam Bulbul v3 claims under 250 ms to first audio byte [S22, vendor].

What a violation check must decide (all options)

Input: the candidate sentence, the trainee's question, the case's permitted negatives, and its everyday-detail whitelist. Output: one choice from {permitted_negative, everyday_detail, dont_know, new_clinical_fact}, plus noul sub-questions for: - a new positive symptom or sign - a number (Devanagari ०–९, ASCII digits, or number words in Hindi or English, such as "do din", "teen baar", "100 ke upar") - a medicine or dose (brand, generic or household name, such as "Crocin", "goli", "injection") - a diagnosis or disease label - a test or result ("sugar", "report", "X-ray")

It must also catch implicature: "haan, thoda sa hota hai" (yes, it happens a little) is a positive symptom. A negated permitted term must pass, as in "nahi, khoon nahi aaya" (no, there was no blood). [I] Run the lexicon first because it is deterministic and auditable, and use the classifier only for paraphrase the lexicon misses. The rule should be a block on either signal.

(a) Pre-generate, validate, then speak exactly that text

Flow: router → Flash-Lite writes one short sentence from the bounds → lexicon + classifier → speak. - Added latency [E]: about 300–600 ms for generation, plus 40–240 ms for the classifier, compared with Live answering directly. - Speaking the text: route the turn to TTS (Gemini 3.8 Flash-Lite TTS or Bulbul) instead of Live. Injecting the text into Live and saying "repeat exactly" is undocumented and unverifiable [I]. - Failure modes: the TTS voice differs from the Live voice (this needs a voice-matching test, since I have not verified that voice names are shared [I]); prosody discontinuity; Live's context needs the turn added via send_client_content (model role) so later turns stay coherent [S20]; the extra hop pushes past 1.5 s at the tail. - Strength: it is the only option where nothing unvalidated is ever audible.

(b) Stream-gate Live output and cancel mid-utterance

Flow: buffer audio client-side by D ms → check transcript deltas → on a violation, interrupt with turn_complete=true and flush the buffer. - Added latency: D plus classifier time, applied to every Live turn. With an unknown transcript lag, D must exceed (transcript lag + about 120 ms for the Clef-flash p95). That is likely 300–800 ms [E]. - Failure modes: transcript lags audio, so violating words leak if D is too small. Partial words in Hindi are hard to classify. A cut-off patient sounds broken, so you need a recovery line ("…maaf kijiye, mujhe yaad nahi" — sorry, I don't remember). Interruption semantics may leave the partial turn in history [S20]. This is the NeMo stream_first: true failure, where the client already received tokens [S15]. - Verdict [I]: useful only as a safety net that logs and truncates, not as the primary gate.

(c) Classify the trainee question before generation

Flow: transcript of the trainee's final utterance → choice {authored, permitted_negative, everyday, unknown/out_of_case} → authored and negative answers come from case text (no generation), everyday answers are generated and gated, unknown gets "pata nahi" (I don't know). - Added latency: the Clef-flash p95 of about 120 ms [S5], or about 10–30 ms for a fine-tuned MuRIL [E]. It can run in parallel with the end-of-turn silence window on the streaming input transcript [I]. - Failure modes: a misroute to "everyday" lets generation drift, so you still need the output check; trainee ASR errors in Hinglish; questions with several parts. - Strength: most turns never reach free generation at all.

4. Latency budget (trainee stops speaking → first patient audio)

Stage (c)+(a) via TTS Live direct, post-hoc check (today) Source
End-of-turn detection 500–800 ms 500–800 ms [S18] recommended silenceDurationMs
Final transcript available 0–150 ms [E] n/a (inside Live) not published
Route (Clef-flash / MuRIL) 40–120 / 10–30 ms 0 [S5] / [E]
Answer text authored: ~0. Everyday: 300–600 ms [E] inside Live [NP] Flash-Lite TTFT
Validate (lexicon + Clef-flash) 40–125 ms after speaking [S5]
TTS first audio ~190–250 ms (Bulbul, vendor). Gemini TTS [NP] Live first audio [NP] [S22]
Network India↔edge, several hops 50–150 ms [E] 50–150 ms [E] not published
Total, authored / negative turn ~0.8–1.4 s [E] ~0.8–1.3 s [E]
Total, generated everyday turn ~1.2–2.0 s [E]

Human conversational gaps cluster tightly around a cross-language mean [S23] (the often-quoted "~200 ms" is a secondary gloss and I could not verify it in the abstract). [I] So 1–1.5 s is already "slow but acceptable" for a hesitant patient. A filler such as "hmm…" played immediately from a cached clip can mask the everyday path.

5. Recommendation

  1. Do (c) first. Classify the trainee question and answer authored and permitted-negative turns from case text. This removes most generation risk at the lowest latency. Use the existing lexicon plus a small router.
  2. For the remaining "everyday" turns, do (a) via TTS, not Live. Generate one short sentence with Flash-Lite from a whitelist-constrained prompt, run the lexicon gate first, then a noul/choice classifier, then send it to TTS. On any doubt, fall back to a pre-recorded "pata nahi / yaad nahi" (I don't know / I don't remember).
  3. Classifier choice:
  4. Prototype on Clef via Workers AI. It has the right API shape, the best published out-of-scope score, about 210 ms, and an Apache licence, so you are not locked in.
  5. In parallel, fine-tune MuRIL as the long-term gate, because it is the only option with documented transliterated-Hindi coverage, runs in tens of ms, and can live in our own India region.
  6. Do not use Jev (US-only, slowest, unknown languages), ShieldGemma (English only), or Llama Guard (wrong taxonomy).
  7. Use Clef-flash only if it passes the out-of-scope evaluation.
  8. Keep (b) as telemetry. Continue validating Live transcripts after the fact for any turns that still go through Live, and alert on violations. Add mid-utterance cancel only after measuring transcript lag.

6. Evaluation plan

  • Dataset. At least 1,500 labelled candidate answers across the existing cases, split evenly between Devanagari Hindi, romanised Hinglish and code-mixed text, plus at least 200 each in Bengali and Tamil.
  • Labels: the 4-way choice above plus the five noul flags.
  • Include adversarial negatives: negated permitted terms, implicature ("thoda sa"), number words, household drug names, and "sugar/BP" as tests.
  • Have two clinician annotators label it, and report Cohen's κ.
  • Targets [I].
  • Recall ≥ 0.99 on new_clinical_fact (safety-critical). At most 1 leak per 1,000 improvised turns in a shadow run.
  • Precision ≥ 0.90, so the patient doesn't say "pata nahi" too often.
  • Router accuracy ≥ 0.95 on authored versus not.
  • Report recall per language. Any language below target falls back to deterministic "pata nahi".
  • Latency SLOs [I]. Gate p95 ≤ 150 ms, measured from an Indian region. End-of-turn → first audio: p50 ≤ 1.2 s and p95 ≤ 1.8 s for authored turns; p95 ≤ 2.0 s for generated turns. Measure each stage with the existing stage-latency instrumentation.
  • Procedure. Run an offline evaluation of lexicon alone, lexicon + Clef, lexicon + Clef-flash and lexicon + MuRIL. Then run a 2-week shadow mode logging gate decisions on real Live transcripts. Switch only after that.

References

  • S1. TypeSafe, "Introducing System One Models and Jev": https://typesafe.ai/blog/introducing-system-one-models-and-jev (date shown 15 Sep 2026; metadata 8 Oct 2026)
  • S2. TypeSafe docs: https://docs.typesafe.ai
  • S3. TypeSafe docs index: https://docs.typesafe.ai/llms.txt (the models page https://docs.typesafe.ai/reference/models returned 404; OpenRouter's jev-1.13 page also returned 404)
  • S4. Cloudflare Workers AI, Clef: https://developers.cloudflare.com/workers-ai/models/clef/
  • S5. Cloudflare blog, Clef decision models (1 Oct 2026): https://blog.cloudflare.com/clef-decision-models
  • S6. Hugging Face, Cloudflare/clef: https://huggingface.co/Cloudflare/clef
  • S7. Secondary review of Jev (unverified): https://andrew.ooo/answers/what-is-typesafe-jev-system-one-model-september-2026/
  • S8. Hugging Face, Cloudflare/clef-flash: https://huggingface.co/Cloudflare/clef-flash
  • S9. Workers AI, clef-flash: https://developers.cloudflare.com/workers-ai/models/clef-flash/
  • S10. Workers AI limits: https://developers.cloudflare.com/workers-ai/platform/limits/
  • S11. Qwen3 blog (29 Apr 2025), 119 languages: https://qwenlm.github.io/blog/qwen3/
  • S12. Llama Guard 4: https://huggingface.co/meta-llama/Llama-Guard-4-12B
  • S13. Prompt Guard 2 86M: https://huggingface.co/meta-llama/Llama-Prompt-Guard-2-86M
  • S14. ShieldGemma: https://huggingface.co/google/shieldgemma-2b
  • S15. NeMo Guardrails output rail streaming: https://docs.nvidia.com/nemo/guardrails/latest/configure-guardrails/yaml-schema/streaming/output-rail-streaming
  • S16. MuRIL: https://huggingface.co/google/muril-base-cased
  • S17. IndicBERT v2: https://huggingface.co/ai4bharat/IndicBERTv2-MLM-only
  • S18. Gemini Live guide: https://ai.google.dev/gemini-api/docs/live-guide and models list: https://ai.google.dev/gemini-api/docs/models
  • S19. Groq pricing (no speeds or regions visible): https://groq.com/pricing
  • S20. Gemini Live capabilities: https://ai.google.dev/gemini-api/docs/live-api/capabilities
  • S21. Gemini speech generation: https://ai.google.dev/gemini-api/docs/speech-generation
  • S22. Sarvam TTS (vendor claim): https://www.sarvam.ai/try/tts-api ; https://docs.sarvam.ai/api-reference-docs/text-to-speech/api/overview
  • S23. Stivers et al. 2009, PNAS 106(26):10587, doi:10.1073/pnas.0903616106: https://pub.uni-bielefeld.de/record/1591790