12-04 更新 实时
首页/ 模型选型/ 正文

用 StateBench 式部署日志测试 LLM 状态跟踪

模型选型 来源:Towards Data Science 2026-11-28 21:00 3 阅读 机器翻译
用 StateBench 式部署日志测试 LLM 状态跟踪

你在 09:05 把预发布环境(staging)的改动推到生产环境。五分钟后,预发布环境上运行的是 build b31。到了 09:11,提供给用户的是哪个 build?最新的一条日志记录显示了一个 build ID 和一个时间戳。你还缺少哪个事实?

为简化起见,假设一次发布总是把预发布环境上的 build 复制到生产环境。生产环境会保留这份副本,直到下一次部署。09:00 时预发布环境运行的是 build b17。因此,09:11 时对外提供的 build 是 b17。如果我们把这个值改成当时预发布环境运行的是 build b24,那么答案就会是 b24。两条日志都以相同的两条记录结尾。把每条日志分别交给一个大语言模型(LLM),问它 09:11 时对外提供的是哪个 build。

状态追踪基准测试会改变什么?

Jackson Petty、William Merrill 和 Ashish Sabharwal 在 2026 年 11 月 2 日的预印本中描述了 StateBench。作者给出一系列对具名变量的更新,并在保持变量数量、不同取值的数量以及更新位置不变的前提下,推导出更简单的序列。两条序列中位于相同位置的更新,可能需要解读该序列的读者(或模型)付出不同的工作量。[1]

考虑赋值、覆写、自增和交换。第一种只需要一次查找。对于被覆写的设置,你需要最近的一次赋值。递增一个计数器需要知道先前的值。交换两个寄存器则需要两者在交换之前的值。

研究人员让四个前沿模型生成变量的最终值。在准确率方面,在研究人员合成基准测试中最通用类别的最长序列上,每个模型的得分都不超过 13%。对于下文的部署练习,我们采用类似的方法来控制对比,并依靠 Python 来评估查找。[1, 2]

当最新的记录给出错误的构建

同一次部署可能以两种方式被记录。条目“set production to b17”给出了构建 ID。条目“promote staging”则告诉我们要去 staging 中查找该构建,并说明何时停止查找。staging 在 09:05 的值告诉我们什么上线了。09:10 的值则告诉我们之后 staging 运行的是什么。

使用构建 b17、b24 和 b31,组成九个有序对。第一个元素是晋升之前 staging 的构建 ID,第二个是晋升之后 staging 的构建 ID。允许重复。每个有序对记录两次,一次写入晋升条目中写明的构建 ID,一次写入复制 staging 的指令。该对中的第一个构建始终是正确答案。

下面的函数逐个读取事件。默认情况下,它会为复制操作保存构建 ID。将 use_latest 设为 True 则改为保留指令。随后该函数在提问时根据 staging 解析该指令。无论是否设置此标志,它都会模拟整个日志。

from itertools import productdef production(events, *, use_latest=False): state = {} for target, value in events: if value == "COPY_STAGING" and not use_latest: value = state["staging"] state[target] = value result = state["production"] if result == "COPY_STAGING": return state["staging"] return resultif __name__ == "__main__": builds = ("b17", "b24", "b31") total = len(builds) ** 2 for form in ("literal", "copy"): latest = replay = 0 for before, after in product(builds, repeat=2): value = before if form == "literal" else "COPY_STAGING" events = [ ("staging", before), ("production", value), ("staging", after), ] latest += production(events, use_latest=True) == before replay += production(events) == before print(f"{form}: latest={latest}/{total}, replay={replay}/{total}")

literal: latest=9/9, replay=9/9copy: latest=3/9, replay=9/9

两种方法在显式写入上都得到 9/9。重放副本得到 9/9。在提问时查找 staging 在副本上得到 3/9。在这三个历史记录中,staging 都结束于已上线的构建。

在所有六个 staging 在副本之后发生变化的情况下,这种捷径都得不到任何分数。现在隐藏九个副本用例中每个用例的第一个 staging 条目。考虑 staging 最终为 b31 的三个用例。在这三个用例中,两个可见条目完全相同。正确的 production 构建在一个用例中是 b17,在另一个中是 b24,在第三个中是 b31。其他两种结尾情况也是如此。

对于相同的两行始终给出相同答案的规则,在这九个等权重的用例中最多只能答对三个。完美记住这些行也无助于确定这些用例的正确答案。

发布助手的四个输入

对每个变体,在新的对话中使用下面的提示词,并采用相同的模型和设置。只向助手提供该变体中的事件。通过在每种情况下将 UNKNOWN 保留为一个选项,你可以评估助手判断何时信息不足无法回答问题的能力。

一次提升操作会将暂存环境复制到生产环境。日志按执行顺序排列。仅使用这些事件。09:00 将暂存环境设为 b17。09:05 将暂存环境提升到生产环境。09:10 将暂存环境设为 b31。在 09:11,生产环境中正在运行的是哪个构建?给出构建 ID 以及能够确定它的时间戳。如果无法确定该 ID,回答 UNKNOWN,并指出缺失的信息。

