On the Challenges and Opportunities of Learned Sparse Retrieval for Code
Organizations: NAVER LABS Europe
Abstract
Retrieval over large codebases is a key component of modern LLM-based software engineering systems. Existing approaches predominantly rely on dense embedding models, while learned sparse retrieval (LSR) remains largely unexplored for code. However, applying sparse retrieval to code is challenging due to subword fragmentation, semantic gaps between natural-language queries and code, diversity of programming languages and sub-tasks, and the length of code documents, which can harm sparsity and latency. We introduce SPLADE-Code, the first large-scale family of learned sparse retrieval models specialized for code retrieval (600M-8B parameters). Despite a lightweight one-stage training pipeline, SPLADE-Code achieves state-of-the-art performance among retrievers under 1B parameters (75.4 on MTEB Code) and competitive results at larger scales (79.0 with 8B). We show that learned expansion tokens are critical to bridge lexical and semantic matching, and provide a latency analysis showing that LSR enables sub-millisecond retrieval on a 1M-passage collection with little effectiveness loss.
Figures & tables
Appendix figures & tables4 assets
Supplementary material from the paper’s appendix.
Appendix
| SPLADE-Code 0.6B | SPLADE-Code 1.7B | SPLADE-Code 8B | |
| Base Model | Qwen/Qwen3-0.6B | Qwen/Qwen3-1.7B | Qwen/Qwen3-8B |
| Batch size | 256 | 256 | 256 |
| Negatives per query | 8 | 7 | 7 |
| LoRA Rank | 64 | 64 | 64 |
| Max Length | 512 | 512 | 512 |
| Learning Rate |
| Dataset | SPLADE-Code-0.6B | SPLADE-Code-8B | SPLADE-EN-0.6B |
|---|---|---|---|
| Average | 45.4 | 49.7 | 48.1 |
| ArguAna | 56.4 | 59.9 | 52.3 |
| CQADupstackGamingRetrieval | 56.8 | 59.2 | 56.0 |
| CQADupstackUnixRetrieval | 40.5 | 46.7 | 37.6 |
| ClimateFEVERHardNegatives | 19.0 | 21.7 | 19.6 |
| FEVERHardNegatives | 60.8 | 66.0 | 62.2 |
| Dataset | SPLADE-Code-0.6B | SPLADE-Code-8B | SPLADE-EN-0.6B |
|---|---|---|---|
| Average | 48.3 | 54.3 | 47.0 |
| AILAStatutes | 28.1 | 32.4 | 27.7 |
| ArguAna | 56.4 | 59.9 | 52.3 |
| BelebeleRetrieval | 54.1 | 77.1 | 48.4 |
| CovidRetrieval | 73.3 | 72.7 | 78.9 |
| HagridRetrieval | 98.7 | 98.7 | 98.8 |
Learned Sparse Retrieval
Learned sparse retrieval trains models to expand queries and documents into weighted, indexable terms for efficient semantic search.
See all 18 papers