- Monthly visits
- 0
- Pricing
- Not set
- Listed
- —
- Updated
- 2026-10-10
01What is Clef
Clef is Cloudflare's open-source family of decision models. It sets the context, then decides what to do next. Unlike chat models that generate open-ended text, Clef temporarily defines the question in each request and scores each option, allowing code to route or block accordingly without repeatedly retraining for new categories. Within the Clef family, the 27B Clef prioritizes accuracy, while the 9B Clef-flash reaches a median latency of 38.8 ms, making it suitable for embedding in an Agent's hot path.
02Key Features of Clef
Probabilistic decisions: Input state and typed questions, then output the probability of each option so code can directly route, block, or escalate to a human.
Three question types: Supports noul, choice, and score, with up to 64 questions per request.
Visual classification: Includes a built-in vision encoder and can score up to 4 images together with text.
64K context: Accommodates more complete inputs, including long logs, tickets, and JSON state.
Jev API compatibility: The request schema aligns with Jev, so migration generally requires changing only the endpoint and model name.
Non-autoregressive inference: After a single prefill, it scores valid options in parallel instead of generating text token by token, delivering much lower latency than general-purpose LLMs.
Low-latency edge hosting: Powered by the global Workers AI GPU network, Clef has a median latency of 209 ms and Clef-flash only 38.8 ms, making both suitable for hot paths.
03How Clef Works
Follow WeChat and reply “开源” to join the AI open-source project community
Non-autoregressive decision architecture: Clef performs a single prefill-only forward pass over the input, then scores the valid schema options defined in the request in parallel, deriving structured results directly from internal representations.
Two-stage attention routing: Each valid option first extracts context relevant to itself from the prompt. The parameters of each field then cross-attend to one another and reconnect with the original payload for joint modeling. A lexical prior maintains semantic consistency across options, ultimately aggregating the evidence into scores under the schema constraints.
Frozen backbone + lightweight adaptation: The backbone consists of Qwen3.8-27B and Qwen3.5-9B. The main network is frozen, while the routing head and rank-256 LoRA adapters are optimized jointly. This achieves decision-making capability with a very small number of trainable parameters, reducing training and deployment costs.
Calibration-oriented training objective: Post-training uses label-smoothed cross-entropy to keep outputs within the valid schema, supplemented by Brier loss specifically to calibrate probabilities so the output values themselves remain trustworthy.
RLCD reinforcement learning: The in-house Reinforcement Learning for Calibrated Decisions serves as a secondary optimization objective. It assigns partial credit to adjacent ordinal options, full credit to exact matches, and applies a reference penalty to prevent distribution drift, improving accuracy and generalization.
Data strategy: Training data comes from an internally generated dataset. Field order, prompt structure, and schema structure are permuted to improve generalization, making the model less sensitive to question phrasing and able to adapt to new categories defined at request time.
04How to Use Clef
Confirm account and permissions: Register a Cloudflare account, obtain an Account ID and API Token, and enable Workers AI.
Select a model: Choose @cf/cloudflare/clef or @cf/cloudflare/clef-flash as needed.
Build the request body: Specify model, state (text/JSON state), and questions (1–64 noul/choice/score questions, with clear criteria boundaries).
Make the call: Send a REST POST request to /accounts/{id}/ai/run/@cf/cloudflare/clef, or invoke it through the env.AI.run() binding in a Worker.
Parse probability results: Read the option probabilities/weighted scores for each question from response.answers, then use the “highest option + probability threshold” for routing or blocking.
Add images (optional): For visual decisions, embed PNG/JPEG/WebP bytes in the request rather than sending a remote URL.
Load test before launch: Measure latency and accuracy using your own state lengths and question counts, then decide whether to switch fully or route traffic between flash and clef by risk.
Advanced fine-tuning (optional): For specialized domain labels, accumulate data through AI Gateway and use the FDE team's RL fine-tuning service to customize the model.
05Core Advantages of Clef
Fast: Non-autoregressive parallel scoring plus edge GPU hosting gives Clef a median latency of 209 ms and Clef-flash only 38.8 ms, 2.5×–13× faster than Jev and suitable for hot paths.
High accuracy: Ranks first on the Jev Decision Index, achieves the highest score in 7 of the official 10 decision benchmarks, and wins 3 of 4 Typesafe workflow evaluations.
Add categories without retraining: Categories are defined temporarily in the request, so adding labels does not require retraining the model as with traditional classifiers.
Calibrated probabilities: Brier loss + RLCD training makes output probabilities trustworthy, allowing thresholds to be set directly for automated decisions.
Native multimodality: The built-in vision encoder can classify images, while Jev currently supports text only.
Double the context: The 64K context, compared with Jev's 32K, accommodates longer logs and state.
Zero-cost migration: Full Jev API compatibility enables a smooth replacement by changing the endpoint and model name.
06Clef Project Links
Project website: https://blog.cloudflare.com/clef-decision-models/
Hugging Face model repository: https://huggingface.co/Cloudflare/clef
https://huggingface.co/Cloudflare/clef-flash
07Clef Use Cases
Customer support ticket triage: Input ticket content and screenshots, then determine in one request whether the issue is urgent, which team it should be routed to, and its severity score. Low-confidence cases are automatically escalated to a human.
Threat intelligence and phishing prevention: Combine with Browser Run to fetch and render web pages, then perform multi-label classification on domains and pages. Official testing completed the full workflow in only 2.2 seconds.
Bot traffic detection: Use Clef-flash on the gateway hot path to quickly determine whether crawlers are benign or malicious, blocking or allowing them in milliseconds.
Pre-checks for Agent tool calls: Before an Agent performs a high-risk operation, ask Clef “Should it do this, and which tool should it use?” and decide whether to execute or request confirmation based on probability thresholds.
© Disclaimer: domains and linked content may change over time. AIEZZ does not control third-party websites. Review external content and risks independently.


User reviews0