按下面所述评估每个变体,并对每个变体使用其起始日志。将构建 ID 与支持证据分开考虑。

UNKNOWN(缺少 09:05 时的暂存环境值)

研究针对 b24 的编辑。较早的编辑要求助手给出不同的答案。较晚的编辑要求相同的答案。在最后一次编辑中,如果助手认识到缺失的证据是提升时的暂存环境值,就给予奖励。猜测 b17 会与原始日志一致,但助手没有理由这样做。

如果你的助手依赖检索来提供答案,请保留它接收到的确切段落。如果助手在使用完整日志时回答 b17,而在使用最后两行时回答 b31,请检查为什么 09:00 的赋值没有被检索到。检查为什么助手在没有足够依据的情况下给出了某个构建。将每个答案与其输入一起保留,可以让你分别测试这两个问题。

发布记录中应保留什么

维护一份发布日志,记录每次成功构建晋升的构建 ID。这有助于回滚排查。在一个只记录诸如“promote staging”这类事件的系统中,要确定紧邻其前的 staging 分配。当两个事件共享同一时间戳时,序列号可以告诉你哪个先执行。若缺少这种排序,就可能会有不止一个构建符合同一条记录。

要执行回归测试,需保留原始发布日志和那三个变体。这些改动展示了何时答案应变为 b24、何时应保持 b17,以及何时助手应索要更早的 staging 记录。对“哪个构建被晋升了?”给出单个正确答案,并不能说明助手能否做出全部三种区分。

[1] J. Petty、W. Merrill 和 A. Sabharwal,A Fine-Grained Hierarchy and Benchmark for State Tracking in Language Models(2026),arXiv:2611.03094v1,11 月 2 日。

