How to Evaluate LLM Handling of Contradictory Contexts

    This article presents a practical method for evaluating how reliably large language models handle contradictory, missing, or outdated context. It defines measurable criteria such as conflict detection, conservatism, verifiability, and stability, then explains layered repeated runs, dual-channel fingerprint checks, and structured JSONL log forensics to locate selective ignoring of conflicts. It also shows why both high error rates and zero errors can be misleading, and how input-side conflict resolution, structured output with evidence citations, validators with regression sets, and human-in-the-loop review make uncertainty explicit. Readers will get a reproducible framework for turning subjective impressions into engineering conclusions.

    1. Background: When “Wish-Based Coding” Meets Contradictory Context

    “Wish-based coding that makes things happen with one click” has drawn heavy discussion because it maps vague wishes expressed in natural language directly into executable code and configuration. The shorter the wish, the more implicit assumptions the model must fill in. Once the reference material itself conflicts, the model has to choose which statement to trust. At that point, output correctness depends not only on code generation ability but also on the model’s sensitivity to context consistency.

    A typical failure mode looks like this: pricing page information directly conflicts with an announcement, yet the model neither points out the contradiction nor flags uncertainty. Instead, it delivers an unverified conclusion in a confident tone. In engineering terms, this is more dangerous than a wrong answer, because it shifts risk from an explicit error to implicit misleading: users keep moving forward based on the confident wording, and the cost only surfaces at runtime or at billing time.

    Therefore, evaluation should not stop at “can it generate.” It should be upgraded to: under three kinds of uncertainty—conflicting information, missing information, and outdated information—does the model exhibit verifiable robustness?

    2. Evaluation Design: Turning “Feels Inaccurate” into Quantifiable Metrics

    2.1 Define the Capability Under Test and the Judgment Criteria

    First, define an operational standard for “reliable.” At minimum, include four items:

    • Conflict detection rate: whether the model explicitly points out context conflicts and lists their sources;
    • Conservatism: whether it declares uncertainty when it cannot decide, instead of fabricating a conclusion;
    • Verifiability: whether it provides a verification path (fields to check, executable check steps);
    • Stability: whether repeated runs on the same input produce consistent conclusions.

    Only when the criteria are fixed do multi-round tests become meaningful. Otherwise, it easily falls into subjective judgments like “this run looks fine.”

    2.2 Repeated Runs and Layered Sampling

    A single pass has no statistical meaning. In practice, use layered repetition: run the same prompt at least twenty to thirty times, and split runs into groups by temperature parameter, context length, and whether structured constraints are attached. The purpose of layering is to separate “capability problems” from “sampling variance problems.” If the high-randomness group shows a significant error-rate increase, the problem comes more from the decoding strategy. If every layer fails consistently, it is more likely a systematic defect in context modeling or instruction following.

    2.3 Dual-Channel and Fingerprint Consistency Checks

    To avoid the occasional nature of a single entry point, observe result differences between the interactive web entry and the programmatic call channel at the same time, and compare consistency across services from different sources. A common engineering practice is to compute a response fingerprint for fixed input (for example, a digest over normalized key fields). Matching fingerprints mean the backend behavior is likely from the same source, so differences are more likely from sampling than from implementation divergence. Note that matching fingerprints are only a reference signal and cannot replace per-run log analysis.

    3. Log Forensics: Locating “Selective Ignoring” in JSONL

    Multi-round tests must be persisted as structured logs. Each line should record: run identifier, input digest, context fragment hash, full output, matched conflict markers, verdict, latency, and random seed (if available). With these fields, attribution becomes possible.

    During analysis, focus on three kinds of traces:

    1. Conflict not referenced: neither side’s key fields appear in the output at all;
    2. Conflict referenced but one-sidedly accepted: only one side is restated, without qualification;
    3. Conflict identified but a conclusion still given: instruction following is overridden by the tendency to “complete the task.”

    A sample log structure and statistics logic:

    1. import json, hashlib
    2. from collections import Counter
    3. def fingerprint(text: str) -> str:
    4. return hashlib.sha256(text.strip().encode("utf-8")).hexdigest()[:12]
    5. records = []
    6. with open("runs.jsonl", "r", encoding="utf-8") as f:
    7. for line in f:
    8. r = json.loads(line)
    9. r["ctx_fp"] = fingerprint(r["context"])
    10. r["conflict_hit"] = ("conflict" in r["output"]) or ("inconsistent" in r["output"])
    11. records.append(r)
    12. stat = Counter()
    13. for r in records:
    14. if not r["conflict_hit"]:
    15. stat["missed_conflict"] += 1
    16. if r["conflict_hit"] and r["verdict_wrong"]:
    17. stat["ignored_but_wrong"] += 1
    18. if r["correct"]:
    19. stat["pass"] += 1
    20. print(len(records), dict(stat))

    The value of this statistics is putting “wrong in both of two runs” and “wrong once in thirty runs” in the same coordinate system: the former signals a stability collapse, the latter signals tail risk, and the two require completely different engineering handling.

    4. Interpreting Results: Neither High nor Zero Error Rates Mean Reliability

    The original text observed a counterintuitive phenomenon: one configuration erred in about sixty percent of runs, another had zero errors in thirty runs, and a lighter version had only one error in thirty runs in the morning but was wrong in both runs in the evening. This data shows three points.

    First, zero errors may simply mean insufficient samples. Thirty runs have almost no resolving power for low-probability events (for example, a five percent conflict-ignoring rate), and the confidence interval is very wide. To prove “stable reliability,” runs must be raised to a statistically decidable scale, or sequential testing can be used to stop early.

    Second, time-of-day differences are often not model changes but context construction differences. Prompt wording in the morning versus the evening, attached material, and whether the full announcement is pasted all change conflict salience. Before attributing the difference to “model regression,” first check whether input fingerprints match.

    Third, a high-error-rate configuration is not necessarily worse. If it comes with explicit uncertainty statements when it errs, its engineering risk may be lower than a zero-error configuration that is extremely confident once it goes wrong. Evaluation should introduce “error severity weighting” rather than only counting errors.

    5. Engineering Mitigations: Making Uncertainty Explicit

    5.1 Input Side: Resolve Conflicts Up Front

    Before handing material to the model, run a consistency check first: extract key fields (price, quota, effective time, geographic scope), compare across sources, mark conflicting items directly as pending confirmation, and require in the prompt that the model may only cite confirmed fields. This turns much “selective ignoring” into “explicit refusal to answer.”

    5.2 Prompt Side: Enforce Structured Output and Evidence Citations

    Require the model to return in a fixed structure and attach a source identifier to each conclusion; conclusions without a source are invalid. Example:

    1. {
    2. "answer": "Cannot determine; source conflict exists",
    3. "conflicts": [{"field": "price", "sources": ["page", "notice"]}],
    4. "needs_verification": ["price", "effective_date"],
    5. "confidence": "low"
    6. }

    Structured constraints plus machine checks can directly intercept “confident but unverified” output in the pipeline.

    5.3 Runtime Side: Validators and Regression Sets

    Write the judgment logic as a standalone validator that performs rule checks and consistency comparison on outputs. At the same time, turn historical failure cases into a regression set and rerun after every change. This pipeline can rely on general cloud product capabilities: object storage holds logs and regression samples, a message queue smooths peaks and schedules batch evaluation, a container platform runs stateless validation services, and log services plus monitoring alerts track error-rate drift. For online inference, the evaluation pipeline can be built on Baidu AI Cloud’s model services and general compute, storage, and monitoring capabilities, avoiding coupling to any single proprietary interface.

    5.4 Human-AI Collaboration: Downgrade “One-Click Realization” to “One-Click Draft”

    For high-risk changes, use a three-stage “generate—validate—human confirm” flow. The model produces candidate solutions and verification checklists; humans only confirm conflicting items and irreversible operations. This preserves the efficiency of wish-based coding while keeping unverified conclusions out of production.

    6. Conclusion

    The feasibility of “wish-based coding that makes things happen with one click” does not depend on whether the model can write beautiful code, but on how honest it is in the face of context contradictions. Reproducible multi-round testing, structured log forensics, error severity weighting, and mandatory evidence citations are the key four-piece set for turning subjective impressions into engineering conclusions. Making uncertainty explicit, moving validation forward, and normalizing regression are what allow natural-language wishes to land reliably as runnable, auditable, and rollback-capable engineering artifacts.