Saved in:
Bibliographic Details
Main Authors: Dong, Qian, Chen, Jia, Ai, Qingyao, Wang, Hongning, Li, Haitao, Wu, Yi, Hu, Yao, Liu, Yiqun, Ma, Shaoping
Format: Preprint
Published: 2025
Subjects:
Online Access:https://arxiv.org/abs/2507.19033
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866911200099434496
author Dong, Qian
Chen, Jia
Ai, Qingyao
Wang, Hongning
Li, Haitao
Wu, Yi
Hu, Yao
Liu, Yiqun
Ma, Shaoping
author_facet Dong, Qian
Chen, Jia
Ai, Qingyao
Wang, Hongning
Li, Haitao
Wu, Yi
Hu, Yao
Liu, Yiqun
Ma, Shaoping
contents Existing retrieval-augmented code generation (RACG) methods typically use an external retrieval module to fetch semantically similar code snippets used for generating subsequent fragments. However, even for consecutive code fragments, the content often diverges due to logical progression, resulting in a content gap. This gap undermines the performance of current RACG methods, as \textit{external} retrieval modules based on content matching fail to infer the specific information need of LLMs to generate the next code fragment. Therefore, we propose \textbf{SelfRACG}, a novel paradigm that enables large language models (LLMs) to \textbf{Self}-express their information needs to enhance \textbf{RACG}. Specifically, SelfRACG includes an information need expression module and a two-stage information need-guided training strategy, which encourages LLMs to express their information need. Extensive experiments demonstrate that SelfRACG can retrieve external knowledge that better aligns with the LLM's own information needs, resulting in superior generation performance compared to vanilla RACG.
format Preprint
id arxiv_https___arxiv_org_abs_2507_19033
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle SelfRACG: Enabling LLMs to Self-Express and Retrieve for Code Generation
Dong, Qian
Chen, Jia
Ai, Qingyao
Wang, Hongning
Li, Haitao
Wu, Yi
Hu, Yao
Liu, Yiqun
Ma, Shaoping
Information Retrieval
Existing retrieval-augmented code generation (RACG) methods typically use an external retrieval module to fetch semantically similar code snippets used for generating subsequent fragments. However, even for consecutive code fragments, the content often diverges due to logical progression, resulting in a content gap. This gap undermines the performance of current RACG methods, as \textit{external} retrieval modules based on content matching fail to infer the specific information need of LLMs to generate the next code fragment. Therefore, we propose \textbf{SelfRACG}, a novel paradigm that enables large language models (LLMs) to \textbf{Self}-express their information needs to enhance \textbf{RACG}. Specifically, SelfRACG includes an information need expression module and a two-stage information need-guided training strategy, which encourages LLMs to express their information need. Extensive experiments demonstrate that SelfRACG can retrieve external knowledge that better aligns with the LLM's own information needs, resulting in superior generation performance compared to vanilla RACG.
title SelfRACG: Enabling LLMs to Self-Express and Retrieve for Code Generation
topic Information Retrieval
url https://arxiv.org/abs/2507.19033