acceptodds
Under review as a conference paper at ICLR 2027

Detecting Functional Memorization in Code Language Models

Abstract

Large language models (LLMs) are increasingly used to generate code at scale. Meanwhile, prior work has investigated whether training data may be recoverable from model outputs, by auditing the textual overlap between training examples and model generations. Code, however, can be functionally equivalent while textually dissimilar-so when models are trained on code one wishes to protect, they may leak its logic in ways that textual audits cannot detect. We here study this *functional memorization*: we leverage AI coding agents to generate diverse test inputs for training data functionality and evaluate whether model-generated continuations produce the same outputs. We formalize this through a *counterfactual* framework, comparing target models (exposed to specific code) against reference models (not exposed) and requiring functional equivalence only for the target. We instantiate this across 4 open-source models and explicitly filter for functions with meaningful logic in 5 programming languages. We find that 0.3-3.4% of functions are counterfactually functionally memorized, i.e., reproduced with equivalent behavior in restructured code that textual metrics fail to detect. We further show that LLM-based judges offer a scalable proxy for execution-based testing, achieving a true positive rate of 68% at 1% false positive rate, and find that functional memorization is associated with semantic duplication in the training corpus.

Primary area:
alignment, fairness, safety, privacy, and societal considerations
Keywords:
Memorization, code, language models

Reviews

Among:
Shape:
1234this paper, Top 15%
Figure 1. Mean review rating of the reviewed papers at ICLR 2027. This paper averages 3.00 over 3 reviews, above 85% of the others.
Reviewer_kqzYOpenReview ↗
Rating
3
Confidence
3
Informativeness
2
Presentation
3
Soundness
2
Read review
Paper summary

This paper studies functional memorization in code language models, where models reproduce the behavior of training functions despite low textual overlap. It proposes an agent-based execution framework and evaluates the phenomenon across four open-source models and five programming languages, together with proxy detection methods, duplication analyses, and post-training mitigation methods.

Critical strengths
  • The research topic is interesting and valuable.
  • The paper presents a clear direction for auditing code-model memorization beyond textual overlap and provides evidence across multiple models and programming languages.
Critical weaknesses
  • The current experiments are closer to an audit of known training samples, representing a somewhat limited range of real-world leakage scenarios. The experiments provide the model with the exact function signature and up to 250 tokens of preceding code, meaning that the auditor already possesses substantial context about the target code.

  • Differences between the reference model and the target model cannot be attributed solely to the target function’s exposure during training. The paper constructs approximate counterfactual controls using earlier and later training checkpoints. The two models differ by an entire training phase rather than only by the specific function being audited. The target model might generate a functionally similar completion more easily because of an overall improvement in coding capability.

Questions for authors
  • With a target of 10 agent-generated inputs per function, achieving 80% line coverage does not guarantee that critical branches and edge cases are tested. A small number of hard-coded rules might pass these inputs, while complex functions could be misclassified because of uncovered paths. How do the authors address the risk of misclassification caused by untested branches and edge cases?

  • Approximately 10% of functions fail to receive a conclusive score, and this figure rises to about 20% for Rust. Functions with complex dependencies, extensive state, or structures resembling real-world projects may be more likely to be excluded. The memorization risk associated with these functions may differ from that of the retained samples. Could the authors compare the length, number of dependencies, and code complexity of conclusive and inconclusive samples, and report the range of results obtained when treating inconclusive samples as either positive or negative cases?

  • The proxy detection experiments evaluate functional similarity rather than the full definition of counterfactual functional memorization. These experiments use a binary label based solely on whether the execution similarity between the target-model generation and the original function reaches 0.8. They do not incorporate the reference-model comparison or the low-textual-similarity condition into this label. How should these proxy results be interpreted in relation to the paper’s definition of counterfactual functional memorization?

  • The cross-agent consistency of the execution-based evaluations is insufficient to demonstrate the stability of the final memorization rate. Although the correlations between the continuous scores produced by different agents range from approximately 0.74 to 0.82 in Figure 8, the paper’s final conclusions rely on binary labels derived from a threshold of 0.8. High correlation can still mask substantial reclassification of samples near the threshold. Could the authors report label agreement across agents, variations in the final memorization rates, and fluctuations observed when the same samples are evaluated repeatedly?

  • The experiments exploring the relationship between semantic duplication and functional similarity with low textual overlap support only a correlational relationship. The number of semantic near-duplicates may covary with factors such as function popularity, code length, project scale, degree of templating, and frequency of occurrence during training. The existing logistic regression analyses do not adequately control for these factors. The paper proposes semantic deduplication as a mitigation strategy, but the supporting evidence remains incomplete. Could the authors conduct matching analyses or control for additional function attributes? A more direct validation would involve retraining small-scale models on corpora with and without semantic deduplication and comparing their functional memorization rates.

  • The reported memorization rates lack sufficient uncertainty estimates. Functional memorization rates range from only 0.3% to 3.4%, and the number of positive instances is small in some settings, yet Figure 2 does not provide confidence intervals. Generation uses a single greedy completion, while execution testing involves agent-based randomness. Consequently, observed differences across models, languages, and model scales may be affected by measurement variability. How do the authors assess the uncertainty in the reported memorization rates and the differences across models, languages, and model scales?

  • The post-training experiments demonstrate output suppression on known samples, which cannot be directly equated with forgetting the underlying logic. NPO and DPO are trained on the 275 identified functions, and the reduction in memorization is subsequently measured on those same functions. The model might simply stop generating the original implementation from the same prefixes while retaining the associated logic. What evidence distinguishes output suppression on these known samples from forgetting the underlying logic?

  • The description of the DPO-rewrite method is inconsistent. The main text states that the method uses “functionally equivalent rewrites” as preferred completions, whereas the prompt in the appendix requires code with different functionality and the filtering criteria require an execution similarity score of no more than 0.2. These settings represent fundamentally different training objectives. Could the authors reconcile the main text, prompt, and experimental description, and clarify which construction was used to produce Figures 13 and 14?

