LLM推理常依赖语义关联而非形式规则,实验证明其在复杂场景下难以遵循新语义。
LLMs Lean on Priors, Not Programming Language Semantics
- 设计新基准测试,让LLM根据形式语义推理程序执行过程
- 在语义变更和结构复杂度提升时,准确率最高下降60个百分点
- 仅少数模型能长期保持规则遵循,最佳表现仅35%准确率
近期研究探讨大语言模型(LLMs)是否基于显式规则而非预训练中的统计规律进行推理。程序执行提供典型范例:形式语义通过符号转换规则定义行为,可在分布偏移下系统性改变。本文探究LLMs能否基于形式语义进行推理,提出PLSemanticsBench基准,匹配轻量级C程序与两种语义系统——小步操作语义与K语义,并测试四项能力:组合终态规则、状态未变时选择规则、长轨迹下持续遵循规则、在新语义下按规则执行。为分离语义推理与语法熟悉度,重新定义常见运算符以制造符号-意义冲突,并引入仅由规则定义的新符号。在人类编写、LLM翻译及模糊器生成三类数据集上,随结构复杂度上升,标准语义下最高90%的终态准确率下降40–60个百分点。仅有少数模型实现非零长程条件准确率,最优系统也仅达35%。结果表明,当前主流LLMs更依赖预训练词义关联,而非系统性地依据所给形式规则推理。PLSemanticsBench已公开于https://EngineeringSoftware.github.io/PLSemanticsBench。
原文摘要 · Abstract (English)
Recent work asks whether large language models (LLMs) condition their reasoning on explicit rules rather than statistical regularities from pretraining. Program execution provides a canonical instance: formal semantics define behavior through symbolic transition rules that can be systematically altered under distribution shift. We investigate whether LLMs can condition their reasoning on formal semantics through program execution and introduce PLSemanticsBench, pairing featherweight C programs with two semantic systems -- small-step operational semantics and K semantics -- and probing four capabilities: composing rules for final states, selecting rules when state is unmutated, sustaining such conditioning over long traces, and following supplied rules under novel semantics. To decouple semantic reasoning from syntactic familiarity, we redefine familiar operators to induce symbol-meaning conflict and introduce novel symbols defined only through the supplied rules, and stress-test models on Human-Written, LLM-Translated, and Fuzzer-Generated splits with increasing structural complexity. Across 11 frontier LLMs, strong final-state accuracy under standard semantics (up to 90%) drops sharply -- by as much as 40--60% points -- under semantic mutations and increasing structural complexity. Only a handful of models achieve non-zero long-horizon conditioning accuracy, and even the best systems reach just 35%. Together, these results suggest that contemporary LLMs often rely on pretrained lexical associations rather than systematically conditioning on supplied formal rules. PLSemanticsBench is publicly available at https://EngineeringSoftware.github.io/PLSemanticsBench.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。