企业文档智能 [Vol.1 #B2] —— 这份 FAQ 颠覆了标准 RAG 流水线的每一块砖。解析变得微不足道,检索同时充当缓存,而少样本提示也变成了一个检索问题

面向大语言模型的可扩展微调技术

EmptyDataError。听起来很熟悉?那就跟着我,看看在使用 Pandas 加载 CSV 文件时如何避免任何形式的错误……

在要求可靠性的系统中,概率性输出的隐性成本

用 C++ 和 Python 运行 LLaMA 与 Gemma 大语言模型

如何利用 Matplotlib 的全部能力讲述更具吸引力的故事

你是否曾想构建一个知道何时该说话、何时该保持沉默的助手?了解如何使用开源模型来实现它。

聆听来自数据科学领域内部的声音。

减少 DAG 解析时间并节省资源的实用技巧。

译文由英文原文机器翻译,术语按行业惯例统一,可在文末展开原文核对。

查看英文原文(How to Test LLM State Tracking With a StateBench-Style Deployment Log)

You move staging to production at 09:05. Five minutes later, staging is running build b31. At 09:11, what build is served to users? The most recent log entry shows a build ID and a timestamp. What fact are you still missing?

To simplify, let’s say a promotion always copies the build on staging to production. Production keeps that copy until its next deployment. Staging was running build b17 at 09:00. Therefore, the served build at 09:11 is build b17. If we change that value to state that staging was running build b24 at that time, then the answer will be b24. Both logs end with the same two entries. Give each log separately to a large language model (LLM) and ask which build was served at 09:11.

What does a state-tracking benchmark vary?

Jackson Petty, William Merrill, and Ashish Sabharwal describe StateBench in their November 2, 2026 preprint. The authors present a sequence of updates to named variables and derive simpler sequences while keeping the number of variables, the number of distinct values and the positions of the updates fixed. Updates in the same positions in two sequences may require different work from a reader (or model) interpreting the sequences. [1]

Consider assignment, overwrite, increment, and swap. The first requires only a single lookup. For an overwritten setting, you need the most recent assignment. Incrementing a counter requires knowledge of the previous value. Swapping two registers requires both values just prior to the swap.

The researchers had four frontier models generate the final values of the variables. On accuracy, each model scored 13% or less on the longest sequences in the most general class of the researchers’ synthetic benchmark. For the deployment exercise below, we use a similar approach to control a comparison and rely on Python to evaluate lookups. [1, 2]

When the newest record gives the wrong build

The same deployment may be logged in two ways. The entry “set production to b17” gives the build ID. The entry “promote staging” tells us to look for the build in staging and states when to stop looking. The value of staging at 09:05 tells us what went live. The value at 09:10 tells us what staging ran afterward.

Using the builds b17, b24, and b31, form nine ordered pairs. The first element is the build ID of staging before a promotion and the second is the build ID of staging after it. Allow repeats. Record each ordered pair twice, once with the build ID written in the promotion entry and once with the instruction to copy staging. The first build of the pair is always the correct answer.

The function below reads events one after the other. By default, it saves the build ID for copies. Set use_latest to True to keep the instruction instead. The function then resolves the instruction against staging at question time. With or without this flag, it simulates the entire log.

from itertools import productdef production(events, *, use_latest=False): state = {} for target, value in events: if value == "COPY_STAGING" and not use_latest: value = state["staging"] state[target] = value result = state["production"] if result == "COPY_STAGING": return state["staging"] return resultif __name__ == "__main__": builds = ("b17", "b24", "b31") total = len(builds) ** 2 for form in ("literal", "copy"): latest = replay = 0 for before, after in product(builds, repeat=2): value = before if form == "literal" else "COPY_STAGING" events = [ ("staging", before), ("production", value), ("staging", after), ] latest += production(events, use_latest=True) == before replay += production(events) == before print(f"{form}: latest={latest}/{total}, replay={replay}/{total}")

literal: latest=9/9, replay=9/9copy: latest=3/9, replay=9/9

Both methods score 9 out of 9 on explicit writes. Replaying the copy scores 9 out of 9. Looking up staging at question time scores 3 out of 9 on copies. In each of those three histories, staging finishes on the build that went live.

In all six cases where staging changes after the copy, the shortcut fails to score any points. Now hide the first staging entry in each of the nine copy cases. Consider the three cases where staging ends on b31. The two visible entries are identical across those three cases. The correct production build is b17 in one case, b24 in another and b31 in the third. The same holds for the other two endings.

A rule that always gives the same answer for the same two lines can get at most three of these nine equally weighted cases right. Perfect memory of these lines does not help determine the correct answer for these cases.

Four inputs for a release assistant

Use the prompt below in a new conversation for each variation, using the same model and settings. Give the assistant only the events in that variation. By leaving UNKNOWN as an option in each case, you can assess the assistant’s ability to determine when it has insufficient information to answer a question.

A promotion copies staging to production once.The log is in execution order. Use only these events.09:00 Set staging to b17.09:05 Promote staging to production.09:10 Set staging to b31.Which build is live in production at 09:11?Give the build ID and the timestamps that establish it.If the ID cannot be determined, answer UNKNOWNand identify the missing information.

Evaluate each variant as described below, using the starting log for each. Consider the build ID and the supporting evidence separately.

UNKNOWN (staging at 09:05 is missing)

Study the edits for b24. The earlier edit requires a different answer from the assistant. The later edit requires the same answer. In the last edit, reward the assistant for recognizing that the missing evidence is the staging value at the time of promotion. A guess of b17 would agree with the original log, but the assistant would have no justification for this.

If your assistant relies on retrieval to provide an answer, keep the exact passages it received. If the assistant states b17 using the full log, and b31 using the last two lines, check why the 09:00 assignment was not retrieved. Check why the assistant stated a build without enough justification. Keeping each answer with its input lets you test the two issues separately.

What to keep in the release record

Maintain a release log to record build IDs for each successful build promotion. This aids rollback investigations. In a system that records only events such as “promote staging,” determine the immediately preceding staging assignment. When two events share a timestamp, a sequence number can tell you which ran first. Without this ordering, more than one build may fit the same record.

To perform a regression test, retain the original release log and the three variants. The edits show when the answer should change to b24, when it should stay b17 and when the assistant should ask for the earlier staging record. A single correct answer to “What build was promoted?” doesn’t tell you whether the assistant can make all three distinctions.

[1] J. Petty, W. Merrill and A. Sabharwal, A Fine-Grained Hierarchy and Benchmark for State Tracking in Language Models (2026), arXiv:2611.03094v1, November 2.

Enterprise Document Intelligence [Vol.1 #B2] - The FAQ inverts every brick of the standard RAG pipeline. Parsing is trivial, retrieval doubles as a cache, and few-shot prompting becomes a retrieval problem too

August 31, 202619 min read

Scalable fine-tuning techniques for large language models

EmptyDataError. Sounds Familiar? Then read stick with me for some tips to avoid any form of error when loading your CSV files using Pandas...

April 21, 20215 min read

The hidden cost of probabilistic outputs in systems that demand reliability

April 21, 202611 min read

Running LLaMA and Gemma LLMs with C++ and Python

March 9, 20247 min read

How to use the full capabilities of Matplotlib to tell a more compelling story

October 27, 20237 min read

Have you ever wanted to build an assistant that knows when to talk and when to remain silent? Learn how to do it using open-source models.

January 22, 202416 min read

Hear the voices from within the world of data science.

October 15, 20213 min read

Valuable tips to reduce your DAGs' parse time and save resources.

January 30, 20259 min read

原文为英文,正文由自动抓取并保留原文。

本文由采集器自动同步

原文发布于 Towards Data Science(How to Test LLM State Tracking With a StateBench-Style Deployment Log),标题、摘要与正文由机器翻译,术语按行业惯例统一,未经人工逐句校订。

阅读原文 ↗