QAQ: Bidirectional Semantic Coherence for Selecting High-Quality Synthetic Code Instructions
cs.CL
Submitted: 2026-03-12
Updated: 2026-08-31
Comments: 14 pages, 5 figures. EMNLP 2026 (Main track)
Code: https://github.com/XXSg559/QAQ
License: http://creativecommons.org/licenses/by/4.0/
The gist: 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.
Terminology
Abstract
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 (AQ). 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 (QA)? 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.
Sources
- Program Synthesis with Large Language Models
- Evaluating Large Language Models Trained on Code
- DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligence
- ProDS: Preference-oriented Data Selection for Instruction Tuning
- Large-Scale Data Selection for Instruction Tuning
- StarCoder: may the source be with you!
- Rho-1: Not All Tokens Are What You Need
- Code Llama: Open Foundation Models for Code
- Qwen3 Technical Report
- Magicoder: Empowering Code Generation with OSS-Instruct
- Magpie: Alignment Data Synthesis from Scratch by Prompting Aligned LLMs with Nothing
Related papers
- Exploring Solution Divergence and Its Effect on Large Language Model Problem Solving
- Ishigaki-IDS-Bench: A Benchmark for Generating Information Delivery Specification from BIM Information Requirements
- Subliminal Steering: Stronger Encoding of Hidden Signals
- MedStruct-S: A Benchmark for Key Discovery, Key-Conditioned QA and Semi-Structured Extraction from OCR Clinical Reports
- The End of Transformers? On Challenging Attention and the Rise of Sub-Quadratic Architectures
- Untangling the Mechanisms of Misleading Context in Medical Question Answering