# AgenticPPL: Perplexity (on what?) is intelligence

> Source: <https://wenhaochai.com/blogs/agentic-ppl.html>
> Published: 2026-11-25 12:00:00+00:00

**Recommendation:** When using perplexity as a rollout-free proxy for agent capability, exclude terminal output and score commands and thoughts instead; the source measured ρ +0.67 and +0.59 versus −0.37 for output.
More in the playbook "Evals and testing for LLM apps": <https://wpnews.pro/playbooks/evals-testing>

# AgenticPPL: Perplexity (on what?) is intelligenceAgenticPPL：困惑度（在什么上？）就是智能AgenticPPL: Perplexity (on what?) is intelligence

This post proposes a way to find the tokens in raw data whose perplexity tracks downstream performance.

本文提出了一种思路，能够从原始数据中找到一些 token，它们的困惑度和下游任务非常相关。

[Experiment page ↗](https://wenhaochai.com/exps/pretrain-ppl-eval.html)

[实验主页 ↗](https://wenhaochai.com/exps/pretrain-ppl-eval.html)

[AgenticPPL toolkit ↗](https://github.com/wenhaochai/AgenticPPL)

[AgenticPPL 工具包 ↗](https://github.com/wenhaochai/AgenticPPL)

[AgenticPPL data ↗](https://huggingface.co/datasets/wchai/AgenticPPL)

[AgenticPPL 数据集 ↗](https://huggingface.co/datasets/wchai/AgenticPPL)

## Plain perplexity on agent trajectories ranks models backwardsagent 轨迹上的普通 perplexity 把模型排反了

Compression usually tracks capability<sup>1</sup>, so trajectory perplexity is the obvious rollout-free proxy for command-line agents. On [Terminal-Bench 2.1](https://www.tbench.ai/)<sup>2</sup> it ranks 40 open-weight models backwards (Figure 1). Which tokens carry the signal?

压缩率通常和能力同步<sup>1</sup>，所以不跑 agent、直接算轨迹 perplexity，是给命令行 agent 排名最自然的办法。可是在 [Terminal-Bench 2.1](https://www.tbench.ai/)<sup>2</sup> 上，它把 40 个开源模型排反了（图 1）。信号到底在哪些 token 上？

## Terminus-2 trajectories and their perplexityTerminus-2 轨迹和它们的 perplexity

Terminal-Bench 2.1 runs in Terminus-2. Turn 0 sends the **task**; each reply splits into **thought**, **command** and chat-template **formatting**; the shell answers with **terminal output**.

Terminal-Bench 2.1 运行在 Terminus-2 里。第 0 轮发来 **task**；之后每轮回复拆成 **thought**、** command** 和对话模板的**格式字符**；shell 回以终端 **output**。

The trajectories come from [Terminal-Lego](https://huggingface.co/datasets/Lego-X/Terminal-Lego-Traj-8k) (292 tasks; Claude Opus 4.6, GLM-5, DeepSeek-V3.2) and [terminal-wrench](https://huggingface.co/datasets/few-sh/terminal-wrench) (175 tasks; Claude Opus 4.6, Gemini 3.1 Pro, GPT-5.4), 1,401 in all. Another 960 **held-out trajectories** come from other tasks.

轨迹来自 [Terminal-Lego](https://huggingface.co/datasets/Lego-X/Terminal-Lego-Traj-8k)（292 题；Claude Opus 4.6、GLM-5、DeepSeek-V3.2）和 [terminal-wrench](https://huggingface.co/datasets/few-sh/terminal-wrench)（175 题；Claude Opus 4.6、Gemini 3.1 Pro、GPT-5.4），共 1,401 条。另有 960 条 **held-out 轨迹**，来自其他题目。

One forward pass scores each trajectory. The development models span 2–14B and 59–128B; the 15 models of the 21–37B band are the **held-out models**, scored once at the end.

每条轨迹只跑一次前向。开发集模型覆盖 2–14B 和 59–128B；中间 21–37B 一档的 15 个模型是 **held-out 模型**，只在最后测一次。

Within a family, scale behaves. Across families it inverts: `K2-Horizon-7B` scores 44.2% and `Ministral-3-8B` 4.1%, yet `K2-Horizon-7B` has the higher perplexity on every trajectory, this one included:

同一家族里，规模规律正常。跨家族就反了：`K2-Horizon-7B` 得 44.2%，`Ministral-3-8B` 得 4.1%，可 `K2-Horizon-7B` 在每条轨迹上的 perplexity 都更高，包括这一条：

Here too its perplexity is 1.160 bits per byte against 0.561.

在这一条上，它的 perplexity 是每字节 1.160 bits，`Ministral-3-8B` 只有 0.561。

## Terminal output carries the backwards sign反向信号来自终端 output

By span, every assistant field ranks models forwards. Terminal output alone ranks them backwards, and it holds 87% of the variance.

按段落拆开，助手写的每一栏都正向排名。只有终端 output 反向，它占了 87% 的方差。

#### Rank correlation by trajectory span

#### 各轨迹段落与榜单的排名相关

Commands rank models best and terminal output ranks them backwards.

command 排得最准，只有终端 output 把模型排反。

| Byte set | Share of bytes | Share of perplexity | Spearman ρ | 
|---|---|---|---|
| All bytes, plain perplexity | 100.0% | 100.0% | −0.29 | 
| Terminal output | 35.7% | 58.9% | −0.37 | 
| All bytes except output | 64.3% | 41.1% | +0.40 | 
| Task, first user message | 24.6% | 27.2% | +0.33 | 
| Chat-template formatting | 5.9% | 0.7% | +0.39 | 
| Thought | 15.8% | 9.1% | +0.59 | 
| Commands | 18.0% | 4.1% | +0.67 | 

| 字节子集 | 字节占比 | perplexity 占比 | Spearman ρ | 
|---|---|---|---|
| 全部字节，普通 perplexity | 100.0% | 100.0% | −0.29 | 
| 终端 output | 35.7% | 58.9% | −0.37 | 
| 除 output 外的全部字节 | 64.3% | 41.1% | +0.40 | 
| Task，首轮用户消息 | 24.6% | 27.2% | +0.33 | 
| 对话模板的格式字符 | 5.9% | 0.7% | +0.39 | 
| Thought | 15.8% | 9.1% | +0.59 | 
| Command | 18.0% | 4.1% | +0.67 | 

Measured on 25 development models and 1,401 trajectories.

在 25 个开发集模型和 1,401 条轨迹上测得。

The models’ 20 most likely next tokens show why. Weak agents copy the repeated screen; strong agents look past it to their own next turn.

看模型最想说的前 20 个 token，就能明白原因。弱模型照抄重复的屏幕；强模型越过屏幕，去预测自己的下一轮。

On a repeated prompt, `Ministral-3-8B` copies the hostname while `K2-Horizon-7B` predicts its own thinking tag. Commands reverse the pair, but in the package check they still tie: most of the command repeats the package name.

遇到重复的 prompt，`Ministral-3-8B` 照抄主机名，`K2-Horizon-7B` 却预测自己的思考标签。只算 command，两者就换了位置；但在这一步修包记录里仍然打平，因为 command 大部分在重复包名。

## AgenticPPL Auto-research Run

Which command tokens matter? Searching on the scored models’ own perplexity would overfit, so we split rule and search (Figure 2). An outer agent rewrites trajectories, hiding the output or dropping thoughts, and two external evaluator models, Flint and Inkling 2 Mini<sup>3</sup>, score the rewrites. An inner agent writes `pick` from those scores and `combine` from one model’s perplexity, and sees only development ρ.

哪些 command token 才算数？直接看待测模型的 perplexity 去搜，会过拟合，所以我们把规则和搜索分开（图 2）。外层 agent 改写轨迹，比如遮住 output、删掉 thought，交给两个外部评测模型 Flint 和 Inkling 2 Mini<sup>3</sup> 打分。内层 agent 根据这些分数写 `pick`，根据单个模型的 perplexity 写 `combine`，它只看得到开发集 ρ。

Both agents are Claude Code running on Gemini 4 Carbon, and nobody steers them. The outer agent writes each rewrite as code: it hides the terminal output, drops the thoughts, keeps only the last few turns, or masks the task description. Each rewrite comes back as the evaluator models’ per-token perplexity, and in one run the outer agent built 31 such features. The inner agent changes one thing per step and hears back a single ρ.

两个 agent 都是跑在 Gemini 4 Carbon 上的 Claude Code，全程没有人干预。外层 agent 把每种改写写成代码：遮住终端 output、删掉 thought、只留最后几轮，或者遮住题目描述。每种改写都换回评测模型逐 token 的 perplexity；其中一次运行里，外层 agent 造出了 31 个这样的特征。内层 agent 每一步只改一处，换回的只有一个 ρ。

Three searches ran side by side. Each leveled off between +0.84 and +0.90 within a few dozen evaluations, about two and a half hours (Figure 3).

三次搜索同时进行。每次都在几十轮评测、大约两个半小时内，停在 +0.84 到 +0.90 之间（图 3）。

They converged on one idea. Every final rule keeps the command tokens whose Flint perplexity falls by more than 0.5 bits once the output is visible, and every final rule reads Flint alone. They differ in the details. One removes the thoughts before it measures the drop, one skips tokens that Flint itself finds hard, and one also keeps first-turn commands that the task description explains. Each averages in its own bounded way: mean probability, perplexity capped at 2 bits, or the rank in the top 20 capped at 1.5.

它们收敛到了同一个想法。每条最终规则都保留看见 output 后 Flint perplexity 下降超过 0.5 bits 的 command token，而且都只读 Flint。细节各有不同：一条先删掉 thought 再量下降，一条跳过 Flint 自己都觉得难的 token，还有一条另外保留第一轮里题目描述能解释的 command。平均方式也各有各的上限：对概率求平均，把 perplexity 截断到 2 bits，或者取 top 20 里的名次并截断到 1.5。

## Commands written from the output rank models读取前文 output 的 command 才能给模型排名

Flags and prompt strings test syntax; capability shows when a command acts on output. Flint finds those places by scoring each trajectory twice, with the output and without it. **AgenticPPL** keeps the command tokens whose Flint perplexity falls by more than 0.5 bits once the output is visible, and averages a model’s perplexity on them with each token capped at 2 bits (Figure 4). After `ls` prints `deadsnakes-ppa.list`, it picks that filename in the next `cat`.

参数和题面字符串只考语法；能力体现在 command 依据 output 行事的地方。Flint 对每条轨迹算两次，一次带 output，一次不带，就能找到这些位置。**AgenticPPL** 保留看见 output 后 Flint perplexity 下降超过 0.5 bits 的 command token，把模型在这些位置上的 perplexity 逐个截断到 2 bits 再平均（图 4）。`ls` 印出 `deadsnakes-ppa.list` 之后，它挑出下一条 `cat` 里的这个文件名。

In the package check it picks only  `|`. There `K2-Horizon-7B` has a perplexity of 0.70 bits and `Ministral-3-8B` of 7.06. Why cap?

在这步修包记录里，它只挑  `|`。在这里 `K2-Horizon-7B` 的 perplexity 是 0.70 bits，`Ministral-3-8B` 是 7.06。为什么要截断？

## Capping each token beats plain averaging逐 token 截断胜过直接平均

Hold the tokens fixed and change only the average: capping each token or averaging probability beats the plain mean perplexity by twenty points.

token 不变，只换平均方式：逐 token 截断或对概率求平均，比直接平均 perplexity 高出二十多个点。

#### The same tokens averaged in different ways

#### 同一批 token，不同的平均方式

Cap each miss.

给每次失误封顶。

| Reducer over picked positions | Spearman ρ | 
|---|---|
| Mean probability | +0.894 | 
| Mean perplexity with each token capped at 2 bits | +0.888 | 
| Mean perplexity with each token capped at 4 bits | +0.831 | 
| Mean perplexity with each token capped at 1 bit | +0.785 | 
| Plain mean perplexity | +0.679 | 
| Plain mean perplexity weighted by bytes | +0.679 | 

| 所选位置上的汇总方式 | Spearman ρ | 
|---|---|
| 对概率求平均 | +0.894 | 
| 每个 token 截断到 2 bits 的平均 perplexity | +0.888 | 
| 每个 token 截断到 4 bits 的平均 perplexity | +0.831 | 
| 每个 token 截断到 1 bit 的平均 perplexity | +0.785 | 
| 直接平均 perplexity | +0.679 | 
| 按字节加权的直接平均 perplexity | +0.679 | 

Measured on 25 development models with the same picked tokens.

在 25 个开发集模型上用同一批挑中的 token 测得。

A token’s perplexity has no ceiling. One confident bet on another valid flag costs 10 to 40 bits and erases dozens of small wins.

单个 token 的 perplexity 没有上限。一次自信地押错另一个合法参数，就要付 10 到 40 bits，抹掉几十处小优势。

On  `|`, the cap leaves `K2-Horizon-7B` at 0.70 bits and holds `Ministral-3-8B` at 2.

在  `|` 上，截断让 `K2-Horizon-7B` 停在 0.70 bits，把 `Ministral-3-8B` 压在 2。

## It holds on held-out trajectories and held-out modelsheld-out 轨迹和 held-out 模型上依然成立

We fixed the test in advance<sup>4</sup>: held-out trajectories on the development models, then once on the held-out models.

检验方法事先定好<sup>4</sup>：先在开发集模型上测 held-out 轨迹，再在 held-out 模型上只跑一次。

#### Held-out trajectories and held-out models

#### held-out 轨迹与 held-out 模型

The rule keeps its lead on held-out trajectories and held-out models.

规则在 held-out 轨迹和 held-out 模型上依然领先。

| Measure | Development | Held-out trajectories × development models | Held-out trajectories × held-out models | 
|---|---|---|---|
| AgenticPPL | +0.890 | +0.854 | +0.788 | 
| Commands only | +0.674 | +0.678 | +0.561 | 
| Plain perplexity | −0.292 | −0.288 | −0.495 | 

| 指标 | 开发集 | held-out 轨迹 × 开发集模型 | held-out 轨迹 × held-out 模型 | 
|---|---|---|---|
| AgenticPPL | +0.890 | +0.854 | +0.788 | 
| 只算 command | +0.674 | +0.678 | +0.561 | 
| 普通 perplexity | −0.292 | −0.288 | −0.495 | 

Each cell is a Spearman ρ. The held-out models were scored once.

表中都是 Spearman ρ。held-out 模型只测了一次。

Held-out trajectories barely move ρ. On the held-out models AgenticPPL leads plain perplexity by +1.28 (95% interval [+0.57, +1.79]).

换成 held-out 轨迹，ρ 几乎不变。在 held-out 模型上，AgenticPPL 比普通 perplexity 高 +1.28（95% 区间 [+0.57, +1.79]）。

From all bytes to 0.30% of them, the 9B pair trades places.

从全部字节缩到其中 0.30%，那对 9B 模型换了位置。

## A second evaluator finds the same rule换一个评测模型，搜出同一条规则

Is the rule Flint’s? The searches had Inkling 2 Mini too and never kept it. Searched with Inkling alone, the rule reaches +0.889 (Figure 3).

这条规则是 Flint 独有的吗？搜索时 Inkling 2 Mini 一直可用，却从没被留下。只用 Inkling 搜，规则达到 +0.889（图 3）。

Its rule has the same shape. It keeps the command tokens whose Inkling perplexity falls once the prompt and output are visible, weights them mostly by what the output adds, and averages probability with those weights.

它的规则形状相同。它保留 prompt 和 output 可见后 Inkling perplexity 下降的 command token，主要按 output 带来的下降加权，再用这些权重对概率求平均。

#### Two evaluators, two picks

#### 两个评测模型，两套挑法

The two rules pick different tokens of the same kind.

挑中的 token 不同，但是类别相同。

|  | Flint | Inkling only, unweighted | Inkling only, weighted | 
|---|---|---|---|
| Development ρ | +0.890 | +0.864 | +0.889 | 
| Share of bytes picked | 0.30% | 1.98% | 1.98% | 
| Picks in turn 0, before any output | 0% | 38% | 10% | 
| Picked text seen in earlier output | 49% | 21% | 43% | 
| Picked text seen in the prompt | 36% | 51% | 42% | 
| Picks that overlap the other rule’s picks | 49% | 7.5% | 27% | 

|  | Flint | 只用 Inkling，不加权 | 只用 Inkling，加权 | 
|---|---|---|---|
| 开发集 ρ | +0.890 | +0.864 | +0.889 | 
| 挑中字节占比 | 0.30% | 1.98% | 1.98% | 
| 落在第 0 轮（尚无任何 output）的挑选 | 0% | 38% | 10% | 
| 挑中文本在前文 output 里出现过 | 49% | 21% | 43% | 
| 挑中文本在 prompt 里出现过 | 36% | 51% | 42% | 
| 与另一条规则的挑选重叠 | 49% | 7.5% | 27% | 

Measured on the development set. The weighted columns use the Inkling rule’s own weights.

在开发集上测得。加权列使用 Inkling 规则自己的权重。

Inkling picks 6.6 times as many bytes, many copied from the prompt, so the two sets barely overlap. But its rule weights each token, and most of the weight lands on the kind Flint picks: 43% on text read off earlier output, against Flint’s 49%. In the package check it picks four tokens and gives 60% of the weight to  `|`, the one token Flint picks. Two evaluator models, searched separately, point at the same kind of token.

Inkling 挑的字节是 Flint 的 6.6 倍，很多是从 prompt 抄来的，所以两套 token 几乎不重叠。但它的规则给每个 token 一个权重，大部分权重落在 Flint 挑的那一类 token 上：43% 落在前文 output 里出现过的文本上，Flint 是 49%。在修包记录里，它挑了 4 个 token，把 60% 的权重给了  `|`，也就是 Flint 唯一挑中的那个。两个评测模型各自搜索，指向了同一类 token。

It reaches +0.831 on held-out trajectories and +0.763 on the held-out models. Two more Inkling-only searches reach +0.740 and +0.795 on the held-out models; the three searches with both evaluator models reach +0.683 to +0.788.

它在 held-out 轨迹上达到 +0.831，在 held-out 模型上达到 +0.763。另外两次只用 Inkling 的搜索，在 held-out 模型上分别达到 +0.740 和 +0.795；可以同时用两个评测模型的三次搜索是 +0.683 到 +0.788。

## Open questions开放问题

Can the same search find such tokens in code-agent logs scored against SWE-bench Verified, or in reasoning traces scored against a math benchmark?

同样的搜索，能不能在以 SWE-bench Verified 打分的代码 agent 日志里，或者以数学基准打分的推理轨迹里，找到这样的 token？

## The recipe完整 recipe

1. Render each trajectory with the model’s own chat template, run one forward pass, and keep each token’s perplexity in bits.
2. Score the same trajectories with Flint twice, once with the terminal output and once with it replaced by `[output hidden]` .
3. Keep the command tokens after turn 0 whose Flint perplexity drops by more than 0.5 bits once the output is visible and stays below 4 bits.
4. Cap the model’s perplexity on each kept token at 2 bits and take minus their mean. This is AgenticPPL, and higher means a stronger agent.

1. 用模型自己的对话模板渲染每条轨迹，跑一次前向，记下每个 token 的 perplexity（以 bits 计）。
2. 用 Flint 给同一批轨迹各算两次，一次带终端 output，一次把 output 换成 `[output hidden]` 。
3. 保留第 0 轮之后的 command token，条件是看见 output 后 Flint perplexity 下降超过 0.5 bits，并且低于 4 bits。
4. 把模型在每个保留 token 上的 perplexity 截断到 2 bits，取平均后加负号，就得到 AgenticPPL。数值越高，agent 越强。

The [AgenticPPL toolkit](https://github.com/wenhaochai/AgenticPPL) ships the kept positions for the 1,401 development and 960 held-out trajectories, so scoring a model takes only step 1. The [dataset](https://huggingface.co/datasets/wchai/AgenticPPL) holds the trajectories and the positions.

[AgenticPPL 工具包](https://github.com/wenhaochai/AgenticPPL)已经附带 1,401 条开发集轨迹和 960 条 held-out 轨迹上的保留位置，所以给一个模型打分只需要第 1 步。[数据集](https://huggingface.co/datasets/wchai/AgenticPPL)里有全部轨迹和位置。

```
git clone https://github.com/wenhaochai/AgenticPPL && cd AgenticPPL
pip install -e .[gpu]
huggingface-cli download wchai/AgenticPPL --repo-type dataset --local-dir release
agenticppl score --model Qwen/Qwen3.5-4B --split heldout --out qwen.json
agenticppl report qwen.json
```

## Acknowledgements致谢

This work used Princeton Research Computing resources on the Della cluster, supported by the Princeton Institute for Computational Science and Engineering and Research Computing at Princeton University.

本研究使用了普林斯顿大学研究计算中心的 Della 集群算力，由普林斯顿计算科学与工程研究所及研究计算中心提供支持。

## References参考文献

## Citation引用

```
@misc{chai2026agenticppl,
  title        = {AgenticPPL: Perplexity (on what?) is intelligence},
  author       = {Chai, Wenhao},
  year         = {2026},
  howpublished = {Blog post},
  url          = {https://wenhaochai.com/blogs/agentic-ppl.html}
}
```


