跳到正文
EasyXiv 检索
投稿 关于 登录

按回车检索 · 直接输入编号(如 1706.03762)可跳转到论文

计算机科学 > 计算与语言

arXiv:2404.01903 (cs)
[提交于 2024年4月2日 (v1),最后修订于 2025年10月3日 (此版本, v3)]

标题:Understanding How CodeLLMs (Mis)Predict Types with Activation Steering

作者:Francesca Lucchetti, Arjun Guha
查看论文《Understanding How CodeLLMs (Mis)Predict Types with Activation Steering》的 PDF
查看原文 PDF 中文 PDF (下批处理) EasyResearch 阅读
摘要:Large Language Models (LLMs) are widely used by software engineers for programming tasks. However, research shows that LLMs often lack a deep understanding of program semantics. Even minor changes to syntax, such as renaming variables, can significantly degrade performance across various tasks. In this work, we examine the task of type prediction: given a partially typed program, can a model predict a missing type annotations such that the resulting program is more typed? We construct a dataset of adversarial examples where models initially predict the correct types, but begin to fail after semantically irrelevant edits. This is problematic, as models should ideally generalize across different syntactic forms of semantically equivalent code. This lack of robustness suggests that models may have a shallow understanding of code semantics. Despite this, we provide evidence that LLMs do, in fact, learn robust mechanisms for type prediction-though these mechanisms often fail to activate in adversarial scenarios. By using activation steering, a method that manipulates a model's internal activations to guide it toward using latent knowledge, we restore accurate predictions on adversarial inputs. We show that steering successfully activates a type prediction mechanism that is shared by both Python and TypeScript, and is more effective than prompting with in-context examples. Across five different models, our comprehensive evaluation demonstrates that LLMs can learn generalizable representations of code semantics that transfer across programming languages.
评论: 40 pages, 67 figures. To be published at BlackBoxNLP 2025
主题: 计算与语言 (cs.CL); 机器学习 (cs.LG); 程序设计语言 (cs.PL)
引用方式: arXiv:2404.01903 [cs.CL]
  (或者 arXiv:2404.01903v3 [cs.CL] 对于此版本)
  https://doi.org/10.48550/arXiv.2404.01903

提交历史

来自:Francesca Lucchetti
[v1] 2024年4月2日 星期二 12:44:44 UTC
[v2] 2024年9月13日 星期五 14:56:46 UTC
[v3] 2025年10月3日 星期五 17:11:21 UTC
全文链接:

访问论文:

  • 查看原文 PDF
  • 中文 PDF (下批处理)
  • EasyResearch 阅读
  • TeX 源文件
  • arXiv 原文页面
查看许可

当前浏览上下文:

cs.PL
< 上一篇   |   下一篇 >
最新 | 近期 | 2025-10
切换浏览方式为:
cs
cs.CL
cs.LG

参考文献与引用

  • Google Scholar
  • Semantic Scholar

BibTeX 格式的引用

EasyXiv 是独立运营的中文预印本站点,与 arXiv 及康奈尔大学无隶属关系。 论文元数据与原文来自 arXiv.org,感谢 arXiv 提供开放获取服务。
关于 · 帮助 · 投稿指南 · 版权 · arXiv 原站