用反向翻译自监督训练代码与文档互动生成模型
BatCoder: Self-Supervised Bidirectional Code-Documentation Learning via Back-Translation
- 通过文档生成代码再反推原代码,构建自监督信号
- 7B模型在HumanEval上达83.5% pass@1,优于开源基线
- 仅需代码即可训练,适合小语种或数据少的场景
代码相关任务的大型语言模型训练通常依赖高质量的代码-文档配对数据,但这类数据成本高且稀少,尤其在冷门编程语言中。我们提出BatCoder,一种自监督强化学习框架,用于联合优化代码生成与文档撰写。该框架采用反向翻译策略:先从代码生成文档,再用生成的文档重建原始代码。原始代码与重建代码之间的语义相似度作为隐式奖励,驱动强化学习提升模型在双向任务上的表现。该方法仅需代码即可训练,显著扩大可用数据规模。在7B模型上评估,BatCoder在HumanEval和MBPP测试集上分别取得83.5%和81.0%的pass@1性能,优于现有开源基线。同时,该框架在训练数据量和模型规模上均表现出稳定增长特性。
原文摘要 · Abstract (English)
Training LLMs for code-related tasks typically depends on high-quality code-documentation pairs, which are costly to curate and often scarce for niche programming languages. We introduce BatCoder, a self-supervised reinforcement learning framework designed to jointly optimize code generation and documentation production. BatCoder employs a back-translation strategy: a documentation is first generated from code, and then the generated documentation is used to reconstruct the original code. The semantic similarity between the original and reconstructed code serves as an implicit reward, enabling reinforcement learning to improve the model's performance both in generating code from documentation and vice versa. This approach allows models to be trained using only code, substantially increasing the available training examples. Evaluated on HumanEval and MBPP with a 7B model, BatCoder achieved 83.5% and 81.0% pass@1, outperforming strong open-source baselines. Moreover, the framework demonstrates consistent scaling with respect to both training corpus size and model capacity.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。