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

Abstract: 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.

## introduction recent large language models (llms) achieve human-level performance on simple programming tasks @xcite , but ## method the framework of solverank consists of three stages, as illustrated in figure 3 . we use the deepseek-r1 model to generate logically equivalent but differently phrased problems, which are verified with gpt-4o for consistency. then, we use these as positive samples to train solverank, with bm25/random-retrieved problems as negative ones. during inference, we retrieve relevant problems and code to assist the downstream code generator. ## conclusion in competitive programming, understanding problem-solving logic is crucial. current code generation models focus on surface-level semantics, which often fail on complex problems. this paper introduces solverank, a solution-aware ranking model that uses synthetic data to improve code generation performance. the model outperforms semantic-based retrievers and introduces a solutionlevel ranking task. future work will explore the reinforcement learning for ranking improvement.