LLM Hallucination and Factuality Governance: A Practical Guide

    This guide explains why fluent but incorrect LLM outputs are risky, how hallucinations arise from probabilistic modeling and missing context, and how to control them in production. It covers building repeatable factuality test sets, prompt constraints that force uncertainty disclosure, multimodal grounding techniques, fallback designs for high-stakes domains, and a structured two-month evaluation approach for model selection. The goal is to make uncertainty explicit so teams can balance efficiency with reliability.

    1. Why “Looks Real” Is More Dangerous Than “Doesn’t Answer”

    The first problem most teams hit with large language models is not a refusal to answer. It is an answer that reads convincingly and is simply wrong. The phenomena described in the source material are typical: when asked about a public figure’s background, the model fills in a complete, coherent narrative that never happened; in technical Q&A about a specific toolchain, the model insists on a conclusion that contradicts the official documentation; in multimodal generation tasks, the model fails to locate a local structure that genuinely exists in the image.

    These failures share one trait: the output is highly fluent at the language level and unconstrained at the factual level. For developers, the risk is not a single wrong answer. The risk is that wrong output gets written directly into documentation, tickets, knowledge bases, or automated pipelines, where it becomes contamination that keeps amplifying.

    Selection therefore should not stop at subjective impressions of chat quality. It should rest on measurable dimensions: factual consistency, instruction following, refusal and uncertainty expression, multimodal grounding, and stability across long multi-step tasks.

    2. Technical Causes: From Probability Modeling to Missing Context

    A large model is fundamentally doing conditional probability modeling. It optimizes for the likelihood of the next token, not for whether the sentence is true. When a class of entities is sparse in the training corpus, or the question involves time-sensitive information, the model falls back on language priors to fill the gap, producing confident but incorrect narration.

    The common triggers fall into four categories:

    1. Extrapolation beyond the knowledge boundary: the question lies outside training coverage, and the model answers anyway.
    2. Insufficient context: required input material is missing, so the model fills in with common sense.
    3. Prompt ambiguity: open-ended questions place no constraint on the answer’s shape, leaving too much room to improvise.
    4. Multimodal alignment bias: local features extracted by the visual encoder are not properly used by the language layer, so localization questions fail.

    The point of understanding these causes is that hallucination cannot be eliminated by switching to a different model. It has to be handled with engineering that makes uncertainty explicit.

    3. Factuality Evaluation: Build a Repeatable Test Set

    The most effective way to decide whether a model fits a business is to build a small but well-structured regression test set and rerun it after every model version update.

    Recommended question types:

    • Closed factual questions: a single correct answer, automatically scorable.
    • Document consistency questions: given official documentation, check whether the model contradicts the material.
    • Open-ended reasoning questions: observe whether the model proactively flags uncertainty.
    • Multimodal localization questions: given an image and a description, test local structure recognition.
    • Long-context questions: retrieve the key constraint among a large volume of distractors.

    A sketch of the evaluation harness (pseudocode, expressing flow only):

    1. cases = load_cases("eval_set.jsonl") # each entry has prompt, reference, type
    2. report = []
    3. for c in cases:
    4. out = call_model(c.prompt, temperature=0.0) # disable randomness during evaluation
    5. score = judge(out, c.reference, c.type) # rules or manual review
    6. report.append({"id": c.id, "type": c.type, "score": score})
    7. print(summarize(report)) # report pass rate per question type, not a single total score

    Two practices matter. Set the temperature to 0 during evaluation to reduce random variation. Report pass rates per question type so a total score cannot hide a critical weakness. The source material notes that “a question from a year ago still fails on the new version,” which is exactly the value of a fixed regression set: it surfaces stalled capability and regressions across version iterations.

    4. Prompt Engineering: Trading Constraints for Determinism

    Given open-ended questions, models tend to produce agreeable, fluent answers, while conservative models tend to avoid answering. Prompt structure can pull both tendencies back into a controllable range.

    A reusable constraint template has four parts:

    1. Role and boundaries: state the usable knowledge scope.
    2. Material first: require answers to rely only on the provided material.
    3. Uncertainty labeling: require an explicit statement when information is insufficient.
    4. Structured output: fix the fields so programs can parse the result.

    Example:

    1. You may answer only based on the material provided below.
    2. If the material does not cover it, output: {"answer": null, "reason": "insufficient material"}
    3. Output must be JSON with fields: answer, evidence, confidence.

    When combined with retrieval-augmented generation (RAG), inject the retrieved passages together with source identifiers and require the model to cite them item by item. Then even if the model makes an incorrect inference, the citation chain lets you quickly tell whether the problem is retrieval or generation.

    5. Multimodal Scenarios: Local Detail vs. Global Semantics

    The image case in the source material is representative: the full image shows a pirate ship under attack, while a local crop resembles a violin, and the model fails to point out where that local region is. This reflects a common multimodal behavior in which global semantics suppress local detail: salient objects dominate attention allocation, and weakly salient but clearly shaped regions get ignored.

    Improvements include:

    • Give explicit spatial cues in the prompt, such as “describe the image by a nine-grid layout, then indicate which region contains the target.”
    • Use a detect-then-describe pipeline that splits localization and description into two steps.
    • Crop and enlarge key regions for a second pass, then have the model confirm.
    • Output coordinates or region IDs so a program can verify, rather than accepting a vague natural-language explanation.

    When the model cannot produce a verifiable localization result, treat it as a failed sample rather than accepting a plausible-sounding verbal defense.

    6. Fallback Design for High-Risk Scenarios

    In healthcare, legal, and financial settings, factual errors are extremely costly. A workable strategy is to position the model as an aid for organizing and expressing information, not as the source of conclusions.

    Engineering fallbacks typically have four layers:

    1. Mandatory citation: every conclusion must carry a clickable source.
    2. Two-model cross-check: when two models disagree, escalate to a human.
    3. Rules engine up front: dosages, units, statute numbers, and similar items are validated by deterministic rules.
    4. Full-chain logging: record prompts, retrieved passages, and output versions for traceability.

    On the cloud, this can be assembled from object storage for source material, a logging service for the call chain, monitoring and alerting with a threshold on abnormal output rate, and a container platform to run evaluation and inference jobs, forming a closed loop.

    7. Selection Methodology: Running a Two-Month Comparison

    Instead of arguing which assistant is stronger, design a structured trial:

    • Week 1: measure accuracy with closed factual questions.
    • Week 2: measure resistance to misleading input with official-document consistency questions.
    • Week 3: measure grounding with multimodal localization questions.
    • Weeks 4 to 8: connect real business tasks and track the manual correction rate.

    Fix the evaluation metrics at four: first-pass rate, manual correction time, distribution of error severity, and reasonableness of refusals. All four beat a single subjective impression.

    8. Conclusion

    Capability differences between models are real, but no model can guarantee 100% correctness. What actually determines business safety is the evaluation system, prompt constraints, retrieval augmentation, and human fallbacks. Making uncertainty explicit as a design principle is what allows a sustainable balance between efficiency and reliability. Organizations that want to build this kind of evaluation and governance system on Baidu AI Cloud can assemble it from general-purpose capability categories, keeping the stack technically neutral and replaceable.