arXiv:2605.28510cs.SEcs.AI2026-05

用向量搜索+指纹匹配,高效追踪大模型生成代码的来源。

Efficient and Scalable Provenance Tracking for LLM-Generated Code Snippets

  • 先用300M参数编码器做向量检索,快速缩小候选范围。
  • 再用Winnowing指纹比对,60词以上片段准确率超传统方法5.4%。
  • 适合需要版权合规的开发团队和代码审计场景。

用于代码补全与生成的大语言模型在软件开发中日益普及,但可能直接复制训练数据而未标注出处,引发抄袭与许可证合规问题。传统的基于指纹的检测方法(如Winnowing)虽有效,但在现代百亿规模训练语料下需线性时间搜索,难以实用。为此,我们提出SOURCETRACKER——一个300M参数的代码检索编码器,及混合两阶段的溯源追踪框架HYBRIDSOURCETRACKER(HST)。HST首先通过向量搜索快速定位候选片段,再用Winnowing进行精确指纹比对。我们在THESTACKV2数据集的1000万片段子集上训练评估,包含原文与模拟重命名的变体。在10万片段的测试空间中,针对30词片段,混合方法均值倒数排名媲美Winnowing;从60词及以上窗口开始,准确率持续领先达5.4%,且查询复杂度保持对数级。另通过大模型评分发现,部分非真实来源但高度相似的片段仍具实用价值,尤其在长上下文时。结果表明,向量搜索与指纹比对结合可实现高精度、可扩展的代码溯源追踪。

原文摘要 · Abstract (English)

Large language models (LLMs) for code completion and generation are increasingly used in software development, yet they may reproduce training examples verbatim and without authorship attribution, raising legal and ethical concerns around plagiarism and license compliance. Classical fingerprint-based plagiarism detectors based on fingerprinting, such as Winnowing, remain highly effective, yet the inspection requires comparing fragments of code to the entire training set, and their linear-time search makes them impractical for the billion-scale corpora used to train modern code LLMs. To bridge this gap, we introduce SOURCETRACKER, a 300M-parameter encoder tailored for code retrieval, together with a hybrid two-stage provenance-tracking pipeline HYBRIDSOURCETRACKER (HST). HST first narrows down a small set of candidate snippets via vector search, then re-ranks those candidates using Winnowing on exact fingerprints. We train and evaluate our system on a 10M-snippet subset of the THESTACKV2 dataset, with both verbatim and adapted snippets that emulate realistic identifier renaming. On an in vitro 100k-snippet search space with adapted queries, our hybrid approach reaches a mean reciprocal rank on par with Winnowing for 30-token fragments. Then, starting from windows >= 60 tokens, it consistently over-performs by up to 5.4% while preserving logarithmic-time query complexity. In a complementary evaluation using an LLM-based judge, we find that many retrieved snippets not labeled as ground truth are still highly similar to the expected sources, particularly with longer context windows, and thus remain useful for end users. Overall, our results demonstrate that integrating vector search with fingerprinting enables scalable, high-precision provenance tracking for code produced by LLMs.

代码生成溯源追踪大模型合规

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。