In-Depth Review of Clef – Cloudflare's Open-Source Decision Model Family

Executive Summary:
Clef is a family of decision models open-sourced by Cloudflare. Its core purpose is not to generate open-ended text, but to temporarily define problems within requests and output probabilistic scores ...
1. What is Clef
Clef is a family of decision models open-sourced by Cloudflare. Its core purpose is not to generate open-ended text, but to temporarily define problems within requests and output probabilistic scores for each candidate option, allowing code to perform subsequent actions such as routing, interception, or escalation to human agents based on these scores. Unlike traditional classifiers that require retraining for each new category, Clef enables dynamic category definition during inference, significantly enhancing the flexibility and iteration efficiency of decision systems. This family includes two variants: Clef, the 27B-parameter version, focuses on accuracy and ranks first on the Jev Decision Index benchmark; Clef-flash, the 9B-parameter variant, emphasizes speed with a median latency of just 38.8 milliseconds, making it suitable for embedding in Agent hot paths. Overall, Clef provides an efficient decision infrastructure that sits between general-purpose language models and specialized classifiers.

Technical positioning and domain: Clef belongs to the emerging AI subfield known as decision models, which lies between traditional large text generation models and specialized classifiers. Its primary application areas include pre-screening of tool calls in Agents, triaging customer service tickets, determining Bot traffic, and classifying threat intelligence—scenarios that require fast, structured, and probabilistic outputs. Clef is not the first in this category; Typesafe AI's Jev was the pioneer in defining the "decision model" product form. However, Clef has established a differentiated advantage in this niche with lower latency, a larger context window, and built-in visual capabilities.
Development background: Clef was developed by Cloudflare's internal team and is hosted and inferred using Cloudflare Workers AI's global edge GPU network. As a leading global CDN and edge computing service provider, Cloudflare has long focused on the network infrastructure layer. Its investment in decision models stems from its own business needs: determining traffic types with extremely low latency on gateway hot paths and quickly classifying threats in security scenarios. Unlike startups such as Jev, Cloudflare has open-sourced Clef and deeply integrated it into its ecosystem, reflecting its technical strategy of "using infrastructure capabilities to support AI applications."
Core value: Clef addresses three major pain points of traditional LLMs in structured decision tasks: high latency, high cost, and unreliable probability outputs. General-purpose large models generate text token by token, resulting in slow inference speeds and unstable output formats. Traditional classifiers, on the other hand, cannot dynamically add categories during runtime, requiring retraining and redeployment for each new label. Clef employs a non-autoregressive architecture, prefilling the input once and then scoring all valid options in parallel, bypassing token-by-token generation to compress decision latency into the millisecond range. It also uses Brier loss and RLCD reinforcement learning to calibrate output probabilities, making the probability values themselves a reliable basis for automated decision-making.
Technical features: Clef uses a training strategy that freezes the base model and adds lightweight adaptation layers, with Qwen3.8-27B and Qwen3.5-9B as its backbone. Only the routing head and a rank-256 LoRA adapter are jointly optimized, achieving decision-making capabilities with minimal parameter count. A two-stage attention routing mechanism allows each valid option to extract relevant context from the prompt and connect back to the original payload via cross-attention for joint modeling. The entire family supports a 64K context window, includes a built-in vision encoder capable of embedding up to four images, and is fully compatible with Jev's API, resulting in near-zero migration costs.
2. Key Features
Probabilistic Decision Output: Given a state (text/JSON state) and a typed question, the model outputs a probability distribution for each option. Code can directly use these probability values for routing, interception, or escalation to human agents. Unlike traditional classifiers that output a single label, Clef provides a complete probability vector, enabling upper-layer systems to set confidence thresholds for fine-grained risk control.
Three Question Types: Supports three question formats: noul (binary judgment), choice (multi-class classification), and score (scoring/ranking). A single request can include up to 64 questions. This design allows Clef to perform multiple decision tasks in parallel within a single request, such as simultaneously determining the urgency of a ticket, the responsible team, and severity score, reducing latency overhead from multiple calls.
Visual Classification Capability: Built-in vision encoder allows up to 4 images to be input alongside text for joint scoring. This capability enables Clef to handle multimodal decision-making scenarios such as screenshots, scanned documents, and web renderings. In contrast, its main competitor Jev currently only supports text input, making this a significant functional differentiator for Clef.
64K Context Window: Supports context input of up to 64K tokens, capable of accommodating full logs, historical tickets, JSON state snapshots, and other long texts. Compared to Jev's 32K context window, Clef's doubled capacity allows the model to see more complete decision-making evidence, which helps improve accuracy in complex scenarios.
Jev API Compatibility: The request schema is fully aligned with Jev. When migrating from Jev to Clef, users only need to modify the endpoint and model name; existing code logic remains unchanged. This compatibility strategy significantly reduces the switching cost for users, especially for teams already using Jev in production environments.
Non-autoregressive Inference Mechanism: This is Clef's most technically distinctive feature. After performing a single prefill-only forward computation on the input, the model directly scores all valid options in parallel, rather than generating text token by token. This mechanism reduces decision latency from seconds in general-purpose LLMs to tens of milliseconds, while also avoiding output format drift caused by open-ended generation.
Edge-Hosted Low Latency: Clef runs on the global GPU network of Workers AI, achieving a median latency of 209 milliseconds and a P95 latency of 238.6 milliseconds. Clef-flash further reduces the median latency to just 38.8 milliseconds and the P95 latency to 122.4 milliseconds. The distributed edge nodes enable the model to respond to requests locally, making it suitable for embedding in the hot path of latency-sensitive agents.
3. How to Use
Register an Account and Obtain Credentials: Register for a Cloudflare account, obtain your Account ID and API Token from the console, and confirm that you have enabled the Workers AI service. The API Token must have the necessary permissions for Workers AI. It is recommended to use a dedicated Token with the minimum required scope.
Select Model Specifications: Choose a model version based on your business requirements. For scenarios requiring high accuracy and with higher latency tolerance (e.g., deep triage of service tickets), use
@cf/cloudflare/clef. For scenarios extremely sensitive to latency (e.g., real-time Bot traffic detection), use@cf/cloudflare/clef-flash. Both models share the same API schema, making the switch very low-cost.Construct the Request Body: The request body must include three core fields:
modelspecifies the model name;statecarries the input content to be evaluated (can be plain text or structured JSON state);questionsdefines 1 to 64 decision questions, with each question requiring a clear type (noul/choice/score), a list of options, and a description of the criteria boundaries. The clearer the criteria are written, the more accurate the model's judgment will be.Initiate API Call: In your code, make a POST request via REST to the endpoint
/accounts/{account_id}/ai/run/@cf/cloudflare/clef, or use theenv.AI.run()method within a Cloudflare Worker to bind the call. If using the official SDK, pass in the constructed request body object as described above.Parse Probability Results: The
response.answersfield in the response body contains the probability of each option or weighted scores. In actual business logic, use a strategy of "highest probability option + confidence threshold" for routing or interception decisions. For example, set 0.7 as the threshold for automatic handling, and automatically escalate requests below that value to human agents.Integrate Image Input (Optional): When visual judgment is required, embed binary data of images in PNG, JPEG, or WebP formats directly into the request body. Avoid passing remote URLs. Up to 4 images can be used in conjunction with text input.
Pre-Launch Stress Testing: Before switching traffic, perform real-world latency and accuracy testing using
stateand question counts that match the production environment. It is recommended to initially switch traffic in a proportionate manner for gray-scale deployment, and then decide whether to fully switch to clef, clef-flash, or route traffic between them based on risk levels according to the test results.Advanced Fine-Tuning (Optional): If your business domain labels are particularly specialized, you can accumulate production data through the AI Gateway and then submit it to Cloudflare's FDE team for custom decision model fine-tuning using their RL fine-tuning service. This path is suitable for teams with extremely high accuracy requirements and sufficient data accumulation.
Notes: The number of questions and the length of the context directly impact latency and cost. It is recommended to reduce the number of questions to the minimal necessary set. Criteria descriptions should avoid vague expressions and use specific, verifiable judgment standards. The selection of probability thresholds should be based on precision-recall curves from a validation set, not arbitrary decisions.
4. Pros and Cons Analysis
| Pros |
|---|
| Extremely low inference latency: The non-autoregressive parallel scoring architecture bypasses token-by-token generation. Clef-flash median latency is only 38.8ms, 2 to 3 orders of magnitude lower than general-purpose LLMs, making it embeddable into online request hot paths. |
| Dynamic categories without retraining: Categories are temporarily defined during requests, and adding new classification labels does not require retraining the model, significantly shortening the business iteration cycle and reducing operational costs. |
| Probabilistic outputs are calibratable: Through joint optimization using Brier loss and RLCD reinforcement learning, the output probabilities themselves are credible and can be directly used as confidence metrics for automated decision-making. |
| Full Jev API compatibility: During migration, only the endpoint and model name need to be changed, and existing code logic does not require rewriting, resulting in nearly zero switching cost. |
| Native multimodal support: Built-in vision encoder supports joint decision-making with up to 4 images and text, whereas the current competitor Jev only supports plain text. |
| 64K context window: Doubles the 32K context window of Jev, allowing for longer logs and more complete business states, resulting in more comprehensive decision-making basis. |
5. Comparative Analysis with Similar Tools
| Dimension | Clef / Clef-flash (Cloudflare) | Jev (Typesafe AI) | Traditional Classification Models (e.g., BERT fine-tuning) |
|---|---|---|---|
| Core Architecture | Non-autoregressive decision architecture, parallel scoring after prefill | Decision model, pioneer in the category | Autoregressive or Transformer encoder with classification head |
| Context Window | 64K | 32K | Typically 512–4K |
| Visual Input | Supported, with built-in vision encoder, up to 4 images | Not supported, only text | Depends on the model, most do not support |
| Median Latency | 209.3ms (clef) / 38.8ms (clef-flash) | 524.1ms | 10–50ms |
| Dynamic Categories | Supported, temporarily defined within requests | Supported, similar mechanism | Not supported, requires retraining |
| Probability Calibration | Joint calibration using Brier loss + RLCD | Calibration mechanism present | Usually softmax probabilities, no specific calibration |
| Jev API Compatibility | Fully compatible | Native interface | Not compatible |
| Open Source License | Model weights open-sourced (HuggingFace) | Primarily commercial API | Mostly open-sourced |
| Deployment Method | Workers AI edge hosting | Typesafe hosting | Self-hosted on GPU/CPU |
| Jev Decision Index | First | Baseline reference | Not evaluated |
Selection Recommendations: For teams already using Jev in production environments, Clef is a high-priority replacement option—full API compatibility means extremely low migration costs, while also offering double the context window, visual input capabilities, and latency improvements ranging from 2.5× to 13×. This makes Clef-flash particularly competitive in latency-sensitive edge decision scenarios (e.g., gateway traffic classification, Bot detection), with a median latency of 38.8 milliseconds.
For teams not yet using decision models, the choice depends on business constraints. If private deployment and full model control are priorities, traditional fine-tuned classification models still offer advantages in latency, but the lack of dynamic categories means retraining is required for every business change. If decision flexibility and probability reliability are more important, and platform binding to Cloudflare is acceptable, Clef provides a more modern decision infrastructure. While general-purpose LLMs have the strongest generalization capabilities, they suffer from structural disadvantages in structured decision tasks, including high latency, high cost, and unstable outputs. As such, they are better suited for reasoning support before decisions, rather than as the primary decision-making component for high-frequency tasks.
6. Editor's Summary
Clef demonstrates a clear sense of direction in terms of technological innovation. The non-autoregressive decision-making architecture is not a new concept, but Clef has engineered it to a production-ready level—achieving millisecond-level structured decision outputs with model sizes of 27B and 9B. This outcome is the result of a series of design choices, including two-stage attention routing, frozen base models with LoRA adaptation, Brier loss, and RLCD reinforcement learning. Among these, the two-stage attention routing enables each valid option to first extract relevant context before mutually attending to one another, a mechanism whose effectiveness in structured decision-making tasks is worth noting. Reducing decision latency to 38.8 milliseconds while maintaining probabilistic calibration indicates that Cloudflare has made targeted investments in model architecture design and training objective setting, rather than simply reusing general-purpose LLMs. However, Clef still lacks sufficient disclosure on technical details such as data synthesis and the specific implementation of RLCD, and independent reproduction and verification by the academic community will require more information.
In terms of practical value, Clef fills the gap between general-purpose LLMs and specialized classifiers. For Agent-based applications, scenarios such as pre-screening of tool calls, triage of support tickets, and Bot detection naturally require "fast, structured, and probabilistic" decision-making capabilities, rather than open-ended text generation. Clef encapsulates this ability into a standardized API compatible with Jev, leveraging Cloudflare's global edge nodes via Workers AI to achieve low-latency inference. Empirical testing of a full threat intelligence classification chain taking just 2.2 seconds demonstrates its engineering maturity. Particularly commendable is the Jev API compatibility strategy, which positions Clef not only as a new model but also as a low-migration-cost infrastructure upgrade option.
In terms of target users, Clef is primarily aimed at three categories of developers: first, teams already using Jev but constrained by latency or context length, who can smoothly migrate; second, backend engineers building Agent-based applications who require millisecond-level structured decision capabilities; and third, developers within the Cloudflare ecosystem who can integrate Clef with Workers AI to achieve full-stack integration from model inference to business logic. For teams seeking private deployment or deeper customization of the probabilistic calibration mechanism, Clef currently offers limited options.
Looking ahead, the most noteworthy evolution paths for Clef include: increased transparency in training techniques (which will help foster a thriving community ecosystem), expansion of the inference environment beyond Workers AI to more platforms, and the progression of visual capabilities from "image scoring" to more complex multimodal reasoning. As a standalone category, decision models are rapidly taking shape, and Clef has secured a relatively advantageous position in this space through its open-source strategy and performance data. Subsequent versions of Clef are definitely worth keeping an eye on.
7. Application Scenarios
Intelligent Ticket Triage for Customer Support: Input the ticket text content and user screenshots, and complete multiple decision-making tasks in a single request: whether it's urgent, which technical team it should be routed to, and what severity score it should receive. Tickets with low confidence are automatically escalated to manual processing, preventing service risks caused by misjudgment. In testing, Clef can complete a set of typical triage decisions within 209 milliseconds, significantly shortening the ticket response chain.
Threat Intelligence and Phishing Classification: Combined with Browser Run to capture and render the target webpage, input the page screenshot and domain information into Clef for multi-label threat classification of the domain/page, such as phishing, scams, and malicious downloads. Official testing shows that this full process takes approximately 2.2 seconds, offering higher efficiency than manual analysis or traditional rule engines when identifying new phishing site variants.
Bot Traffic Intent Identification: Deploy Clef-flash on the gateway hot path to quickly determine whether each incoming request is from a benign bot (e.g., search engine crawling) or a malicious bot (e.g., brute-force attacks, data scraping), making a decision to block or allow in milliseconds. With a median latency of 38.8 milliseconds, it does not introduce perceptible additional overhead to normal traffic, making it suitable for high-concurrency edge protection scenarios.
Pre-Approval for High-Risk Agent Tool Calls: Before an Agent performs high-risk operations such as deleting data, sending messages, or calling external APIs, input the operation description and list of tools into Clef to ask, "Should this be executed and which tool should be used?" The system then decides to directly approve, request user confirmation, or reject based on probability thresholds. This mechanism adds a configurable security gate to the Agent's autonomous behavior.
Log Anomaly Pattern Recognition: Leveraging a 64K context window, input long-term system logs or JSON state snapshots as a whole into Clef for multi-class scoring of anomaly patterns, identifying fault types, impact scope, and recommended handling priority to help operations personnel quickly locate root causes.
8. FAQ
Q: What is the fundamental difference between Clef and general-purpose large language models (e.g., GPT-4o, Llama 3)?
A: General-purpose LLMs generate text sequentially using a token-by-token autoregressive mechanism, producing open-ended natural language outputs. In contrast, Clef employs a non-autoregressive decision architecture, which scores all valid options in parallel after a single prefill of the input, resulting in a structured probability distribution. General-purpose LLMs are well-suited for tasks requiring explanation, generation, and open-ended reasoning, but they suffer from high latency and unstable output formats. Clef is ideal for high-frequency, structured, and confidence-scored decision tasks, achieving latency as low as 38.8 milliseconds.
Q: How can new categories be dynamically defined in Clef requests? Is retraining required?
A: Categories in Clef are temporarily defined in the questions field of the request. Users simply need to clearly specify the type, list of options, and criteria boundaries in each request. The model dynamically adapts to the schema during inference, without requiring retraining or fine-tuning for new categories. Compared to traditional classifiers, which require retraining and redeployment for each new label, this significantly simplifies the business iteration process.
Q: What is the principle behind non-autoregressive decision models? Why can they achieve millisecond-level latency?
A: Clef first performs a prefill-only forward pass on the input to establish an internal representation. It then uses a two-stage attention routing mechanism: each valid option first extracts relevant context from the prompt, and the parameters of each field cross-attend with one another and re-connect to the original payload for joint modeling. Finally, the evidence is aggregated into scores under the schema constraints. Since no token-by-token text generation occurs during this process, it avoids the serial overhead of autoregressive decoding, reducing decision latency to the level of a single forward pass.
Q: How does Clef balance performance with Clef-flash? How should one choose between them in production environments?
A: Clef (27B) has a median latency of 209.3ms and a P95 latency of 238.6ms, ranking first on the Jev Decision Index, achieving top scores in 7 out of 10 official decision benchmarks, making it suitable for accuracy-critical offline or near-real-time scenarios. Clef-flash (9B) has a median latency of just 38.8ms and a P95 latency of 122.4ms, making it ideal for online hot paths with extremely strict latency requirements. It is recommended to分流 based on risk during the gray release phase: use Clef for high-risk decisions and Clef-flash for low-risk, high-frequency decisions. Adjust the ratio based on empirical data.
Q: Is Clef free to use? Are the model weights open-sourced?
A: Clef's model weights are open-sourced on HuggingFace and can be freely downloaded for research. However, the inference service runs on the Cloudflare Workers AI platform, and calls are charged according to Workers AI's billing standards. Workers AI provides a free tier for developers to test, with additional usage charged based on the volume of calls. If full local deployment is desired, the weights must be downloaded from HuggingFace and the inference framework must be run in a self-hosted environment.
Q: How much code modification is required to migrate from Jev to Clef?
A: The API schema of both is fully compatible, and migration typically requires only two changes: the API endpoint and the model name. The existing request body structure, question definition format, and response parsing logic can all be reused. Developers using the official Jev SDK can complete the migration by switching to the Cloudflare Workers AI endpoint and adjusting the model name parameter.
Q: Does Clef support private deployment? Can it run independently of the Cloudflare platform?
A: The model weights are open-sourced, so in theory, inference services can be deployed on private infrastructure. However, the official team currently does not provide optimized solutions or containerized configurations for private deployment. Additionally, the model heavily relies on Cloudflare Workers AI's edge GPU network to achieve low-latency hosting. If deployed independently, latency performance will depend on hardware configuration and network conditions, and may not match the official 38.8ms median latency. For scenarios where latency is not critical, self-deployment can be tested; for latency-sensitive production environments, it is recommended to use Cloudflare Workers AI hosting.
9. Project Links
- Project official blog: https://blog.cloudflare.com/clef-decision-models/
- Workers AI official documentation: https://developers.cloudflare.com/workers-ai/
- HuggingFace model library (Clef 27B): https://huggingface.co/Cloudflare/clef
- HuggingFace model library (Clef-flash 9B): https://huggingface.co/Cloudflare/clef-flash
Related AI Model Articles

In-Depth Review of Mellum2.1: A Technological Leap in JetBrains' Open-Source Agentic Coding Model
Mellum2.1 is an open-source AI programming model launched by JetBrains, built on a 12B Mixture-of-Experts (MoE) architecture, activating only 2.5B parameters during each inference. The core breakthrou...

Claude Haiku 5.5 – Anthropic's Most Lightweight Model
Claude Haiku 5.5 is the latest small language model officially released by Anthropic on October 7, 2026. It is positioned as a high-value product with the tagline "cheapest, fastest, and most capable....
Ling-3.1-flash – A New Generation Large Model Launched by the Bailing Team at Ant Group
Ling-3.1-flash is a new generation large language model launched by the Bailing team at Ant Group. It employs a hybrid linear Attention architecture and MoE sparse activation technology, with a total ...

IQuest-Q1 Review: A 320B Sparse MoE Open-Source Agent Foundation Model Specializing in Code and Long-Horizon Agent Tasks
IQuest-Q1 is an open-source Agent foundation model developed by IQuestLab, with a core focus on code generation and Agent task execution. The model employs a sparse MoE architecture, featuring a total...
© All Rights Reserved. Some content on this site is partially generated by AI with human review.
