Improving Code Translation with Syntax-Guided and Semantic-aware Preference Optimization
- URL: http://arxiv.org/abs/2605.13229v1
- Date: Wed, 13 May 2026 09:19:39 GMT
- Title: Improving Code Translation with Syntax-Guided and Semantic-aware Preference Optimization
- Abstract summary: We argue that a robust semantic reward for code translation must be derived directly from the source code.<n>In this paper, we propose CTO to improve code translation with syntax-guided and semantic-aware preference optimization.
- Score: 22.90890448332095
- License: http://creativecommons.org/licenses/by/4.0/
- Abstract: LLMs have shown immense potential for code translation, yet they often struggle to ensure both syntactic correctness and semantic consistency. While preference-based learning offers a promising alignment strategy, it is hindered by unreliable semantic rewards derived from sparse test cases or restrictive reference translations. We argue that a robust semantic reward for code translation must be derived directly from the source code. In this paper, we propose CTO to improve code translation with syntax-guided and semantic-aware preference optimization. Through contrastive learning, we train a cross-lingual semantic model to directly assess functional equivalence between source and translated code. By formulating code translation as a multi-objective optimization problem, this robust semantic signal is seamlessly unified with compiler-based syntactic feedback within the direct preference optimization framework. Extensive experiments on C++, Java, and Python translations demonstrate that CTO significantly outperforms existing baselines and alternative preference optimization strategies.
Related papers
- An Extensive Empirical Study on Code Translation Technique [3.398993044674732]
We compare representative code translation techniques across methodological paradigms and translation granularities.<n>Our analysis considers executable correctness, code similarity, translation direction, translation, and failure patterns.<n>These findings provide empirical evidence and practical guidance for developing more robust, type-aware, structure-aware, and context-aware code translation techniques.
arXiv Detail & Related papers (2026-08-21T06:41:04Z) - Joint Semantic Token Selection and Prompt Optimization for Interpretable Prompt Learning [57.91658393667469]
Interpretable Prompt Learning is a hybrid framework that alternates between discrete semantic token selection and continuous prompt optimization.<n>Our framework is plug-and-play, allowing seamless integration with existing prompt learning methods.
arXiv Detail & Related papers (2026-05-06T02:38:59Z) - Multimodal Large Language Models with Adaptive Preference Optimization for Sequential Recommendation [60.33386541343322]
We propose a Multimodal Large Language Models framework that integrates Hardness-aware and Noise-regularized preference optimization for Recommendation (HaNoRec)<n>Specifically, HaNoRec dynamically adjusts optimization weights based on both the estimated hardness of each training sample and the policy model's real-time responsiveness.
arXiv Detail & Related papers (2025-11-24T04:10:46Z) - Can Emulating Semantic Translation Help LLMs with Code Translation? A Study Based on Pseudocode [9.384417259861438]
Pseudocode-based translation emulates the human semantic translation by first interpreting the program's intent and logic into pseudocode.<n>We find that pseudocode-based translation helps translate programs that direct translation struggles to handle.
arXiv Detail & Related papers (2025-10-01T13:58:19Z) - Function-to-Style Guidance of LLMs for Code Translation [59.487054943812836]
We propose F2STrans, a function-to-style guiding paradigm designed to improve the performance of large language models in code translation.<n>Our approach comprises two key stages: (1) Functional learning, which optimize translation correctness using high-quality source-target code pairs.<n>We introduce a novel code translation benchmark that includes up-to-date source code, extensive test cases, and manually annotated ground-truth translations.
arXiv Detail & Related papers (2025-07-15T08:25:02Z) - NL in the Middle: Code Translation with LLMs and Intermediate Representations [56.77064674776534]
Large language models (LLMs) produce buggy code translations.<n>One promising avenue to improve translation accuracy is through intermediate representations.<n>We investigate whether LLM-based code translation can benefit from intermediate representations.
arXiv Detail & Related papers (2025-07-11T14:29:21Z) - DSTC: Direct Preference Learning with Only Self-Generated Tests and Code to Improve Code LMs [56.4979142807426]
We introduce underlinetextbfDirect Preference Learning with Only underlinetextbfSelf-Generated underlinetextbfTests and underlinetextbfCode (DSTC)<n>DSTC uses only self-generated code snippets and tests to construct reliable preference pairs.
arXiv Detail & Related papers (2024-11-20T02:03:16Z) - Align-SLM: Textless Spoken Language Models with Reinforcement Learning from AI Feedback [50.84142264245052]
This work introduces the Align-SLM framework to enhance the semantic understanding of textless Spoken Language Models (SLMs)<n>Our approach generates multiple speech continuations from a given prompt and uses semantic metrics to create preference data for Direct Preference Optimization (DPO)<n>We evaluate the framework using ZeroSpeech 2021 benchmarks for lexical and syntactic modeling, the spoken version of the StoryCloze dataset for semantic coherence, and other speech generation metrics, including the GPT4-o score and human evaluation.
arXiv Detail & Related papers (2024-11-04T06:07:53Z) - The Importance of Directional Feedback for LLM-based Optimizers [23.669705029245645]
We study the potential of using large language models (LLMs) as an interactive for solving problems in a text space using natural language and numerical feedback.
We design a new LLM-based that synthesizes directional feedback from the historical optimization trace to achieve reliable improvement over iterations.
arXiv Detail & Related papers (2024-05-26T05:22:35Z)
This list is automatically generated from the titles and abstracts of the papers in this site.
This site does not guarantee the quality of this site (including all information) and is not responsible for any consequences.