论文:代码仓库训练数据像泛基因组,去重会误删最新版本
Git History Is a Pangenome: Repetition in Code Training Corpora and What Deduplication Removes, Keeps and Misses
训练代码模型的人必看:去重管线会把一半文件的旧版本留下来,SWE-bench 答案还藏在 18 个历史版本里。作者给出了几条可直接落地的规则和工具,成本几乎为零。
一项研究测量了代码去重工具作用于仓库完整历史(而非单个快照)时的行为,样本包括预注册抽取的 306 个公开仓库、25 个成熟项目以及 SWE-bench 背后的 12 个仓库。结果显示历史数据主要是重复:典型仓库历史中当前代码平均相当于 19 份副本,成熟项目达 89 份,原因是每次编辑只改动少数行,改动文件中十分之九的 token 在改动前已存在。
精确匹配去重对这些副本完全无效,因为没有两个版本完全相同;按近似重复分组并保留一份的常规做法可将副本压缩到约 2 份。但存在两个问题:广泛使用的去重实现选择保留版本时忽略日期,导致一半文件的训练版本是旧版本,按最新优先排序即可几乎零成本修复;其次,SWE-bench 这类基准测试的 bug 修复会以中位数 18 个后续版本的形式残留在历史中,去除基准答案需要对每个版本单独检查。
作者将测量结果整理成面向在代码历史上训练模型团队的一组简短规则,并公开了测量工具和冻结输出。
Git History Is a Pangenome: Repetition in Code Training Corpora and What Deduplication Removes, Keeps and Misses
Code models are increasingly trained on the full history of software repositories, every version of every file, rather than on a single snapshot. The tools that deduplicate training data were built for snapshots, and what they do to a history has not been measured. We measured it on a pre-registered random sample of 306 public repositories, 25 mature projects, and the 12 repositories behind the SWE-bench benchmark. A history is mostly repetition: in the vocabulary of text indexing, a pangenome, one text in many near-identical variants. The history of a typical repository holds the equivalent of 19 copies of its current code, and a mature repository holds 89. The reason is that each edit changes a few lines and leaves the rest of the file in place: nine tokens in ten of a changed file already existed before the change. Exact-match deduplication removes none of these copies, since no two versions are identical. Large training pipelines already deduplicate their snapshots by grouping near-identical files and keeping one. Applied across versions, the same step brings the repetition down to about two copies. But two problems remain. The deduplicator keeps one version of each file, and in widely used implementations, including the one we measured, the rule for choosing that version ignores dates, so for half of all files the version kept for training is an old one. Sorting versions newest first before deduplicating fixes the problem at almost no cost. The second problem is benchmark answers. Benchmarks such as SWE-bench test a model on real bug fixes, and a merged fix survives in a median of 18 later versions of the files it changed. Therefore, removing benchmark fixes needs a separate step that checks every version. We turn the measurements into a short set of rules for teams that train on code history, and release the instruments and frozen outputs.
本条情报归属 AITOP「论文」核心追踪栏目。在跨区域产业观察坐标中,该动态直接关联「AI 开发者工具链、Coding Agent 与工程化实践」研究主线,反映出当前技术演进与商业落地的最新风向。涉及核心实体与技术议题包括:代码训练数据、数据去重、SWE-bench、微调,读者可通过下方标签进入对应专题页查阅历史脉络与关联对比。
信源核验说明:本文原始线索采编自「arXiv cs.LG」(@Saurabh Chopra),经 AITOP 多维评分管线结构化提炼。