arXiv:2603.12165cs.CL2026-03

用反向语义一致性筛选高质量合成代码指令,提升模型训练效果。

QAQ: Bidirectional Semantic Coherence for Selecting High-Quality Synthetic Code Instructions

  • 从答案反推问题的语义一致性评估数据质量
  • 仅选25%数据即达全量数据性能,优于现有方法
  • 适合需要高效筛选合成数据的研究者和工程师

合成数据已成为训练代码生成模型的关键,但其噪声和幻觉难以通过现有指标检测。传统数据筛选方法如指令遵循难度(IFD)仅评估给定查询时模型生成答案的难易程度(A|Q),在噪声数据上存在歧义——低概率可能源于任务本身复杂度或模型幻觉。本文提出QAQ框架,从反向视角评估:答案能否准确预测原始问题(Q|A)。引入逆向互信息(RMI)量化答案对问题的信息增益。分析表明,RMI过低表示语义错配,过高则可能包含模型易识别的缺陷模式。进一步提出基于强弱模型分歧的筛选策略,识别有效且具挑战性的样本。在三个数据集(WarriorCoder、Magpie-Qwen2.5-Coder-Pro-300K、OpenR1-Math-220k)上的实验显示,仅使用25%的分层RMI筛选数据,即可达到全量数据性能,且始终优于或媲美现有方法。该研究强调双向语义一致性在合成数据治理中的重要性,为降低计算成本提供了可扩展路径。代码已开源。

原文摘要 · Abstract (English)

Synthetic data has become essential for training code generation models, yet it introduces significant noise and hallucinations that are difficult to detect with current metrics. Existing data selection methods like Instruction-Following Difficulty (IFD) typically assess how hard a model generates an answer given a query ($A|Q$). However, this metric is ambiguous on noisy synthetic data, where low probability can distinguish between intrinsic task complexity and model-generated hallucinations. Here, we propose QAQ, a novel data selection framework that evaluates data quality from the reverse direction: how well can the answer predict the query ($Q|A$)? We define Reverse Mutual Information (RMI) to quantify the information gain about the query conditioned on the answer. Our analyses reveal that both extremes of RMI signal quality issues: low RMI indicates semantic misalignment, while excessively high RMI may contain defect patterns that LLMs easily recognize. Furthermore, we introduce a selection strategy based on the disagreement between strong and weak models to identify samples that are valid yet challenging. Experiments across three datasets spanning code generation (WarriorCoder, Magpie-Qwen2.5-Coder-Pro-300K) and math reasoning (OpenR1-Math-220k) demonstrate that selecting just 25\% of data using stratified RMI matches full-data performance while being consistently competitive with or better than existing data selection methods. Our approach highlights the importance of bidirectional semantic coherence in synthetic data curation, offering a scalable pathway to reduce computational costs without sacrificing model capability. Code is available at https://github.com/XXSg559/QAQ.

代码生成数据筛选大模型语义一致性

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。