3 comments
AuthorsOpenReview ↗

Response to review (1/3)

We thank the reviewer for their feedback and time spent on the paper. We now answer the questions and weaknesses raised and aim to update the PDF by the end of the discussion phase.

The current experiments are closer to an audit of known training samples

We agree that our setup assumes a "strong" auditor with access to the exact context preceding the function. This is a deliberate design choice: a model developer or data owner checking whether functional logic leaks should estimate the worst case, and this is the standard "discoverable" memorization setup in the extraction literature (Carlini et al., 2023; Ippolito et al., 2023; Nasr et al., 2025). This does not imply that the same rates would hold in real-world leakage scenarios, where users or adversaries typically have less context. We will further clarify this in Section 6.

Differences between the reference model and the target model cannot be attributed solely to the target function’s exposure during training

Thank you for raising this important point. It is something we acknowledge in the limitations (Section 6, "our counterfactual is not a perfect leave-one-out version of the target…"), but are happy to discuss further.

In short:

  1. We agree that an exact leave-one-out counterfactual would give a strong signal, but it is infeasible at this scale and not noise-free, as training data contains many verbatim and semantic near-duplicates.
  2. Our use of a reference model and a counterfactual criterion is already stricter than most extraction studies. Our checkpoint-based reference follows prior work and reflects a practical audit.
  3. Beyond the reference model, our prompt and evaluation design already aim to separate memorization from generalization.
  4. In a new experiment, we train a new reference model on deduplicated training data and find the measured memorization to be reduced but certainly not removed, so our main conclusion holds.

For more details on each of these points, we refer to our rebuttal to reviewer nPAM.

How do the authors address the risk of misclassification caused by untested branches and edge cases?

We agree that measuring functional equivalence through execution comes with its limitations. It depends on the diversity and coverage of the inputs the agent generates, and a generation that reproduces only some execution paths may still leak meaningful logic. This can lead to false positives or false negatives, while the true label is also nuanced and likely context dependent. We acknowledge this in Section 6, noting that there is likely no single correct threshold, and we report ablations across thresholds (Fig. 7) and across models and agentic harnesses (Fig. 8).

We have now also added two direct checks:

  • line and branch coverage of the training functions is 0.95–0.99 on average in every language (see our response to Reviewer rUQA).
  • More inputs: we re-tested all 44 flagged functions in Python (CC) for OLMo-3-32B with 30 additional inputs each. 39 keep their label, and the 5 that lose it were already borderline (S_target = 0.80–0.91; see our response to Reviewer nPAM).

Could the authors compare the length, number of dependencies, and code complexity of conclusive and inconclusive samples?

We compared conclusive and inconclusive functions (OLMo-3-32B) on length (lines of code), code complexity (cyclomatic complexity) and number of dependencies (distinct functions called):

Mean, conclusive / inconclusivePython (CC)Python (SE)CJavaRustGo
Lines of code20.5 / 21.918.8 / 20.124.6 / 26.922.9 / 24.321.8 / 22.023.1 / 23.8
Cyclomatic complexity4.5 / 3.96.2 / 6.46.1 / 6.15.7 / 5.35.0 / 3.25.4 / 4.8
N dependencies8.6 / 9.55.4 / 5.83.5 / 4.27.4 / 8.27.2 / 7.46.6 / 7.5

