AI
New Framework Tackles LLM Code Errors by Cross-Checking Against Problem Variants
Researchers propose semantic triangulation to reduce hallucinations in AI-generated code by validating solutions against mathematically distinct versions of the same problem.
Large language models show promise in writing executable code from natural language prompts, yet the programs they produce frequently harbor bugs stemming from hallucinations. Testing approaches that rely on LLM-generated checks—such as test cases and auto-formalized specs—often fail to catch errors because the same model that wrote the buggy code typically generates flawed validation tools, leading to correlated mistakes that go undetected.
A New Validation Strategy#
Researchers have introduced semantic triangulation, a theoretically motivated approach designed to break this cycle of correlated errors. Rather than asking a single LLM to both produce and validate code, the method transforms the original problem into a fundamentally different variant—one requiring a distinct algorithmic approach—and cross-checks solutions to both versions for consistency. Under a formal model of how LLMs hallucinate, this strategy provides stronger confidence that selected code is correct.
Implementation and Results#
The framework materializes through four concrete techniques: problem inversion, decomposition, and solution enumeration strategies. Testing on benchmark suites including LiveCodeBench and CodeElo using models like GPT-4o, DeepSeek-V3, and Gemini 2.5 Flash showed tangible improvements. The method boosted the likelihood of choosing a correct program by 16% compared to conventional baselines (standard test generation, metamorphic testing, and specification auto-formalization). In scenarios where the system can either select a solution or abstain from choosing, it achieved 7% higher reliability and a 7% higher F1 score.
Distinguishing Features#
A key strength is handling inexact problems—those with multiple valid solutions—where traditional validation methods stumble. The approach uniquely manages this real-world complexity while maintaining effectiveness across diverse model architectures and problem domains.

