
Clef / Clef-flash decision models (Cloudflare)
Cloudflare announces Clef and Clef-flash, open-weight "decision models" (Apache 2.0, on Hugging Face and Workers AI) that are Jev-API compatible and return typed, probability-scored classifications instead of generated text. The models are built by post-training a frozen Qwen backbone (Qwen3.8-27B for Clef, a smaller Qwen3.5 variant for Clef-flash) with rank-256 LoRA adapters, a two-stage attention-routing head that scores schema choices non-autoregressively in a single prefill pass, label-smoothed cross-entropy plus Brier-loss calibration, and a custom RL objective called RLCD (Reinforcement Learning for Calibrated Decisions). Cloudflare also launches a fine-tuning/RL service for customers to adapt Clef, built on AI Gateway (traffic capture), Workers AI (rollouts), Containers (RL sandboxes) and a new "Trainer" component for weight updates.
What it claims
Cloudflare released two open-weight decision models under Apache 2.0, available on Hugging Face and hosted on Workers AI:
- Clef is built on a frozen Qwen3.8-27B. Cloudflare positions it as the precision model.
- Clef-flash is built on a frozen Qwen3.5-9B. It is meant for latency-critical calls.
Both are API-compatible with Typesafe AI's Jev, so switching from Jev should be a drop-in change. Cloudflare says Clef leads the Jev Decision Index. It names two capabilities Jev lacks:
- a vision encoder, so Clef can classify images (Jev is text-only);
- a 64k context window, against Jev's 32k.
On Typesafe's own eval suite, Clef beat Jev in 3 of 4 areas. Across 43 eval benchmarks, the Clef models beat other decision models on latency. The one exception is Laya, which is faster but scores lower on quality.
How it works
- Inference. Qwen does a single prefill-only pass. All valid schema choices are then scored in parallel straight from the backbone's internal representations, with no text generated. The scoring uses a two-stage attention routing step: 1. Each option pulls the evidence relevant to it from the prompt. 2. The fields cross-attend to each other and back to the original payload.
The page says a "lexical prior" preserves the meaning of each option, but does not explain how.
- Supervised post-training. Only the routing head and rank-256 LoRA adapters are trained. The losses are label-smoothed cross-entropy over valid schema outputs, plus a Brier loss to calibrate the probabilities. The training data is Cloudflare's internal synthetic sets, which permute field orders, prompts and schema structures.
- RLCD, used as a secondary objective:
- gives partial credit for an adjacent ordinal choice;
- rewards records where every field is correct;
- applies a reference penalty to prevent distribution shift.
- Lineage. Clef grew out of an earlier Cloudflare experiment that read logprobs from DiffusionGemma, building on work by Matt Mastracci.
Evidence
- Internal threat-intelligence test (domain classification, with Browser Run). Clef took 2.2s to fetch, render and classify a site, and returned multi-label probabilities (for example, 95% fashion, 85% ecommerce, <1% phishing). The same workflow on gpt-oss-120b, Cloudflare's fastest general LLM, took 4.7s and returned only two classifications.
- Benchmark tables. The page refers to tables and a live demo site, but the scores were not in the fetched text.
How to use it
Model ID: @cf/cloudflare/clef. The page does not give the Clef-flash ID. The call below is from the page; the line continuations are shown as single backslashes:
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/cloudflare/clef \
-X POST \
-H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
-d '{
"model": "clef",
"state": "Checkout has been failing for every customer for the last hour.",
"questions": {
"urgent": { "type": "noul", "instructions": "Is this support request urgent?" },
"team": {
"type": "choice",
"instructions": "Which team should handle this request?",
"criteria": {
"billing": "Payments, invoices, and refunds",
"technical": "Outages, errors, and configuration",
"sales": "Plans and upgrades"
}
},
"severity": {
"type": "score",
"instructions": "How severe is the customer impact?",
"criteria": ["No impact", "Minor", "Major", "Critical"]
}
}
}'The request takes free-text state plus named questions. The example shows three question types:
noul, apparently a yes/no question;choice, with a map of labels to descriptions;score, with an ordered list of labels.
Each answer comes back typed, with probabilities.
Data handling. Cloudflare states it does not read, store or train on hosted requests or responses, unless you opt into fine-tuning.
Fine-tuning. For now this is available only as a hands-on engagement with Cloudflare's forward-deployed engineering team. A self-serve platform is planned. The pipeline loops back on itself:
flowchart LR T[Your traffic] --> G[AI Gateway: capture dataset] G --> R[Workers AI: rollouts on Clef] R --> S[Containers: score/replay sandbox] S --> TR[Trainer: weight update] TR --> D[Workers AI BYO Model: redeploy] D --> T
Limits
- Self-serve RL is not available yet. Several of its components (AI Gateway capture, Containers as RL sandboxes, BYO Model/Cog) are described as work in progress.
- Benchmarks are vendor-run. The quality numbers are not in the fetched text, so verify them on the demo site. The latency comparison is a single internal workflow, measured against a general-purpose LLM rather than another decision model.
- Fine-tuning has a cost. The page notes that a fine-tuned model may lose some general-purpose performance in exchange for accuracy in its domain.
- Gaps in the page. It gives no training data size, compute figures or Clef-flash endpoint name.
Organisations named here
- Cloudflare
- TypeSafe AI
- Hugging Face
- Jev
- Jev Decision Index
- Matt Mastracci
- vLLM
Technologies named here
- Workers AI
- Clef
- Hugging Face
- Clef-flash
- Cloudflare AI Gateway
- Jev System One
- Cloudflare Containers
- Laya
- gpt-oss-120b
- Trainer
- DiffusionGemma
- Workers AI Bring Your Own Model
- Qwen3.8-27B
- vLLM
- Qwen3.5-9B
- Browser Rendering
- Qwen3.5
- LoRA
- Cloudflare
Techniques named here
- Decision model classification
- Prefill-only, non-autoregressive scoring
- Two-stage attention routing
- Low-rank adapter fine-tuning
- Label-smoothed cross-entropy with Brier loss
- RLCD
- Exposing logprobs for deterministic probabilities
Related in models


