Code LLMs can reproduce target functions even when text differs
Olmo-3-32B exhibits functional memorization of code it was exposed to during training
AI/ML arXiv 11 Jun 2026 Measurement Prototype evidence
Published as “Detecting Functional Memorization in Code Language Models”
Why it matters
Auditing code LLMs requires functional similarity checks beyond token overlap to detect proprietary logic leakage.
Summary
Functional memorization occurs in code LLMs: 3.9% of generated functions are functionally similar to training data under a conservative LLM-judge, but only 0.28% pass strict execution-based verification. Midtraining consistently raises similarity across all metrics, and near-verbatim memorization is also observed. However, many functional detections are noisy, AST parsing fails on many samples, and execution tests miss most cases, limiting confidence in the headline rates.
What they found 8
- 3.9% of samples are functionally memorized under the most conservative LLM-judge (BLEU < 0.75).
“we observe functional memorization at a similar order of magnitude, with 3.9% of samples counterfactually functionally memorized under our most conservative LLM-judge (with BLEU< 0.75).”
- Execution-based testing finds 0.28% of generations functionally identical to training data.
“execution-based testing finds that 0.28% of the generations are functionally identical to a training-data function.”
- Midtraining increases similarity across all metrics; all deltas are positive.
“All deltas (∆) are positive, confirming that exposure during midtraining systematically increases similarity across every metric-from text overlap to execution-based functional equivalence.”
- Target model produces 17 exact (0.23%) and 116 near-verbatim (1.56%) matches, while reference model also produces some matches.
“We find that the target model produces 17 (0.23%) exact matches and 116 (1.56%) near-verbatim completions (BLEU ≥0.75, following Ippolito et al. (2023)).”
- Reference model (unexposed) still produces 12 exact and 85 near-verbatim completions.
“the reference model, which has not seen the CraneCode data, already produces 12 exact and 85 near-verbatim completions.”
- 8 functions (0.11%) are counterfactually memorized exactly; 43 (0.58%) are counterfactually near-verbatim.
“we find that 8 (0.11%) functions are counterfactually memorized exactly (the target produces a verbatim match, the reference does not)”
- CodeBLEU data-flow flags 130 functions (1.8%) as counterfactually memorized.
“CodeBLEU’s data-flow component flags 130 functions (1.8%) as counterfactually memorized at τfunc = 0.75”
- HyClone execution verification yields 21 pairs (0.28%) as functional clones.
“21 pairs (0.28%) are counterfactually execution-verified: the target model produces a functional clone (similarity ≥0.75) while the reference model does not (similarity < 0.75).”
Caveats 6
- Only 0.28% of generations are confirmed by strict execution-based testing, far lower than the 3.9% reported by the LLM-judge.
- Structural metrics produce noisy scores and false positives, especially for short or attribute-heavy functions.
- AST parsing fails for 1,114 of 7,422 generated samples, limiting the applicability of CodeBLEU and TSED.
- Many Stage-1 HyClone clones fail to execute due to dependencies on class state, unavailable packages, file I/O, or global variables.
- they can produce noisy scores and false positives when functions are short, dominated by print or plot statements, or consist primarily of attribute assignments (e.g., self.x =). They also require successful AST parsing, which fails for 1,114 of our 7,422 generated samples.
- Stage-1 clones fail to execute because functions depend on class state (self), unavailable packages, file I/O, or global variables (details in Appendix B.2).
What’s new here 3
- Introduces a counterfactual experimental setup using a midtrained target model versus a pretrained reference model to isolate memorization.
- Evaluates functional memorization with a suite of metrics beyond text overlap, including structural code similarity, LLM-as-a-judge scores, and execution-based clone detection.
- Provides quantitative estimates of functional leakage (up to 3.9% by LLM-judge, 0.28% by execution) for an open-source code LLM.