一句话:提出白盒成员推理框架 SERSEM,用 AST 与静态检查抑制语法样板噪声,放大代码大模型的逐字记忆信号。
代码大模型常在海量且许可不明确的语料上训练,如何通过成员推理攻击(MIA)评估数据污染成为关键问题。已有基于序列级概率(如 Loss、Min-K% Prob、PAC)的方法容易被代码中大量无信息量的语法样板稀释。本文提出 SERSEM:一种白盒攻击框架,采用双信号方法。首先,通过静态抽象语法树(AST)分析、基于拼写检查的多语言逻辑检测以及离线 linting,导出一个连续的字符级权重掩码;随后用这些启发式权重对 Transformer 内部激活进行池化,并据此校准输出 logits 的 token 级 Z-score。作者在 25,000 条样本的平衡数据集上评估,SERSEM 在 StarCoder2-3B 上取得 0.7913 的全局 AUC-ROC,在 StarCoder2-7B 上取得 0.7867,稳定优于所实现的概率基线 Loss、Min-K% Prob 与 PAC。结果表明,聚焦于人类编码习惯中的异常点,比序列级概率平均更能可靠地指示逐字记忆。
As Large Language Models (LLMs) for code increasingly utilize massive, often non-permissively licensed datasets, evaluating data contamination through Membership Inference Attacks (MIAs) has become critical. We propose SERSEM (Selective Entropy-Weighted Scoring for Membership Inference), a novel white-box attack framework that suppresses uninformative syntactical boilerplate to amplify specific memorization signals. SERSEM utilizes a dual-signal methodology: first, a continuous character-level weight mask is derived through static Abstract Syntax Tree (AST) analysis, spellchecking-based multilingual logic detection, and offline linting. Second, these heuristic weights are used to pool internal transformer activations and calibrate token-level Z-scores from the output logits. Evaluated on a 25,000-sample balanced dataset, SERSEM achieves a global AUC-ROC of 0.7913 on the StarCoder2-3B model and 0.7867 on the StarCoder2-7B model, consistently outperforming the implemented probability-based baselines Loss, Min-K% Prob, and PAC. Our findings demonstrate that focusing on human-centric coding anomalies provides a significantly more robust indicator of verbatim memorization than sequence-level probability averages.
DOI 原文 · arXiv · PDF(开放获取) · DBLP
@inproceedings{abs-2604-01147,
title = {SERSEM: Selective Entropy-Weighted Scoring for Membership Inference in Code Language Models},
author = {Kıvanç Kuzey Dikici and Serdar Kara and Semih Çağlar and Eray Tüzün and Sinem Sav},
booktitle = {FSE},
year = {2026},
doi = {10.1145/3803437.3807734}
}