Urgent.News

What's breaking now, across thousands of outlets.

AI

Supercharge Your LLM Router with a Decision Model: Clef on Cloudflare Workers

In part 1 we built a classification router in about 50 lines on a Cloudflare Worker. It classifies each prompt and routes it through AI Gateway: coding questions to Claude Sonnet, everything else to a cheap Workers AI model. The classifier was a small LLM, Llama 4 Scout, with a one-line system prompt: "Reply with only that single word." Since then, a new kind of model has appeared for exactly…

In part 2, we integrate Clef and Clef-flash decision models onto the existing Cloudflare Worker router, replacing the Llama 4 Scout classifier. To measure their performance, we create a benchmark script that runs 20 labeled prompts through /classify multiple times, tracking accuracy and highlighting which prompts were incorrectly routed.

The benchmark results show that the new decision models improve accuracy but still struggle with prompts confidently routed to the wrong model. The solution lies in implementing a safer default: if the classifier is unsure or provides an incorrect answer, route the prompt to the stronger model. While this raises accuracy, it still falls short when the model is confident yet wrong.

Decision models, unlike traditional chat models, directly return typed answers without generating text, eliminating the need to parse or correct rambling responses. By providing explicit questions, the decision model can categorize prompts as coding or simple, ensuring the correct model is selected.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in AI

What are LLMs and How to Build Stuff Using it?

Ever wondered how AI models like ChatGPT, Claude, Gemini, Deepseek, Llama etc. understand and generate human-like text? The idea this whole post hangs on: an LLM only predicts the next token, so every…

Data hubs' troubled waters

The country is racing to power the global AI boom, but the unquenchably thirsty data centers it needs are already draining the water that sustains millions of lives.

More from Friday 9 October →