arXiv:2610.11727cs.SEOct 2026

Manuscript Offprint

arXiv:2610.11727

MAP4CS: A Multi-dimensional Data Pruning Framework for Efficient Code Retriever Fine-tuning

Yuxuan Chen, Mingwei Liu, Guangsheng Ou, Zekai Zhang, Zike Li, Yanlin Wang, Pelin Zheng

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original. This text is shared under the same licence.

YUXUAN CHEN, School of Software Engineering, Sun Yat-sen University, China

MINGWEI LIU*, School of Software Engineering, Sun Yat-sen University, China

GUANGSHENG OU, School of Software Engineering, Sun Yat-sen University, China

ZEKAI ZHANG, School of Software Engineering, Sun Yat-sen University, China

ZIKE LI, School of Software Engineering, Sun Yat-sen University, China

YANLIN WANG, School of Software Engineering, Sun Yat-sen University, China

PEILIN ZHENG, School of Software Engineering, Sun Yat-sen University, China

Retrieval-Augmented Generation (RAG) has become a cornerstone in software engineering for enhancing Large Language Models (LLMs) with domain-specific knowledge. However, adapting retrievers to evolving code repositories remains challenging due to the noise and redundancy inherent in massive code corpora. Standard fine-tuning on the full corpus is computationally expensive and often leads to sub-optimal performance due to negative transfer from low-quality samples. Conversely, simple random sampling fails to guarantee data representativeness.

To address these challenges, we propose MAP4CS (Multi-dimensional Awareness Pruning for Code Search), an adaptive data pruning framework. MAP4CS identifies a small, high-quality core subset by integrating syntactic structure, semantic diversity, and distributional representation, followed by a rigorous rule-based filtering pipeline. Extensive experiments on two large-scale datasets demonstrate that MAP4CS consistently outperforms random sampling baselines using only 5% of the training data. Remarkably, it achieves performance comparable to, or even superior to, fine-tuning on the full dataset, validating the “less is more” hypothesis in data-centric AI. Furthermore, linguistic analysis reveals an adaptive optimization mechanism: MAP4CS automatically functions as a de-duplicator for redundant corpora and a denoiser for chaotic ones, constructing a training corpus that is both lexically diverse and information-dense.

CCS Concepts: • Software and its engineering → General programming languages; • Computing methodologies → Natural language processing; • Information systems → Information retrieval.

Additional Key Words and Phrases: Code Search, Retrieval-Augmented Generation, Data Pruning, Large Language Models

∗^{*}Corresponding author.

Authors' Contact Information: Yuxuan Chen, School of Software Engineering, Sun Yat-sen University, Zhuhai, China, chenyx677@mail2.sysu.edu.cn; Mingwei Liu, School of Software Engineering, Sun Yat-sen University, Zhuhai, China, liumw26@mail.sysu.edu.cn; Guangsheng Ou, School of Software Engineering, Sun Yat-sen University, Zhuhai, China, ougsh3@mail2.sysu.edu.cn; Zekai Zhang, School of Software Engineering, Sun Yat-sen University, Zhuhai, China, zhangzk27@mail2.sysu.edu.cn; Zike Li, School of Software Engineering, Sun Yat-sen University, Zhuhai, China, lizk8@mail2.sysu.edu.cn; Yanlin Wang, School of Software Engineering, Sun Yat-sen University, Zhuhai, China, yanlin-wang@outlook.com; Peilin Zheng, School of Software Engineering, Sun Yat-sen University, Zhuhai, China, zhengplin@mail.sysu.edu.cn.

Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from permissions@acm.org.

© 2026 Copyright held by the owner/author(s). Publication rights licensed to ACM.

Chen et al.

ACM Reference Format:

Yuxuan Chen, Mingwei Liu, Guangsheng Ou, Zekai Zhang, Zike Li, Yanlin Wang, and Peilin Zheng. 2026. MAP4CS: A Multi-dimensional Data Pruning Framework for Efficient Code Retriever Fine-tuning. ACM Trans. Softw. Eng. Methodol. XX, X, Article XXX (June 2026), 24 pages. https://doi.org/XXXXXXX.XXXXXXX

1 Introduction

The advent of Large Language Models (LLMs) has fundamentally reshaped the landscape of software engineering, empowering automated tools for code completion, summarization, and synthesis [63, 64]. Despite their impressive capabilities, off-the-shelf LLMs often struggle with domain-specific software repositories, particularly when dealing with private enterprise libraries, evolving APIs, or legacy systems that were not part of their pre-training data [60]. To mitigate limitations such as hallucinations and knowledge cutoffs, Retrieval-Augmented Generation (RAG) has emerged as a pivotal paradigm [30, 43]. By retrieving relevant code snippets from an external knowledge base to serve as context, RAG significantly enhances the accuracy and reliability of generated code [30, 60]. Consequently, the performance of the neural code retriever becomes the bottleneck of the entire pipeline [24].

