Large Language Model Selection and Hallucination Control: A Practical Guide
This guide explains how to choose a large language model based on task fit rather than raw capability, and how to control hallucinations in production. It covers task layering, the two main failure modes, a reproducible evaluation method with fixed test cases and consistency scoring, structured prompting, retrieval-augmented generation with citations, multimodal grounding, and handling long constraint chains with external tools. A final checklist helps teams make uncertainty explicit and intercept errors before they reach users.
1. Reframe the Problem: Choose the Best Fit, Not the Strongest Model
When teams compare two general-purpose LLM services, the discussion often collapses into an argument about which model is “smarter.” A more rigorous approach is to break the problem apart. Models perform inconsistently across four dimensions: factual recall, open-ended reasoning, long-context consistency, and multimodal grounding. Moreover, the gap between prompt strategies applied to the same model is often larger than the gap between models. So the first step in selection is task layering, not a side-by-side score.
Start by sorting business scenarios into three layers:
- Factual: term definitions, API semantics, configuration option meanings. There is one correct answer, and it can be verified.
- Reasoning: deriving a solution under multiple constraints. An answer exists, but the path to it is not unique.
- Generative: marketing copy, creative rewrites. No single correct answer; style and preference matter most.
These three task types tolerate very different levels of “confidence.” Evaluating them together in one mixed test set will inevitably produce contradictory conclusions.
2. Two Forms of Hallucination: Fabricated Facts and Overconfidence
One typical phenomenon described in the source material: for an event involving a real person, the model produced content that was structurally complete and delivered in a confident tone, but did not exist. That is factual fabrication. A second, more subtle form appears when the model faces an open question with no definite answer and returns a single high-confidence conclusion, which then misleads decision-making.
The causes differ, and so do the remedies:
- Factual fabrication mostly stems from incorrect associations in parametric memory and requires an external knowledge source as a fallback.
- Overconfidence mostly stems from differences in alignment strategies. Some models lean toward conservative refusal; others lean toward agreeable conclusions. This must be suppressed through prompt constraints and post-hoc verification.
In engineering terms, treat refusal rate and verifiability rate as first-class metrics in evaluation, rather than judging only whether an answer reads smoothly.
3. A Reproducible Evaluation Method: Fixed Case Set and Layered Scoring
Do not make decisions based on ad hoc questions. Build a fixed case set of 30 to 100 items covering the three task layers above. Each case contains three fields: input, reference answer, and judging method. Automate the judging wherever possible:
case:id: F-017type: factinput: "For a certain open-source video generation approach with a dual-sampler structure (high-noise and low-noise), how should the merged weights handle noise-version adaptation?"reference: "Follow the official documentation; do not attach the high-noise version adaptation layer."judge: exact_match | llm_judgetolerance: 0
During evaluation, fix the temperature, fix the system prompt, and fix the context length. Repeat each case three times and compute a consistency rate. Any case whose consistency rate falls below the threshold is marked “unstable” outright, regardless of whether a single answer happened to be correct. This step filters out a large number of models that merely “look usable.”
4. Structured Prompting: Turn Open Questions into Decidable Ones
Models are most prone to overconfidence on open-ended questions. An effective practice is to force the model to output constraints and uncertainties first, then the conclusion:
Answer in the following steps:1. List the known conditions this question depends on;2. Mark which conditions cannot be confirmed from public information;3. If conditions are incomplete, give no more than two candidate conclusions with their respective premises;4. Finally, state the verification action you recommend.
This “premises first, conclusion second” structure significantly reduces the share of unfounded assertions and lowers review cost. For factual questions, the system prompt should state explicitly: if you cannot confirm it, answer that you cannot confirm it, and do not fill in details.
5. Retrieval Augmentation: Give Facts a Source
Factual tasks should not rely on parametric memory. Chunk authoritative documents into an index, retrieve the relevant pieces, splice them into the context, and require the model to cite a source number for each statement:
Context:[1] Official documentation: Do not use the high-noise adaptation layer.[2] Community discussion: two contradictory claims exist.Question: How should the adaptation layer be loaded with merged weights?Requirement: Answer using only [1] and [2], mark the citation numbers, and when they conflict, defer to [1].
The value of retrieval augmentation is not only higher accuracy. It turns “what the model said” into something traceable. Logging and monitoring should record the document version behind every retrieval hit, which makes incident review straightforward.
6. Multimodal Scenarios: Grounding Differs Between Parts and the Whole
The source material describes a typical multimodal failure: the full image shows a pirate ship and a mermaid, but after a local crop that resembles a violin, the model could not point out where that region is. This reflects two distinct capabilities: fine-grained localization, and reasoning about the relationship between the whole and its parts.
Practical recommendations:
- For localization needs, require the model to output normalized coordinates or a region description rather than vague natural language.
- For compound judgments of the “a part looks like A, the whole is B” kind, split the query in two: describe the whole first, then compare region by region.
- Build a small image-text test set and track localization hit rate as a quantitative metric of multimodal capability.
7. Complex Technical Problems: Externalize Long Constraint Chains
In the dual-sampler weight and adaptation layer problem from the source material, the difficulty is not the amount of knowledge but the length of the constraint chain: model structure, adaptation layer version, and noise branch constrain one another. For such problems, write the constraints out as a checklist and hand them to an AI coding tool with strong tool-calling and code-execution ability to verify, instead of asking a conversational model to “think up” the answer in one pass.
A reusable workflow: turn constraints into a checklist, generate candidate solutions, reproduce a minimal case in a sandbox, then use logs to verify whether the correct branch was actually loaded. If any step fails, roll back so the wrong conclusion does not propagate downstream.
8. Selection Conclusions and a Deployment Checklist
Overall, scenarios that prioritize factuality should favor the more conservative, more verifiable option. Scenarios that prioritize creative generation and conversational experience can accept more agreeable phrasing, but post-hoc verification is mandatory. The checklist:
- Build a layered case set with a consistency-rate threshold.
- Enforce retrieval augmentation and citation for factual tasks.
- Enforce premise enumeration and multiple candidate outputs for open-ended tasks.
- Route key conclusions to a human review queue, and feed review records back as evaluation cases.
- Use a container platform to host sandbox reproduction, and use logs and monitoring metrics to observe hallucination rate continuously.
One premise has to be accepted in the end: no model has a 100% accuracy rate. Engineering capability shows up in making uncertainty explicit and standardizing the verification process, so that errors are intercepted before they reach users. The combination of general capabilities that Baidu AI Cloud offers across model services, retrieval augmentation, and observability can serve as a reference pattern for building such a control pipeline.
