Skip to content
Preprint

RAPO-Sol: Retrieval-Augmented Preference Optimization for Repository-Level Solidity Code Generation

Oct 2026 · 0 citations · 45 references
Computer Science

TL;DR

RAPO-Sol is presented, a two-stage training framework for repository-level Solidity code generation that combines complementary benefits from retrieval during training and Solidity-aware preference optimization without adding retrieval cost at inference.

Abstract

Smart contracts written in Solidity manage assets, permissions, and irreversible state changes, making code generation both useful and security-critical. Repository-level Solidity generation is challenging because models must synthesize complete contracts or libraries while preserving consistency across state variables, modifiers, events, inheritance, external calls, and access-control logic. We present RAPO-Sol, a two-stage training framework for repository-level Solidity code generation. First, Retrieval-Augmented Fine-Tuning (RAFT) augments each training input with similar Solidity examples, helping the model learn recurring contract-level patterns while remaining retrieval-free at inference time. Second, Direct Preference Optimization (DPO) trains the model to prefer reference contracts over close but semantically flawed alternatives. We construct rejected samples using Solidity Semantic-Anchor Perturbation (SAP), which perturbs validation statements, visibility modifiers, data-location keywords, context variables, payment operations, and low-level calls. Experiments on SolidityBench with CodeLlama-7B-Instruct, DeepSeek-Coder-6.7B-Instruct, and Qwen2.5-Coder-7B-Instruct show that RAFT consistently improves over supervised fine-tuning, while SAP-based DPO provides further gains in BLEU and SolidityScore. The full RAFT+DPO pipeline achieves the best performance across all three models, demonstrating complementary benefits from retrieval during training and Solidity-aware preference optimization without adding retrieval cost at inference.

View source

Similar papers

Preprint Oct 2026

Rivet: Utility-Preserving Context Control for Repository-Level Coding Agents

Rivet is proposed, a context control framework that preserves repository evidence for coding agents under a fixed context budget that achieves the highest Pass@1 in all 16 settings and improves over the strongest baseline by 3.15 percentage points on average.

Ru-Wei Pan, Lin-Hao Wu, Ya-Kun Zhang et al. · 0 citations
Open access Nov 2026

TalentLoop – AI-Driven Resume Generation and Semantic Verification via Live Codebase Integration and Dynamic ATS Weighting

In modern hiring practices, the standard Applicant Tracking System (ATS) is dependent on manipulative keyword-based algorithms, making them susceptible to the creation of false credentials and technical skills. In this paper, we present TalentLoop, a novel Tri-Score recruitment architecture that abandons static heurist...

Aryan Naik, Apeksha Ranjan, D. Jadhav et al. · 0 citations
Preprint Oct 2026

Which Code Changes Need Re-embedding? CIPBench and the Limits of Multi-Signal Index Maintenance

Repository-level retrieval-augmented generation systems must keep vector indexes synchronized with continuously evolving code, yet there is no principled basis for deciding which changed code units actually need new embeddings. We ask whether the retrieval impact of a code change can be anticipated before that embeddin...

Nan-Nan Zhao, Jia-Meng Zhang, Tao-Yu Zhong et al. · 1 citation
#artificial intelligence Preprint Nov 2026

Time-Consistent Evaluation of Hierarchical Code Graphs for SWE Agents

Across 7,200 paired evaluations spanning six foundation models across the MAI-Code Flash, Claude, and GPT-Sol families, ServiceExplorer consistently outperforms both Baseline and Tree-sitter AST across every model, repository, and prompt granularity.

Xian-Peng Sun, Tian-Yi Yu, Hao-Nan Sun et al. · 0 citations

ReMCTS: Reflection-Enhanced Monte Carlo Tree Search for Code Generation

ReMCTS, an execution-grounded, memory-augmented, LLM-guided MCTS-style search framework that organizes program candidates as tree states, retains branch-local debugging context, retrieves failure experience across branches, and distinguishes failed checks from unavailable evidence is presented.

Hui-Fei Wang, Xin-Yi Huang, Yi-Heng Sun et al. · 0 citations
#artificial intelligence Preprint Sep 2026

ContractRL: Shielded Group-Relative Policy Optimization for Auditable Tool-Call Repair

Structured tool calls often fail after only a small number of fields violate a schema or an execution contract. Regenerating the complete object enlarges the action surface and makes repeated repair difficult to audit. We introduce ContractRL, a contract-constrained sequential repair protocol that models verifier-guide...

Miao-Bo Hu, Shu-Hao Hu, Xiao-Bo Guo et al. · 1 citation

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.