代码推理的内部生命周期:从酝酿到解析

From Brewing to Resolution: Tracing the Internal Lifecycle of Code Reasoning in LLMs

精选理由

这篇论文用层析探针找到了LLM做代码推理时“酝酿”到“解析”的秘密,发现即便准确率相近,内部失败模式也截然不同,值得想理解推理本质的人读。

AI 摘要

该论文提出了LLM代码推理的内部生命周期概念:模型先在早期层中酝酿答案,使其线性可解,然后在后期层分化为四种解析结果——已解析、过度处理、错误解析、未解析。研究对Qwen、Llama、DeepSeek三个架构的16个模型进行了6类代码推理任务的层析探针和上下文剥离解码(CSD)实验。结果显示已解析平均仅41.5%,且函数调用任务中,调用深度从1层增至3层时已解析率从61.1%骤降至2.5%。所有模型的酝酿持续时长稳定在24%-42%,但解析成功率随模型能力和规模变化。

原文 · arXiv: DeepSeek

From Brewing to Resolution: Tracing the Internal Lifecycle of Code Reasoning in LLMs

Standard accuracy metrics cannot explain why LLMs handle variable tracking but fail on semantically equivalent loops. We study an internal lifecycle of code reasoning in which models first brew the answer, making it linearly recoverable many layers before it becomes self-decodable, and then diverge into one of four resolution outcomes: Resolved, Overprocessed, Misresolved, or Unresolved. Understanding this lifecycle matters because similar task accuracies can mask fundamentally different failure modes that surface-level evaluation cannot detect. We introduce a dual diagnostic framework pairing layer-wise linear probing with Context-Stripped Decoding (CSD) and apply it to six code-reasoning task families across 16 models spanning Qwen, Llama, and DeepSeek architectures. All four outcomes carry substantial mass in every task family: overall Resolved is only 41.5%, with multiple tasks below 30%. Controlled sweeps over structure, depth, and operators expose task-specific failure bottlenecks: Function Call Resolved plunges from 61.1% to 2.5% as call depth increases from one to three. Across architectures and scales, the brewing scaffold remains stable, with normalized brewing duration 24-42% across all 16 models, while resolution success varies with capability. This indicates that the scaffold is a stable empirical regularity across the tested decoder-only Transformer families, whereas resolution success covaries with capability, scale, and training. Code: https://github.com/euyis1019/llm-brewing