Inconclusive functions are only marginally longer and are not more complex, but they do call somewhat more external functions. This suggests that a function ends up inconclusive because its dependencies are harder to control.

AuthorsOpenReview ↗

Response to review (2/3)

report the range of results obtained when treating inconclusive samples as either positive or negative cases?

Between 6.7% and 10.3% of functions are inconclusive (and 20.1% for Rust). We deliberately leave them out of the memorization rates, as we prefer to report only functions for which the execution test gives reliable evidence. Counting all inconclusive functions as not memorized would give 0.9–3.1% instead of the reported 1.0–3.4%. Counting all of them as memorized would give 9.6–21.8%, yet this is unlikely to be a fair approximation.

For a more principled estimate, we label the inconclusive functions with our LLM judge (LLaMA-3.3-70B, "Ours"). We set the judge's threshold on the conclusive functions so that its FPR against the execution labels is at most 5%. An inconclusive function then counts as memorized if the LLM judge marks the target as equivalent, not the reference, and BLEU < 0.75. This gives rates close to those we report:

Rate (%)Python (CC)Python (SE)CJavaRustGo
Reported (conclusive only)1.03.33.41.73.41.7
All inconclusive = not memorized0.93.13.01.52.71.6
All inconclusive = memorized10.59.612.311.721.811.1
Inconclusive labelled by LLM judge1.13.23.21.73.01.7

How should these proxy results be interpreted in relation to the paper’s definition of counterfactual functional memorization?

Measuring SIM_func through execution based testing is the only expensive part of computing functional memorization, and we do it for both the target and reference model. Section 5.2 therefore evaluates how well cheaper metrics approximate this step, while condition (2) in Section 3 is a cheap textual check.

To test the proxies end-to-end, we also applied our LLM judge (LLaMA-3.3-70B, "Ours") to the reference model's generations and computed a judge-only counterfactual memorization rate: the judge marks the target as equivalent, not the reference, and BLEU < 0.75. The judge's threshold is calibrated on held-out functions so that it flags as many generations as the execution test does.

Python (CC)Python (SE)CJavaRustGo
Execution-based rate (%)1.03.33.41.73.41.7
LLM-judge-only rate (%)0.72.73.31.43.32.1
Cohen's κ, judge vs. execution label per function0.440.320.330.380.190.31

As expected with the threshold calibration, the judge reproduces the aggregate rates well. Per function, however, its agreement with execution is limited (κ = 0.19–0.44), partly because its errors on the target and reference generations compound. We note that this is a first, untuned instantiation and expect a reliable end-to-end judge would require careful iteration on the model, prompt and thresholds, which we see as a promising direction for future work.

report label agreement across agents, variations in the final memorization rates, and fluctuations observed when the same samples are evaluated repeatedly?

As mentioned in Appendix D, we also ran the execution-based test with four different models and agentic harnesses: Claude Code with Opus-4.7 (main), Opus-4.6 and Sonnet-4.6, and Codex with GPT-5.5. For every pair we now compute Cohen's κ between their labels on the functions that both found conclusive, for the target label (S_target ≥ 0.8) and for the counterfactual memorization label.

AgentsFunctionsκ, target labelκ, counterfactual memorization label
Opus-4.7 vs. Opus-4.64,3690.760.77
Opus-4.7 vs. Sonnet-4.64,1830.770.73
Opus-4.7 vs. Codex GPT-5.54,2720.690.63
Opus-4.6 vs. Sonnet-4.64,3780.730.73
Opus-4.6 vs. Codex GPT-5.54,4800.760.64
Sonnet-4.6 vs. Codex GPT-5.54,2730.740.65

The agreement is substantial (κ = 0.63–0.77) and the highest among the Claude Code agents. It increases with stricter thresholds: for the target label, pairwise κ rises from 0.57–0.72 at τ = 0.5 to 0.77–0.83 at τ = 1.0.

The resulting counterfactual functional memorization rates are (with 95% Wilson confidence intervals).

AgentConclusive functionsMemorization rate % [95% CI]
Claude Code, Opus-4.7 (main)90.2%0.98 [0.73, 1.31]
Claude Code, Opus-4.694.6%0.93 [0.69, 1.25]
Claude Code, Sonnet-4.690.1%0.82 [0.60, 1.13]
Codex, GPT-5.593.3%0.54 [0.36, 0.79]

