<p>In the domain of code search, Generation-Augmented Retrieval (GAR) enhances retrieval by generating example code to bridge the gap between natural language queries and code snippets. However, existing GAR methods still suffer from reduced accuracy when faced with style discrepancies between generated and real-world code, or when query intent is ambiguous. To address these limitations, we propose MeCo (Meta-Enhanced Code)—an advanced extension of the GAR framework that integrates structural and functional features to better align query intent with target code. MeCo leverages large language models (LLMs) to generate example code and extract structural features, including Abstract Syntax Trees (ASTs), Data Flow Graphs (DFGs), and Control Flow Graphs (CFGs), from both generated and repository code. Concurrently, MeCo uses few-shot prompting to produce retrieval points that represent functional intent, applied to both queries and code snippets. These are combined into augmented query and code representations, enabling finer-grained semantic alignment. MeCo significantly improves retrieval performance by addressing both modal and stylistic gaps. Experimental results show up to 27.9% improvement in zero-shot and 9.7% in fine-tuned settings over traditional GAR. Compared to the latest ReCo framework, MeCo yields gains of up to 21.2% in dense zero-shot retrieval and 2.2% in fine-tuning, all while requiring only a single generation step, demonstrating both its efficiency and effectiveness. These results confirm that MeCo’s integration of structural and functional features enhances the precision and contextual relevance of cross-modal code retrieval.</p>

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Meta-enhanced code: leveraging structural and functional features for precise cross-modal code search

  • Le Yuan,
  • Shaohua Liu,
  • Yu Wang,
  • Shangwei Zhu,
  • Tao Wang,
  • Tianlu Mao,
  • Songbo Shao

摘要

In the domain of code search, Generation-Augmented Retrieval (GAR) enhances retrieval by generating example code to bridge the gap between natural language queries and code snippets. However, existing GAR methods still suffer from reduced accuracy when faced with style discrepancies between generated and real-world code, or when query intent is ambiguous. To address these limitations, we propose MeCo (Meta-Enhanced Code)—an advanced extension of the GAR framework that integrates structural and functional features to better align query intent with target code. MeCo leverages large language models (LLMs) to generate example code and extract structural features, including Abstract Syntax Trees (ASTs), Data Flow Graphs (DFGs), and Control Flow Graphs (CFGs), from both generated and repository code. Concurrently, MeCo uses few-shot prompting to produce retrieval points that represent functional intent, applied to both queries and code snippets. These are combined into augmented query and code representations, enabling finer-grained semantic alignment. MeCo significantly improves retrieval performance by addressing both modal and stylistic gaps. Experimental results show up to 27.9% improvement in zero-shot and 9.7% in fine-tuned settings over traditional GAR. Compared to the latest ReCo framework, MeCo yields gains of up to 21.2% in dense zero-shot retrieval and 2.2% in fine-tuning, all while requiring only a single generation step, demonstrating both its efficiency and effectiveness. These results confirm that MeCo’s integration of structural and functional features enhances the precision and contextual relevance of cross-modal code retrieval.