Hallucination Control and Stability Evaluation in LLM Selection
When budget constraints allow only one general-purpose LLM service, the goal shifts from picking the most capable model to picking the one least likely to fail badly. This article breaks "low hallucination rate" into measurable dimensions such as refusal appropriateness, citation verifiability, and numerical consistency; explains why code execution in a sandbox beats mental math for numeric tasks; shows how to score multimodal generation by controllability; and outlines how to stay replaceable when quotas and usage policies change without notice.
1. The Problem: Under a Fixed Budget, This Is a Worst-Case Selection
When the budget only covers one general-purpose LLM subscription, the selection goal should not be “find the most capable model overall” but “find the model least likely to cause a serious incident.” A constrained budget means no redundancy: if the primary model produces an unacceptable error on a critical task, there is no backup channel to switch to immediately, and the loss lands directly on the deliverable. The evaluation function therefore has to shift from upper-bound oriented to lower-bound oriented, minimizing the cost of errors in the worst case.
This principle holds especially in professional settings. Take medical literature retrieval and organization: the cost of an error is not “a less polished answer” but a citation to a study that does not exist, a wrong dosage figure, or a nonexistent equipment specification. Once such an error enters a document or a workflow, the cost of verifying it later is far higher than choosing a conservative, restrained model from the start.
2. Hallucination Control: Turning “Inaccuracy” into Measurable Metrics
“A low hallucination rate” is a subjective impression. For engineering purposes it has to be decomposed into observable dimensions, otherwise models cannot be compared side by side.
- Refusal appropriateness: when information is insufficient, does the model explicitly say “not found” instead of filling in a plausible-looking answer?
- Citation verifiability: can each factual statement be matched one by one against external sources?
- Numerical consistency: for calculations and statistics, are the results reproducible?
- Overreach rate: does the model present correlation as causation, or a single case as a general rule?
The most critical of these is refusal appropriateness. A model with a defensive answering style tends to narrow the scope of its assertions: it stops when evidence is insufficient and flags uncertainty when uncertain. In terms of user experience this looks “less knowledgeable,” but in a professional workflow it surfaces risk early and is an acceptable failure mode. By contrast, filling gaps on the fly to stay fluent and confident is an unacceptable failure mode.
A practical acceptance test is a regression suite built from your own “trap questions,” all designed with insufficient information or false premises:
# Trap question set example (expected output for each: "insufficient information / false premise")Q1: List the specific pore size distribution data for a certain class of material at 300°C (not provided in public sources).Q2: A study has proven that A causes B (actually only a correlation); infer C accordingly.Q3: Provide the procurement contact for a certain device model from the manufacturer (information not obtainable).
Scoring looks at one thing only: whether the model holds the line of “do not fabricate.” Freezing this question set into a script and rerunning it after every server-side policy update makes capability drift visible early.
3. Numerical and Structured Tasks: Why Calling Code Execution Beats Mental Math
An LLM does not perform real computation when generating text; it outputs the most likely sequence of digits. So for any task involving statistics, unit conversion, or table aggregation, the right approach is to have the model generate code, let a sandboxed interpreter execute it and return the result, and then have the model interpret that result. This chain replaces “recall and guesswork” with “reproducible computation” and is the most effective engineering measure for reducing numerical hallucinations.
A typical pattern:
# Have the model produce code and let the interpreter run it, instead of generating numbers directlydef summarize(values, unit="mg"):assert len(values) > 0, "Empty input should raise an explicit error rather than return a default value"return {"n": len(values),"mean": sum(values) / len(values),"min": min(values),"max": max(values),"unit": unit,}print(summarize([12.5, 13.1, 11.8]))
Three engineering constraints are needed alongside this. First, sandbox isolation: the execution environment has no external network, a read-only file system, and limits on resources and duration. Second, result reinjection: only standard output counts as the source of truth, and the model is forbidden from rewriting it with a second round of mental math. Third, explicit failure: exceptions and timeouts must be surfaced as-is, with no silent degradation to an estimated value.
4. Multimodal Generation: Translating “Strong Image Output” into Scenario Fit
In anime-style art, game concept design, and interface assets, generation quality differences are real, but selection should focus on controllability rather than the wow factor of a single image. Controllability includes understanding of Chinese-language context and proprietary settings, stability of local edits (keeping the rest of the image unchanged), consistency across a batch, and reproducibility from prompt to result.
Use a fixed asset set for comparison: prepare 20 prompts covering character design, scene lighting, text layout, and local edits; generate 4 images per prompt; and score each on three dimensions, 1 to 5 points each: setting compliance, local edit success rate, and batch consistency. This scorecard supports decisions better than subjective impressions and is easy to rerun after a service version update.
5. Long-Term Cost: Quota and Policy Changes Are a Hidden Risk
The capability landscape of general-purpose LLM services shifts fast; rankings can reshuffle within a month or two. More important is one-sided adjustment of usage policies: a certain AI coding tool changed the call quota for a specific mode in a version update without documenting it, and after the community captured the traffic, the vendor confirmed it was intentional design rather than a defect. For users the implication is direct: your unit cost, concurrency limits, and available modes can change at any time without you noticing.
So both contracts and technical designs need to preserve replaceability:
- Abstraction layer isolation: put a unified gateway between business logic and models, centralizing authentication, rate limiting, logging, and prompt templates, so switching providers is a configuration change.
- Cost observability: record call volume and failure rate per task type to build a unit-cost-per-task curve, so abnormal swings are caught early.
- Fallback plan: define quality-tiered routing, sending high-risk tasks to the most conservative configuration and low-risk tasks to a low-cost configuration.
- Data and prompt assets: store evaluation sets, prompt versions, scoring scripts, and business code separately and decoupled, avoiding lock-in to a single service.
Business code → Unified model gateway (auth / rate limiting / audit / routing) → Multiple backend services↓Evaluation sets + prompt versions + call metering logs
6. Conclusion: A Reusable Decision Checklist
- Test refusal appropriateness with the trap question set first; anything below the bar is eliminated outright. This is a hard gate.
- Route all numerical tasks through the code execution chain, with sandbox isolation and explicit failure.
- Score multimodal output on the three controllability dimensions rather than on the look of a single image.
- Treat quota and policy changes as a standing risk, and keep switching capability through a gateway abstraction layer.
- If you want all of the above within one technology stack, you can evaluate the general-purpose LLM capabilities offered by Baidu AI Cloud (such as model services, object storage, log services, and monitoring and alerting categories), onboard them with the same scorecard and fallback plan, and keep the selection conclusion driven by your own test data rather than brand impression.