To measure run-to-run variation of a single agent, we also re-ran the main agent (Claude Code, Opus-4.7) on 500 Python (CraneCode) functions for OLMo-3-32B: all 44 memorized ones and 456 random others. The two runs agree closely (κ = 0.83 for the memorization label), and the disagreements stem mostly from borderline scores.

Overall, while the absolute rate varies somewhat with the agentic harness and the run, we find functional memorization to be detected consistently.

AuthorsOpenReview ↗

Response to review (3/3)

Could the authors conduct matching analyses or control for additional function attributes?

We agree that our logistic regression may omit relevant covariates, so it supports only an association and not a causal link. Adding covariates that we can easily compute (such as function length) could reduce confounding but not really eliminate it. As any causal claim would ultimately require controlled experiments that retrain models on corpora with and without semantic deduplication, as the reviewer suggests, we leave this to future work.

We will rephrase Section 5.3 to describe the observed association without implying causality and to present semantic deduplication as a hypothesis to test rather than a recommended mitigation.

The reported memorization rates lack sufficient uncertainty estimates.

We already provide ablations for the randomness from the agentic execution, including different similarity thresholds (Figure 7), models and harnesses (Figure 8).

Yet, we now also report uncertainty for all rates. We split the execution-tested functions of each setup into 5 disjoint random subsets and report the mean ± standard deviation across splits, averaged over 100 random partitions. We also report 95% Wilson confidence intervals on the full-sample rate.

SubsetOLMo-3-32BOLMo-3-7BStarCoder-15BCrystalCoder-7B
Python (CC)1.0 ± 0.3 [0.7, 1.3]0.7 ± 0.3 [0.5, 1.0]
Python (SE)3.3 ± 0.5 [2.8, 3.8]2.2 ± 0.4 [1.8, 2.7]
C3.4 ± 0.6 [2.9, 3.9]2.8 ± 0.5 [2.3, 3.3]
Java1.7 ± 0.4 [1.4, 2.1]1.5 ± 0.4 [1.2, 1.9]
Rust3.4 ± 0.8 [2.7, 4.2]2.3 ± 0.7 [1.7, 3.0]
Go1.7 ± 0.5 [1.3, 2.2]1.0 ± 0.4 [0.7, 1.4]
Python0.3 ± 0.2 [0.2, 0.5]0.5 ± 0.2 [0.3, 0.8]

Our main findings hold under this uncertainty. All intervals exclude zero, so functional memorization occurs in every setup. Stack-Edu rates exceed CraneCode rates for both OLMo models, with non-overlapping intervals. OLMo-3-32B also has a higher point estimate than OLMo-3-7B on all six subsets, although the intervals overlap everywhere except Python (Stack-Edu). We will add these intervals to Fig. 2.

What evidence distinguishes output suppression on these known samples from forgetting the underlying logic?

We explicitly refrained from using the term “unlearning/forgetting” when applying post-training methods as mitigation techniques. We believe our method does not adequately remove knowledge about training data functions from the model, but rather teaches it to suppress output. We will change the corresponding framing.

Could the authors reconcile the main text, prompt, and experimental description, and clarify which construction was used to produce Figures 13 and 14?

Sec. 5.3 indeed does not use the correct wording, and Appendix I is correct: the preferred completions should be functionally valid but functionally different rewrites, filtered to BLEU ≤ 0.3 and execution similarity ≤ 0.2. Figures 13 and 14 use this construction. A functionally equivalent preferred completion would reinforce exactly the logic we aim to suppress. We will fix Sec. 5.3 accordingly.

Reviewer_nPAMOpenReview ↗
Rating
3(+1)
Confidence
3
Informativeness
2
Presentation
3
Soundness
2
Read review
Paper summary

The paper studies whether code models reproduce the behavior of functions seen during training while writing different code. It compares models before and after further training and tests their generated code on automatically chosen inputs. Its method classifies 0.3–3.4% of the evaluated functions as functionally memorized. The paper also evaluates whether another LLM can judge behavioral similarity without running the code. It finds that functions with more similar implementations in the training data are more often reproduced.

Critical strengths

The paper addresses an important gap in memorization auditing: a model can reproduce specific rules without copying the original code. Its examples make this problem concrete. Experiments across several models and programming languages provide broader evidence of this behavior.

Critical weaknesses

