arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2509.01129cs.IR
收藏

Beyond the Surface:面向竞赛级代码生成的解感知检索模型

Beyond the Surface: A Solution-Aware Retrieval Model for Competition-level Code Generation

Shiwen Zhang, Lingxiang Wang, Hainan Zhang, Ziwei Wang, Sijia Wen, Zhiming Zheng

AI总结:

针对竞赛编程中现有检索模型重表层语义、忽略解法级逻辑相似性的问题,提出基于合成数据训练的解感知排序模型SolveRank,可提升难题代码生成效果。

摘要:

在竞赛编程任务中,题目描述往往嵌入复杂的叙事背景中,需要深度理解底层解法才能成功完成任务。当前的代码生成模型主要聚焦于词元级语义建模,极易受到无关叙事语句的干扰。受RAG(检索增强生成)启发,检索具有相似解法的参考代码可能有助于提升模型在难题上的表现。然而,现有检索模型同样强调表层语义相似度,忽略了竞赛编程中至关重要的更深层的解法级逻辑相似性。因此,设计能够准确识别并检索题目及对应代码的排序模型,仍是竞赛代码生成领域亟待解决的研究问题。本文提出了SolveRank,一种依托合成数据的竞赛编程任务解感知排序模型。具体而言,我们利用DeepSeek-R1模型生成逻辑等价但表述不同的新题目,并通过GPT-4o验证其解法一致性。随后,我们将这些样本作为正样本,以BM25检索和随机检索得到的题目作为负样本,训练SolveRank。在推理阶段,SolveRank从语料库中检索相关题目及对应代码,以辅助下游代码生成器。在xCodeEval数据集上的实验表明,SolveRank在精确率和召回率指标上均优于现有最优(SOTA)排序方法,并提升了难题的代码生成性能。

英文摘要:

In competitive programming task, problem statements are often embedded within elaborate narrative backgrounds, requiring deep understanding of the underlying solutions to successfully complete the tasks. Current code generation models primarily focus on token-level semantic modeling, highly susceptible to distractions from irrelevant narrative statements. Inspired by RAG, retrieving reference code with similar solutions may help enhance model performance on difficult problems. However, existing retrieval models also emphasize surface-level semantic similarity, neglecting the deeper solution-level logical similarities that are critical in competitive programming. Therefore, designing ranking models capable of accurately identifying and retrieving problems and corresponding codes remains an urgent research problem in competitive code generation. In this paper, we propose SolveRank, a solution-aware ranking model empowered by synthetic data for competitive programming tasks. Specifically, we leverage the DeepSeek-R1 model to generate logically equivalent but differently phrased new problems, verified by GPT-4o for solution consistency. Then, we train SolveRank with these as positive samples and BM25/random-retrieved problems as negatives. During inference, SolveRank retrieves relevant problems and corresponding code from the corpus to assist a downstream code generator. Experiments on the xCodeEval dataset demonstrate that SolveRank outperforms SOTA ranking methods in precision and recall metrics, and boosts code generation performance for difficult problems.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