Multisage boosts LLM code translation by 2.22x with semantic validation
New framework extracts and verifies program semantics to slash translation errors by half.
Large language models (LLMs) show promise for automated code translation, but often rely on token-level patterns rather than deep program semantics, leading to logical and semantic errors in translated code. To address this, Yufu Wang and colleagues proposed Multisage, a multi-semantic augmentation and self-calibration framework that builds rich, verified semantic information directly from source code. The framework consists of three modules: a semantic representation parsing module that extracts data-flow graphs, type constraints, and external API information; a multi-semantic augmentation module that generates code summaries, function-level test cases, and API-oriented descriptions and tests; and a semantic consistency calibration module that uses semantics-preserving mutations and cross-semantic consistency verification to filter and refine the generated semantics.
Evaluated on the HumanEval-X benchmark, Multisage improved translation success rates by up to 2.22 times across diverse backbone LLMs, consistently outperforming vanilla prompting, instruction-tuned LLMs, and Chain-of-Thought reasoning. The largest improvements were observed on smaller models, suggesting that explicit, verified semantic augmentation can bridge the reliability gap between large and small LLMs. By engineering a structured understanding of program semantics into the translation process, Multisage offers a practical path to more dependable code translation without requiring external resources like functional descriptions or test suites.
- Multisage uses three modules: semantic parsing (data-flow graphs, type constraints, API info), multi-semantic augmentation (summaries, test cases), and consistency calibration.
- Improves translation success rates by up to 2.22x on the HumanEval-X benchmark across multiple backbone LLMs.
- Outperforms vanilla prompting, instruction-tuned LLMs, and Chain-of-Thought reasoning, with the largest gains on smaller models.
Why It Matters
Makes LLM code translation more reliable by engineering semantic understanding into the process, without extra resources.