One major concern is that the reported memorization rates may include cases of generalization. The paper counts a function as memorized when the target model reproduces its behavior but the earlier reference model cannot. However, additional training could teach the target model how to solve that type of problem without seeing the particular function being tested. Such a case would satisfy the paper’s criterion even though the model did not memorize that function. Another concern is that the execution tests may label different rules as equivalent. For example, suppose the original function gives a discount on orders of 500 or more, while the generated function uses 600. If the tests only include orders below 500 or above 600, every result will match, despite the different thresholds. Section 4’s roughly ten inputs and 80% agreement threshold do not rule out this problem.

Questions for authors

Have the authors considered employing additional training without seeing the particular function being tested?

3 comments
AuthorsOpenReview ↗

Response to review (1/3)

We thank the reviewer for their feedback and time spent on the paper. We now answer the questions and weaknesses raised and aim to update the PDF by the end of the discussion phase.

reported memorization rates may include cases of generalization

Thank you for raising this important point. It is something we acknowledge in the limitations (Section 6, "our counterfactual is not a perfect leave-one-out version of the target…"), but are happy to discuss further.

In short:

  1. We agree that an exact leave-one-out counterfactual would give a strong signal, but it is infeasible at this scale and not noise-free, as training data contains many verbatim and semantic near-duplicates.
  2. Our use of a reference model and a counterfactual criterion is already stricter than most extraction studies. Our checkpoint-based reference follows prior work and reflects a practical audit.
  3. Beyond the reference model, our prompt and evaluation design already aim to separate memorization from generalization.
  4. In a new experiment, we train a new reference model on deduplicated training data and find the measured memorization to be reduced but certainly not removed, so our main conclusion holds.

We now elaborate on each point below.

1. Leave-one-out is strong but not perfect. We agree that a leave-one-out counterfactual, as used in membership inference, would give a strong signal. It is, however, infeasible at this scale, since it requires retraining a model per held-out sample or many models on random subsets (Feldman, 2020; Zhang et al., 2023). It is also not noise-free, especially for language model (pre)training. Real-world training data contains many verbatim and semantic near-duplicates, so removing one exact instance of a function rarely fully removes its content (Liu et al., 2025; Shilov et al., 2026). Related issues are well documented for membership inference on LLMs, where evaluations are confounded with near-duplicates between (non-)members and training data (Duan et al., 2024; Meeus et al., 2025a).

2. Reference models in prior extraction studies. A reference model with a counterfactual criterion is already stricter than most extraction studies, which report raw extraction rates (Carlini et al., 2023; Ippolito et al., 2023; Nasr et al., 2025). This fits their threat model: for an external adversary, any regurgitated text is harmful, whatever its cause. We instead consider an auditor who asks whether training on a specific dataset caused the model to emit that data, which is the question relevant to copyright, privacy and confidentiality concerns. Raw rates cannot answer this, since they also count text the model would produce anyway, such as common code and sequences predictable from the prefix. Our checkpoint-based reference follows Hayes et al. (2025b). The two checkpoints share the architecture and training history, and differ mainly in the training phase containing the data of interest. This makes the reference a practical approximation of retraining without that data, available to any auditor with access to checkpoints. The criterion can also only remove cases from the raw count, so our rates are conservative relative to raw extraction rates. Choosing a reference is harder when no clean "before" checkpoint exists, for example when the data is spread throughout pretraining or the auditor has only black-box access. Weaker proxies, such as independently trained models, are then needed, and we consider this an important open problem.

3. Prompt and evaluation design. Beyond the reference model, we designed the evaluation to separate memorization from generalization. We select long functions with meaningful, specific logic (Appendix B), averaging more than 200 tokens over more than 20 lines. The prompt also never describes what the function should do: it contains only the function signature and up to 250 tokens of preceding code, without docstrings, and on average overlaps with the function body by less than 15 tokens and 7% of the characters.

MetricPython (CraneCode)Python (Stack-Edu)
Length (tokens)285.5 ± 140.3236.9 ± 131.8
Lines (non-empty)25.8 ± 10.219.4 ± 9.1
Max token overlap, prompt vs body13.8 ± 17.3 (6.4%)10.6 ± 16.1 (6.2%)
Max substring overlap, prompt vs body58.1 ± 69.2 chars (6.4%)45.4 ± 62.1 chars (6.5%)

For a flagged case to reflect generalization alone, a capable model would have to infer long, specific logic from a prompt that does not explicitly describe it, and do so better than the reference model. We believe this is unlikely for most flagged cases. Indeed, the reproduced logic often relies on hard-coded values that cannot be inferred from the prompt (e.g., the city-specific commission rates in Fig. 1; more examples in Appendix F).

AuthorsOpenReview ↗

Response to review (2/3)

