FeatLens:用特征索引做仓库级代码生成检索,token 开销降 45.9%
FeatLens: Feature-Guided Dynamic Code Graph Construction and Retrieval for Repository-Level Code Generation
做仓库级代码生成的可以看看这篇:FeatLens 用功能索引建图再检索,比全仓库图方法省六成节点、四成多 token,检索还不用调 LLM。
论文提出 FeatLens,一种面向仓库级代码生成的特征引导动态代码图检索方法。它先构建将自然语言功能描述链接到函数级代码实体的特征索引,再根据任务动态生成种子图,用个性化 PageRank 做语义-结构图推理,选出紧凑的推理图,从而省去持久化全仓库图维护和 LLM 探索。在 DevEval 和 EvoCodeBench 上,FeatLens 的 DR@15 达到 0.501 和 0.460,优于稀疏、稠密和图基线。生成任务中,配合 DeepSeek-V3.2 和 GPT-5-mini 分别取得 52.91% 和 53.58% 的 DIR@1。相比最强图基线,图节点减少 61.0%、边减少 86.2%、总 token 开销降低 45.9%,且检索阶段不消耗 LLM token。
FeatLens: Feature-Guided Dynamic Code Graph Construction and Retrieval for Repository-Level Code Generation
Recent code generation research has moved from isolated function completion toward repository-level generation in existing codebases. To implement a target function correctly, an LLM must identify reusable repository dependencies such as existing functions, APIs, and cross-file definitions. Existing retrieval methods provide such context through code similarity search, persistent whole-repository graphs, or LLM-driven graph exploration, but often incur high graph construction, reasoning, and token costs. Feature-oriented methods offer a natural view of software functionality, yet they mainly support requirement decomposition, planning, or feature editing rather than code dependency retrieval. This paper presents \textbf{FeatLens}, a feature-guided dynamic code graph construction and retrieval approach for repository-level code generation. FeatLens builds a feature index that links natural-language feature descriptions to function-level code entities. Given a generation task, it dynamically constructs a task-specific seed graph from the feature index and applies semantic-structural graph reasoning with personalized PageRank to select a compact reasoning graph. This design replaces persistent whole-repository graph maintenance and LLM exploration with deterministic and lightweight dependency retrieval. Experiments on DevEval and EvoCodeBench show that FeatLens achieves the best DR@15 among sparse, dense, and graph-based baselines (0.501 and 0.460). On DevEval generation, it obtains the highest DIR@1, reaching 52.91\% with DeepSeek-V3.2 and 53.58\% with GPT-5-mini, while maintaining competitive Pass@1 and producing shorter code. Compared with the strongest graph-based baseline, FeatLens reduces graph nodes by 61.0\%, edges by 86.2\%, and total token overhead by 45.9\%, with no LLM tokens used during retrieval.