Efficient and Scalable Provenance Tracking for LLM-Generated Code Snippets
cs.SE, cs.AI, cs.IR
Submitted: 2026-05-27
Updated: 2026-10-08
Comments: Article accepted at The Journal of Systems & Software
License: http://creativecommons.org/licenses/by/4.0/
The gist: 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,
Terminology
Abstract
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, 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 overperforms 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, provided that their training data is made accessible...
Sources
- Evaluating Large Language Models Trained on Code
- Code Llama: Open Foundation Models for Code
- StarCoder 2 and The Stack v2: The Next Generation
- OLMoTrace: Tracing Language Model Outputs Back to Trillions of Training Tokens
- Infini-gram: Scaling Unbounded n-gram Language Models to a Trillion Tokens
- Qwen3 Technical Report
- DeepSeek-V4: Towards Highly Efficient Million-Token Context Intelligence
- PlagBench: Exploring the Duality of Large Language Models in Plagiarism Generation and Detection
- Can Watermarking Large Language Models Prevent Copyrighted Text Generation and Hide Training Data?
Related papers
- Falsification-Based Verification of LLM-Generated Optimization Models: Sound Test Batteries and Their Detection Limits
- GitSkills: A Dataset of Agent Skills on GitHub
- SABER: Benchmarking Operational Safety of LLM Coding Agents in Stateful Project Workspaces
- PackMonitor: Enabling Zero Package Hallucinations Through Decoding-Time Monitoring
- IntentCoding: Amplifying User Intent in Code Generation
- Incentives and Outcomes in Bug Bounties