4. New experiment: a capability-matched reference model. To bridge the gap between the reference model used in the paper and an ideal leave-one-out, we trained a new proxy reference model by further training Olmo-3-7B’s reference model on the Python only subset of the target's midtraining data, excluding the evaluated functions and their near-duplicates.

Specifically:

  • We start from the same pretrained OLMo-3-7B checkpoint as our original reference, including its optimizer state.
  • As training data, we use the Python portion of the official OLMo-3 midtraining mix (Dolmino CraneCode and Stack-Edu Python, 13.4M documents). We remove every document that contains a textual (5-gram MinHash, Jaccard ≥ 0.2) or semantic (Qwen3-Embedding-0.6B, cosine ≥ 0.85) near-duplicate of any of the evaluated functions. This removes 6.1% of documents and leaves 10.5B tokens.
  • We use the official OLMo-3-7B training recipe (peak learning rate 2.07e-4 decayed linearly to zero over one epoch), taking 400 H100 GPU hours.

For feasibility, we focus on the 7B model and Python data, which capture the most relevant generalization.

We evaluate the model on two python generation benchmarks HumanEval and MBPP, as also used in Table 8, and find that the proxy closes the capability gap between the original reference and the target:

ModelHumanEval pass@1 (164)MBPP pass@1 (424)
Reference (from paper)27.4%46.5%
New reference (dedup Python training)43.9%63.0%
Target45.1%60.6%

Using the proxy as the reference, we recompute the number of counterfactually functional memorized (CFM) functions, considering the same functions reproduced as functionally equivalent by the target Olmo-7B:

ReferenceCFM (CraneCode)CFM (Stack-Edu)CFM (total, Python)
Pretrained only (paper)30 (0.67%)103 (2.20%)133 (1.45%)
Proxy (deduplicated midtraining)17 (0.38%)87 (1.86%)104 (1.13%)

With a reference that matches the target's coding ability, the memorization rate drops from 1.45% to 1.13%, about a fifth lower, but remains far from zero. Most of the measured memorization is thus attributable to exposure to the evaluated functions rather than to improved capabilities in general.

These results come with caveats. Faithfully reproducing the training is difficult: our proxy covers only the 7B model and the Python portion of the mix, without the other languages or the math and PDF data. Whether such a model is the right approximation of a leave-one-out reference remains an open question. So does the right level of deduplication: stricter thresholds would remove more of the functions' content, but also more generally useful training data. We therefore see these results as complementary evidence rather than a definitive counterfactual. They nonetheless support our main conclusion that code LLMs functionally memorize their training data. We will add this experiment and its limitations to the Appendix.

the execution tests may label different rules as equivalent.

Thank you for raising this point. While we agree that it is technically possible that our input-output tests do not capture every narrow decision logic in the training data function, in practice:

  • We instruct the agent to design valid and diverse inputs for a given training function, and we empirically find the tests to be comprehensive and legitimate.
  • We argue that requiring 80% output agreement on inputs that together cover at least 80% of the function's lines is already a substantial bar, and we also report results at 100% agreement (Fig. 7). Ultimately, as also acknowledged in Section 6, the right threshold is context-dependent and we believe that demonstrating functional leakage and comparing principled ways to detect it remains a meaningful contribution.

To further test this concern directly, we also re-ran the execution test with more inputs for all 44 functions flagged as counterfactually functionally memorized for Python (CraneCode, OLMo-3-32B). For each function, we kept the 10 original input states and had the agent generate 30 additional, different ones, so that more of the function's logic is likely to be tested.

We find that 39 of the 44 functions (89%) keep their label. The 5 that drop below S_target = 0.8 were already borderline, with S_target = 0.80–0.91 on the original inputs. In one of them, the target generation replaces the training function's distance == 0 check with distance < 1, exactly the kind of rule difference the reviewer describes. Such false positives therefore indeed occur, but they are limited to functions near the threshold and change the rate only modestly. This sensitivity is also why we report results across thresholds (Fig. 7). We will add this experiment to Appendix D and discuss this limitation in Section 6.

AuthorsOpenReview ↗

Response to review (3/3)

Have the authors considered employing additional training without seeing the particular function being tested?

See in the experiment (point 4 above).

Additional references not covered in the paper.

Liu et al., 2025. Language models may verbatim complete text they were not explicitly trained on (ICML 2025).

Reviewer_rUQAOpenReview ↗
Rating
3
Confidence
2
Informativeness
2
Presentation
2
Soundness
2
Read review
Paper summary

This paper formalizes a special memorization pattern of code LLMs, called functional memorization, in which private rules, knowledge, or data are memorized as code logic. Such memorization may leak private information, and a normal textual audit cannot detect it. The authors craft a new dataset and evaluate several baseline methods on it, both textual and semantic, showing that the LLM-based judge performs best. They also provide several approaches to mitigate such functional memorization.

