paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Efficient Text-to-Code Retrieval with Cascaded Fast and Slow Transformer Models

使用级联快慢 Transformer 模型的高效文本到代码检索
FSE Proceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering2023匹配度 2/10 · 该论文研究文本到代码检索的级联快慢模型,属于ML+PL交叉中的代码搜索方向,但未涉及静态分析、Agentic程序分析、浮点程序分析、贝叶斯程序分析,也未涉及用LLM/Agent改进程序分析,与用户核心研究方向关联很弱。引用 8 inbox
Akhilesh Deepak Gotmare, Junnan Li, Shafiq Joty, Steven C.H. Hoi
crossref: 2026-09-12dblp: 2026-09-12

AI 速览

一句话:提出级联快慢模型并共享单编码器参数,实现高效且准确的文本到代码检索,在 CodeSearchNet 上取得 SOTA。

语义代码检索(文本到代码检索)旨在用自然语言查询从代码库中召回语义相关的代码片段。构建实用检索系统时,现有方法难以在检索速度与结果相关性之间取得最优平衡。本文提出一种级联快慢模型的文本到代码检索框架:先学习一个快速 transformer 编码器以构建可扩展索引完成快速召回,再训练一个基于分类的慢速重排序模型,对快速检索返回的 top-K 结果进行精排以提升准确性。为降低实际部署两个独立模型带来的高内存开销,作者进一步提出基于共享参数的单 transformer 编码器联合训练快慢模型。在 CodeSearchNet 基准的 6 种编程语言上,该级联方法平均 MRR 达 0.7795,优于此前最优的 0.744,且高效可扩展。

问题
现有语义代码检索方法难以在检索速度与召回结果相关性之间取得最优平衡,且双模型部署内存开销高。
方法
采用级联快慢架构:快速 transformer 编码器学习可扩展索引用于快速召回,慢速分类式重排序模型提升 top-K 精度,并用共享参数的单编码器联合训练两者。
评估
在 CodeSearchNet 基准的 6 种编程语言上以 MRR 为指标评估,平均达 0.7795,超过此前 SOTA 的 0.744,并验证了效率与可扩展性。
原文摘要(Abstract)

The goal of semantic code search or text-to-code search is to retrieve a semantically relevant code snippet from an existing code database using a natural language query. When constructing a practical semantic code search system, existing approaches fail to provide an optimal balance between retrieval speed and the relevance of the retrieved results. We propose an efficient and effective text-to-code search framework with cascaded fast and slow models, in which a fast transformer encoder model is learned to optimize a scalable index for fast retrieval followed by learning a slow classification-based re-ranking model to improve the accuracy of the top K results from the fast retrieval. To further reduce the high memory cost of deploying two separate models in practice, we propose to jointly train the fast and slow model based on a single transformer encoder with shared parameters. Empirically our cascaded method is not only efficient and scalable, but also achieves state-of-the-art results with an average mean reciprocal ranking (MRR) score of 0.7795 (across 6 programming languages) on the CodeSearchNet benchmark as opposed to the prior state-of-the-art result of 0.744 MRR. Our codebase can be found at this link.

链接与引用

DOI 原文 · PDF(开放获取) · DBLP

BibTeX
@inproceedings{Gotmare0JH23,
  title = {Efficient Text-to-Code Retrieval with Cascaded Fast and Slow Transformer Models},
  author = {Akhilesh Deepak Gotmare and Junnan Li and Shafiq Joty and Steven C.H. Hoi},
  booktitle = {FSE},
  year = {2023},
  doi = {10.1145/3611643.3616369}
}