When Models Know but Can’t Say: Relational Encoding Limits Linear Vulnerability Classification in Code LLMs

Rui Melo, Andre Catarino, Claudia Mamede, Corina S. Pasareanu, Rui Abreu


Abstract
Large language models can detect vulnerable code, yet whether their internal representations encode vulnerability information in a form accessible to standard classifiers remains unresolved. We analyze 8 code models on C programs using three datasets (DELTASECOMMITS, SVEN, and PRECISE BUGS). LLMs represent vulnerability relational encoding —code B is more vulnerable than code A—rather than categorically, making the information inaccessible to standard classification probes. We find 87–88% per-pair alignment across layers L3-L23, yet this direction produces limited categorical accuracy because vulnerable and secure samples form overlapping distributions. This structural property—relational rather than categorical encoding—explains the difficulty of categorical classification in pretrained, general-purpose code LLMs, and motivates ranking and preference-learning approaches as more natural for vulnerability assessment.
Anthology ID:
2026.findings-emnlp.1252
Volume:
Findings of the Association for Computational Linguistics: EMNLP 2026
Month:
October
Year:
2026
Address:
Budapest, Hungary
Editors:
Hung-Yi Lee, Sunipa Dev, Jessy Li, Desmond Elliott
Venue:
Findings
SIG:
SIGDAT
Publisher:
Association for Computational Linguistics
Note:
Pages:
26461–26497
Language:
URL:
https://aclanthology.org/2026.findings-emnlp.1252/
DOI:
Bibkey:
Cite (ACL):
Rui Melo, Andre Catarino, Claudia Mamede, Corina S. Pasareanu, and Rui Abreu. 2026. When Models Know but Can’t Say: Relational Encoding Limits Linear Vulnerability Classification in Code LLMs. In Findings of the Association for Computational Linguistics: EMNLP 2026, pages 26461–26497, Budapest, Hungary. Association for Computational Linguistics.
Cite (Informal):
When Models Know but Can’t Say: Relational Encoding Limits Linear Vulnerability Classification in Code LLMs (Melo et al., Findings 2026)
Copy Citation:
PDF:
https://aclanthology.org/2026.findings-emnlp.1252.pdf