Critical strengths
  1. This paper focuses on an interesting memorization format of code LLMs: memorizing private rules or knowledge in code form.

  2. This paper proposes a high-quality dataset and evaluates different types of baselines. The authors also show how to mitigate such functional memorization.

Critical weaknesses
  1. The paper claims functional memorization of code logic in general, but its measurement (output equivalence only) and all of its examples support only memorization of hard-coded rules and data expressed as code. No memorization of private algorithms is evaluated, which would also require considering time and space cost when measuring functional equivalence. The authors should consider narrowing the claim to avoid this discrepancy.

  2. The quality of the equivalence test used to quantify execution-based similarity depends entirely on the inputs the agent designs, and the paper only has line coverage on the original function, for Python only, with no coverage check for the other languages. There is also no branch or path coverage check to guarantee the diversity of the inputs. The reliability of the execution-based similarity therefore needs more clarification.

  3. The proxy study uses general-purpose embedding models but no encoder fine-tuned for clone detection. It is unclear whether fine-tuning would solve this detection task.

  4. The presentation of the paper could be improved. For example, the font sizes in all figures in the main text are too small to read.

Questions for authors
  1. For the LLM judge, what would the performance be with a much smaller model, such as a ~7B or ~27B model?
3 comments
AuthorsOpenReview ↗

Response to reviewer (1/2)

We thank the reviewer for their feedback and time spent on the paper. We now answer the questions and weaknesses raised and aim to update the PDF by the end of the discussion phase.

but its measurement (output equivalence only) and all of its examples support only memorization of hard-coded rules and data expressed as code

We deliberately define functional memorization through input-output equivalence, the standard notion of Type-IV clones (Roy & Cordy, 2007), and we show this to capture meaningful leakage of functional logic embedded in code. We agree, however, that behavioral equivalence does not capture implementation-level properties such as time and space complexity. We will include this as part of the limitations (Section 6).

equivalence test used to quantify execution-based similarity depends entirely on the inputs the agent designs, and the paper only has line coverage on the original function for Python only, with no coverage check for the other languages.

We agree that testing functional equivalence through agentic execution has limitations, as it depends on the diversity and coverage of the inputs the agent generates, and a generation that reproduces only some execution paths may still leak meaningful logic. We acknowledge this in Section 6, noting that there is likely no single correct threshold, and we report ablations across thresholds (Fig. 7) and across models and agentic harnesses (Fig. 8).

While the exact rates vary with the threshold, we believe that demonstrating functional leakage and comparing principled ways to detect it remains a meaningful contribution.

To address coverage directly, we also measured line and branch coverage of the original training function for 500 samples in every language, using each language's native tooling (gcov for C, JaCoCo for Java, LLVM source-based coverage for Rust, Go's built-in -cover flag, coverage.py for Python):

LanguageLine cov. (mean ± std)% with line cov. ≥ 0.8Branch cov. (mean ± std)% with branch cov. ≥ 0.8
C0.988 ± 0.03599.8%0.949 ± 0.08991.6%
Java0.979 ± 0.05898.2%0.957 ± 0.10393.8%
Rust0.989 ± 0.03599.4%0.969 ± 0.08295.3%
Go0.968 ± 0.06697.0%0.973 ± 0.05797.8%
Python (CC)0.994 ± 0.02699.8%0.978 ± 0.06797.5%
Python (SE)0.993 ± 0.024100.0%0.975 ± 0.05997.2%

Note that Go's native tooling reports only statement coverage, which we show instead.

We find that line and branch coverage are consistently high in every language (0.95–0.99 on average) and on par with Python. This confirms that the agent's inputs adequately exercise the training functions across all languages. We will add these results to Appendix D.

The proxy study uses general-purpose embedding models but no encoder fine-tuned for clone detection.

In the paper, we study 4 embedding models: three different sizes of the general purpose Qwen3-Embedding, but also the code-specific Nomic-Embed-Code-7B. To address the reviewer’s suggestion, we evaluated three additional embedding models trained specifically for code representation/retrieval (we are not aware of widely used checkpoints fine-tuned for clone detection): UniXcoder (125M; Guo et al., 2022). CodeSage-large-v2 (1.3B; Zhang et al., 2024) CodeRankEmbed (137M; Suresh et al., 2025),

We use exactly the same setup as for the embedding models in the paper: OLMo-3-32B target, 6 data subsets, samples with conclusive execution results, and the cosine similarity between the training function and generation. We report ROC AUC and TPR at FPR = 0.01 below (next comment).