Regrettably, generic code retrievers often exhibit sub-optimal performance in these specialized software domains due to a lack of exposure to relevant proprietary knowledge during pre-training. To adapt general-purpose retrievers to these domains, fine-tuning on domain-specific corpora is essential [5]. This process typically involves extracting pairs of “Natural Language Query” and “Code Snippet”, denoted as (Q,C)(Q, C), from the target repositories [23]. The model is then fine-tuned on these sample pairs to align the embedding space of the retriever with the specific coding standards and business logic of the target domain [13].

A common practice in the industry is to fine-tune models on the full available corpus to maximize knowledge coverage [27, 35]. However, blindly utilizing all data presents a critical trade-off between efficiency and effectiveness. First, the “Noise Toxicity” Problem: Real-world code repositories are fraught with noise, such as redundant boilerplate code, low-quality auto-generated comments, and deprecated functions [1, 28]. Training on such data can lead to negative transfer, where the retriever overfits to superficial lexical overlaps rather than learning robust semantic representations [6]. Second, the Computational Barrier: The sheer scale of industrial repositories makes full-corpus fine-tuning computationally prohibitive and environmentally costly [49], creating a significant barrier for frequent updates in continuous integration (CI) environments.

To reduce training costs, a straightforward alternative is Random Sampling [38, 48]. While this decreases fine-tuning time, this content-agnostic strategy is flawed for code search tasks. It often leads to the Loss of Long-Tail Knowledge, discarding crucial but infrequent domain-specific APIs [20], while simultaneously suffering from the Retention of High-Entropy Noise, preserving misaligned pairs that confuse the model's decision boundaries [59]. Thus, neither full-data training nor random sampling offers a viable path for efficient and effective domain adaptation.

This dilemma poses a central research question: Is it possible to intelligently identify a small, high-quality subset of data that trains a better code retriever than the full corpus? While data pruning has shown promise in general NLP, directly applying these text-centric methods to code retrieval is insufficient. As we will discuss in Section 2, generic filtering often ignores the unique structural dependencies of code, while traditional software engineering approaches tend to focus on defensive filtering to remove noise, rather than selecting samples with high syntactic and semantic value.

To address these challenges, we propose MAP4CS (Multi-dimensional Awareness Pruning for Code Search), an adaptive data pruning framework designed specifically for efficient retriever fine-tuning. Unlike rigid filtering rules Manuscript submitted to ACM

Creates an UnicastSubject with an internal buffer capacity hint 16. @param the value type @return an UnicastSubject instanceQuery
UnicastSubjec create() { return new UnicastSubject(bufferSize(), true); }Ground TruthUnicastSubject create(int capacityHint) { return new UnicastSubject(capacityHint, true); }Random Top1 Result
SimMAP4CS≈0.86\text{Sim}_{\text{MAP4CS}} \approx 0.86SimMAP4CS≈0.69\text{Sim}_{\text{MAP4CS}} \approx 0.69
SimRandom≈0.63\text{Sim}_{\text{Random}} \approx 0.63SimRandom≈0.64\text{Sim}_{\text{Random}} \approx 0.64

Fig. 1. Motivation Example 1 (Semantic Gap): The baseline model is misled by the explicit keyword “capacity hint” in a distractor method. In contrast, training with diverse semantic strata helps identify the Ground Truth which handles this logic implicitly.

or general-purpose scorers, MAP4CS treats data selection as a multi-objective optimization problem within local semantic contexts. It operates through a rigorous coarse-to-fine pipeline: First, it structures the chaotic code corpus using Stream-Based Semantic Clustering to localize diversity and isolate noisy regions. Second, it evaluates samples via a Multi-Metric Scoring mechanism, integrating Syntactic Structural Diversity, Semantic Alignment Consistency, and Distributional Representativeness. Finally, a cascade filtering and sampling strategy selects the core subset. This multi-dimensional awareness allows MAP4CS to adaptively function as a “de-duplicator” for redundant corpora, a “denoiser” for chaotic datasets, and a “structure-preserver” for complex logic.

To evaluate MAP4CS, we conduct extensive experiments on two large-scale datasets, CSN-Java and Query4Code, using both code-specialized (UniXcoder [15]) and general-purpose (GTE base_{base} [61]), and foundation-model-based (Qwen3-Embedding [62]) dense encoders, alongside BM25 as a lexical baseline. The results demonstrate that using only 5% of the training data, MAP4CS consistently outperforms random sampling baselines across all dense encoders and, remarkably, achieves comparable or even superior performance to fine-tuning on the full dataset. For instance, on the CSN-Java dataset, MAP4CS improves the retrieval MRR by 31.9% over random sampling with UniXcoder and by 45.5% with Qwen3-Embedding, highlighting the “less is more” phenomenon in data-centric AI.

In summary, this paper makes the following contributions:

  • We introduce MAP4CS, a multi-dimensional pruning framework tailored for code search that selects high-value samples by integrating syntactic structure, semantic alignment, and distributional density.

  • We propose an adaptive selection mechanism that effectively resolves the data scale-quality trade-off by filtering high-entropy noise while maximizing sample diversity.

  • Extensive experiments demonstrate that MAP4CS reduces training costs by over 90% while achieving performance comparable to or superior to full-dataset fine-tuning, validating the “less is more” hypothesis.

References (23)