Developers have long struggled with the binary choice between on-device AI and cloud-based LLMs. On-device models offer unmatched privacy and latency but often stumble on complex reasoning, while cloud models provide the necessary intelligence at the cost of high API fees and data exposure. This tension has created a ceiling for edge AI adoption, as teams are forced to either sacrifice accuracy for speed or bankrupt their budgets for reliability.
The Architecture of Confidence: Gemma 4 and the Probe
Cactus Hybrid addresses this trade-off by introducing a confidence-based routing system built upon the Gemma 4 E2B model. Rather than relying on the model to state its own uncertainty in text, which is notoriously unreliable, Cactus has integrated a probe directly into the model checkpoints. This probe is the result of post-training designed to allow the model to score the likelihood that its own generated answer is incorrect. The output is a structured data field providing a confidence score between 0 and 1, separate from the generated text.
This mechanism allows for a dynamic hybrid architecture. In practice, the system handles the majority of tasks on-device and only routes a fraction of queries to a more powerful cloud model, specifically Gemini 3.1 Flash-Lite. When the on-device Gemma 4 model identifies a low-confidence response, the query is escalated. Data shows that by routing only 15-35% of queries to Gemini 3.1 Flash-Lite, the hybrid system achieves performance parity with the cloud model across most benchmarks. This approach transforms the on-device model from a standalone tool into an intelligent filter that maximizes efficiency without compromising the end-user experience.
The Hidden Signal: Beyond Training Data
The most significant technical revelation of Cactus Hybrid is not the routing itself, but the nature of the signal the probe detects. During testing, the probe was applied to domains entirely absent from its training set, specifically audio data. Despite having no prior exposure to audio-specific training, the probe recorded AUROC scores between 0.79 and 0.88 across four distinct audio benchmarks, including two transcription tasks, one audio multiple-choice question (MCQ) task, and one out-of-domain transcription task.
This result suggests that the probe is not simply memorizing patterns from its training data. Instead, it is tapping into a modality-agnostic correctness signal residing within the model's hidden states. The probe identifies a universal signature of accuracy that persists regardless of whether the input is text or audio. For developers, this means the confidence-based routing logic can potentially be extended to various multimodal models, allowing for a unified deployment strategy where the model knows it is wrong before the user ever sees the answer.
Implementing this in a production environment requires specific technical precautions regarding memory and hardware. Developers must avoid using `device_map="auto"` when loading the model. Because the probe scores the output outside the standard `forward()` path of the module, any weights remaining on a meta device during offloading will cause a collision during the confidence reading process. Instead, the device must be explicitly assigned using `.to(device)`.
For those utilizing llama.cpp, the probe functionality is not available in the standard build and must be added via a patch. The necessary modifications are located in the `patches/llama.cpp/` directory. Once the patched server is compiled and deployed, the `confidence` value is returned as a top-level field in the response data, enabling immediate integration into routing logic.
Resources for this implementation, including the Cactus Hybrid collection, are available on Hugging Face under the MIT license, providing a blueprint for companies to move away from binary model selection toward a cost-effective hybrid architecture.




