atlas

Research map / Large language models / Retrieval and knowledge

Repoformer: Selective Retrieval for Repository-Level Code Completion

ICML 2024 · Large language models › Retrieval and knowledge · approach: RAG robustness and evaluation · 3 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Proposes Repoformer, a StarCoderBase-based code LM fine-tuned with a self-supervised multi-task objective to self-decide whether cross-file retrieval is worth triggering for repository-level code completion, improving accuracy and cutting latency.

Problem

Always-on retrieval augmentation for repository-level code completion is often unhelpful or harmful to code LMs and adds substantial inference latency.

Approach

A code LM is trained to emit a special <cc> token to self-trigger retrieval, with labels mined from public repositories by contrasting generation quality with and without retrieved context; a joint loss trains both the self-assessment and robust RAG generation, so the same model acts as selective policy and generator in a single forward pass.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
use Repoformer threshold-selective retrieval instead of always retrievingStarCoderBase-16B · RepoEval APIES: 74.50 -> 77.93Helped
use Repoformer threshold-selective retrieval instead of always retrievingStarCoderBase-16B · CrossCodeLongEval ChunkES: 71.90 -> 75.50Helped
use threshold selection instead of greedy selectionRepoformer-1B · RepoEval APIES: 71.00 -> 72.70Helped
use greedy selection instead of always retrievalRepoformer-1B · RepoEval APIES: 72.02 -> 71.04Hurt
use threshold selection instead of always retrievalRepoformer-1B · RepoEval APIspeedup: 0% -> 28%Helped
use Repoformer-1B as a selective retrieval policy for the larger generation modelStarCoderBase-7B · RepoEval APIES: 73.65 -> 74.10Helped
remove self-evaluation loss (ablation)Repoformer-1B · CrossCodeLongEval ChunkES: 69.97 -> 70.45Helped
remove self-evaluation loss (ablation)Repoformer-1B · CrossCodeLongEval FunctionES: 53.71 -> 53.90Helped
add retrieved contexts to training (ablation)A2 (without self-evaluation loss) · CrossCodeLongEval ChunkES: 68.85 -> 70.45Helped
add retrieved contexts to training (ablation)A2 (without self-evaluation loss) · CrossCodeLongEval FunctionES: 52.12 -> 53.90Helped
place retrieved contexts in the input context rather than after fim_middle (ablation)A4 · CrossCodeLongEval FunctionES: 26.35 -> 53.56Helped
combine self-evaluation and generation losses as a single cross-entropy loss (ablation)Repoformer-1B · CrossCodeLongEval ChunkES: 69.97 -> 70.21Helped

Surprising findings

Limitations

Experimental setup

Datasets: The Stack RepoEval CrossCodeEval

Benchmarks: RepoEval CrossCodeLongEval CrossCodeEval

Metrics: exact match edit similarity unit test pass rate identifier F1 speedup retrieval ratio

Baselines: StarCoderBase always retrieving StarCoder always retrieving No retrieval CodeGen-Mono Code Llama CodeGen25 ChatGPT

Builds on: StarCoder ContraCLM fill-in-the-middle RG-1

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy