少点错误 03月12日
How Language Models Understand Nullability
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

大型语言模型(LLM)展现出卓越的代码编写能力,但其内部程序语义的表示方式仍不甚明了。本文旨在研究LLM如何理解程序值中的“Nullability”(可空性)。通过设计包含15个程序的微基准测试,评估不同规模和训练阶段的模型对可空值的处理能力。研究发现,模型首先在局部范围内理解Nullability,随后逐渐掌握其在程序中的流动方式。此外,随着模型规模扩大和训练时间延长,它们会形成关于Nullability的内部概念。这项研究为理解LLM如何处理程序语义迈出了重要一步。

💡大型语言模型(LLM)在代码编写方面表现出色,但它们如何理解程序语义,尤其是“Nullability”(可空性),仍然是一个谜。

🧪研究团队设计了一个包含15个程序的微基准测试,用于评估模型在处理可空值时的理解程度,测试涵盖了Nullability在程序中的流动方式。

🧠研究发现,模型在理解Nullability时,首先关注局部范围,然后逐渐扩展到整个程序。随着模型规模的扩大和训练时间的增加,它们会形成关于Nullability的内部概念。

📊通过训练一个探针,可以确定模型是否认为变量读取对应于可空变量,从而展示其内部知识。

Published on March 11, 2025 3:57 PM GMT

TL;DR Large language models have demonstrated an emergent ability to write code, but this ability requires an internal representation of program semantics that is little understood. Recent interpretability work has demonstrated that it is possible to extract internal representations of natural language concepts, raising the possibility that similar techniques could be used to extract program semantics concepts. In this work, we study how large language models represent the nullability of program values. We measure how well models of various sizes at various training checkpoints complete programs that use nullable values, and then extract an internal representation of nullability.

Introduction

The last five years have shown us that large language models, like ChatGPT, Claude, and DeepSeek, can effectively write programs in many domains. This is an impressive capability, given that writing programs involves having a formal understanding of program semantics. But though we know that these large models understand programs to an extent, we still don’t know many things about these models’ understanding. We don’t know where they have deep understanding and where they use heuristic reasoning, how they represents program knowledge, and what kinds of situations will challenge their capabilities.

Fortunately, recent work in model interpretability and representation engineering has produced promising results which give hope towards understanding more and more of the internal thought processes of LLMs. Here at dmodel​ , we can think of no better place to apply these new techniques than formal methods, where there are many abstract properties that can be extracted with static analysis. The vast work done in programming language theory over the past hundred years provides many tools for scaling an understanding of the internal thought processes of language models as they write code.

In that spirit, we wanted to start with a simple property that comes up in every programming language, nullability. Nullable values are represented differently across languages; as null pointers in C or C++, with explicit Option types in Rust, and with special nil or None values in dynamic languages like Javascript, Lisp, or Python. In every case, understanding where values can be nullable is necessary for writing even basic code, and misunderstanding where they are nullable can often be a source of bugs.

Do our models understand when a value is nullable? They must, to be able to write code that deals with nullable values, but we haven’t known what form this knowledge takes, what situations are likely to confuse the model. Until now.

Contributions

We end with a demo: after we train a probe that uses the determines whether the model thinks a variable read corresponds to a nullable variable, we can demonstrate that internal knowledge in a reading diagram:

This is a linkpost for : https://dmodel.ai/nullability/



Discuss

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

LLM 代码编写 Nullability 程序语义 模型理解
相关文章