R2Code: A Self-Reflective LLM Framework for Requirements-to-Code Traceability
Yifei Wang, Jacky Keung, Xiaoxue Ma, Zhenyu Mao, Kehui Chen, Yishu Li

TL;DR
R2Code is a novel LLM-based framework that enhances requirement-to-code traceability by combining semantic alignment, self-reflection, and adaptive retrieval, achieving higher accuracy and efficiency.
Contribution
It introduces a self-reflective, multi-component framework that significantly improves trace link accuracy and reduces inference costs over existing methods.
Findings
Outperforms baselines with a 7.4% average F1 gain.
Reduces token consumption by up to 41.7%.
Effective across multiple domains and programming languages.
Abstract
Accurate requirement-to-code traceability is crucial for software maintenance. However, existing IR- and embedding-based methods are heavily dependent on lexical similarity, often yielding incomplete or inconsistent links across projects and languages and incurring high cost from long-context retrieval and prompting. This paper presents R2Code, an LLM-based semantic traceability framework designed to improve trace link accuracy while reducing inference cost. R2Code integrates three components: 1) a decomposition-enhanced Bidirectional Alignment Network (BAN) that aligns four-layer requirement semantics with corresponding code structures to support cross-level semantic matching; 2) a Self-Reflective Consistency Verification (SRCV) module that conducts explanation-guided consistency checking to calibrate link reliability; and 3) a Dynamic Context-Adaptive Retrieval (DCAR) mechanism that…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