We find that:

  • Code-specific embedding models perform in the same range as the embedding models already in the paper: ROC AUC 0.71–0.83 and TPR at FPR = 0.01 of 0.14–0.34 across all subsets. CodeSage-large-v2 is the strongest of the three (in AUC).
  • All embedding models stay substantially below the LLM-judges. On Python (CraneCode), the best new embedding model reaches a TPR of 0.34 at FPR = 0.01, compared with 0.60 for LLaMA-3.3-70B and 0.68 for Sonnet-4.6 with our prompt.

This supports our conclusion: embedding similarity, even from code-specific models, does not reliably capture whether two functions behave the same. Developing embeddings for execution-verified similarity is an interesting direction for future work, and, for now, LLM judges remain the most accurate scalable proxy. We will add these results to Tables 4–6 in Appendix G.

AuthorsOpenReview ↗

Response to review (2/2)

Results for additional code-specific embedding models:

ROC AUC

MetricPython (CC)Python (SE)CJavaRustGo
Embeddings in paper (Qwen3 0.6B/4B/8B, Nomic-code-7B), range0.806–0.8200.798–0.8070.768–0.7880.824–0.8400.751–0.7760.762–0.782
CodeRankEmbed0.8010.7790.7590.8180.7460.759
CodeSage-large-v20.8000.8220.7780.8280.7520.783
UniXcoder0.7930.7370.7080.7920.7220.716
Best LLM-judge (LLaMA-3.3-70B)0.9080.9190.8910.9260.8820.887

TPR at FPR = 0.01

MetricPython (CC)Python (SE)CJavaRustGo
Embeddings in paper, range0.266–0.3020.162–0.1730.164–0.1750.288–0.3140.139–0.1810.218–0.268
CodeRankEmbed0.3030.1510.1420.3220.1930.204
CodeSage-large-v20.3150.1790.1750.3180.1870.232
UniXcoder0.3370.1530.1560.3260.1930.239
Best LLM-judge (LLaMA-3.3-70B)0.6010.3270.2960.4050.2630.410

For example, the font sizes in all figures in the main text are too small to read.

We will increase the font size of all figures in the main text.

For the LLM judge, what would the performance be with a much smaller model, such as a ~7B or ~27B model?

We evaluated our functional-equivalence prompt ("Ours") with three smaller judges on the same OLMo-3-32B generations and subsets: LLaMA-3.2-3B, LLaMA-3.1-8B and LLaMA-4-Scout (MoE, 17B active parameters). We report the ROC AUC/TPR at 1% FPR:

JudgePython (CC)Python (SE)CJavaRustGo
LLaMA-3.2-3B0.769 / 0.1830.780 / 0.1780.753 / 0.0980.791 / 0.2190.708 / 0.1290.772 / 0.104
LLaMA-3.1-8B0.839 / 0.3260.846 / 0.2750.801 / 0.1890.855 / 0.3440.778 / 0.1580.779 / 0.235
LLaMA-4-Scout (17B active)0.925 / 0.5450.908 / 0.2180.885 / 0.1700.911 / 0.3930.878 / 0.0930.868 / 0.430
LLaMA-3.3-70B (paper)0.900 / 0.5820.919 / 0.2440.876 / 0.1690.918 / 0.3820.874 / 0.1060.884 / 0.357

As expected, ROC AUC grows with the model size. ROC AUC across subsets is 0.71–0.79 for 3B, 0.78–0.86 for 8B and 0.87–0.93 for Scout, against 0.87–0.92 for LLaMA-3.3-70B, while TPR results are noisier. These results show that smaller, off-the-shelf models are not powerful enough to detect functional memorization at scale, although fine-tuning them for this task remains a promising direction for future work. We will also add these results to Tables 4–6 in Appendix G.

Thanks for the authors' response, which resolves most of my concerns. Please do not forget to incorporate the additional evidence from the rebuttal into the paper. I will keep my current positive score.

Comments on the paper

2 comments

Dear Reviewers,

Authors’ kindly responded to address your concerns. Please check rebuttals and share your opinions with authors. Thanks for your contributions!

Best, AC

AuthorsOpenReview ↗

Revised paper as part of the rebuttal

We thank the reviewers for their valuable feedback during the discussion phase. As promised, we have now updated the paper PDF incorporating all the points raised during the rebuttal (additions in blue). We of course are still available for discussion if any concerns remain.

From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.

Related papers

Loading the map…

Discussion (0)

Sign in to comment.