<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://hzxbzp.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://hzxbzp.github.io/" rel="alternate" type="text/html" hreflang="en" /><updated>2026-11-23T19:55:19+00:00</updated><id>https://hzxbzp.github.io/feed.xml</id><title type="html">Zhipeng Bao</title><subtitle>AI · Robotics · Autonomous Driving — Thoughts on technology and life</subtitle><author><name>Zhipeng Bao</name></author><entry xml:lang="en"><title type="html">Give the ViT Some Scratch Paper: What Register Tokens Are For</title><link href="https://hzxbzp.github.io/blog/2026/11/register-tokens/" rel="alternate" type="text/html" title="Give the ViT Some Scratch Paper: What Register Tokens Are For" /><published>2026-11-23T00:00:00+00:00</published><updated>2026-11-23T00:00:00+00:00</updated><id>https://hzxbzp.github.io/blog/2026/11/register-tokens</id><content type="html" xml:base="https://hzxbzp.github.io/blog/2026/11/register-tokens/"><![CDATA[<p>Feed a road photo to DINOv2 and draw its attention map, and you may see something odd. The brightest spots aren’t on the car or the pedestrian. They’re in a blank patch of sky, or an empty stretch of asphalt.</p>

<p>I’ve been working on driving video lately, and I use the spatial feature grid from a video encoder: one feature per small region of the frame, not a single vector for the whole clip. Telling a lane change from a merge depends on where the lanes are, so whether those per-region features are clean matters to me. That’s why I read <em>Vision Transformers Need Registers</em> by Darcet and colleagues at Meta and Inria, one of the ICLR 2024 Outstanding Papers. It explains what those bright spots are, and the fix is surprisingly simple.</p>

<h2 id="a-quick-refresher-on-vits">A quick refresher on ViTs</h2>

<p>A ViT reads an image by cutting it into small squares, say 14×14 pixels each. Each square is a <strong>patch</strong>, and each patch becomes a vector called a <strong>token</strong>. There’s also one special <strong>CLS token</strong> that doesn’t belong to any part of the image; its job is to summarize the whole picture, and it’s what gets used for classification.</p>

<p>All the tokens then go through many transformer layers. In each layer, every token looks at every other token and decides how much to take from each one. That’s <strong>attention</strong>, and an attention map shows where a given token is looking.</p>

<p>In principle, a patch token should keep describing its own little square: this one is sky, that one is a headlight.</p>

<h2 id="the-strange-bright-spots">The strange bright spots</h2>

<p>The paper traces the bright spots in the picture at the top to an unusual kind of patch token: one with a very large <strong>norm</strong>, which you can think of as the vector’s volume.</p>

<figure class="figure-wide">
  <img src="/assets/images/blog/registers-norms.svg" alt="Illustration: the norms of 50 patch tokens; almost all are similar and one is about ten times taller, roughly 2% of the tokens." />
</figure>

<p>What they found:</p>

<ul>
  <li><strong>They’re rare.</strong> About 2% of all tokens. In DINOv2 ViT-g, 2.37% of tokens have a norm above 150.</li>
  <li><strong>They’re loud.</strong> Their norm is about ten times that of a normal token.</li>
  <li><strong>They sit in boring places.</strong> Almost always sky, walls or road: patches that look much like their neighbours and carry little new information.</li>
  <li><strong>They need scale and time.</strong> They only appear in larger models (from ViT-L up for DINOv2), only after about a third of training, and only from the middle layers on, around layer 15 of the 40-layer ViT-g.</li>
</ul>

<p>DINOv2, OpenCLIP and DeiT-III all show them. Interestingly, the original DINO doesn’t.</p>

<h2 id="whats-inside-them">What’s inside them</h2>

<p>The authors gave these high-norm tokens a check-up: take one token and see which questions it can still answer.</p>

<figure class="figure-wide">
  <img src="/assets/images/blog/registers-probing.svg" alt="Probing results from the paper. Position prediction: normal patches 41.7%, high-norm patches 22.8%. ImageNet linear classification: CLS token 86.0%, high-norm patches 69.0%, normal patches 65.8%." />
</figure>

<p>The left question is “where in the image are you?” Normal patches get it right 41.7% of the time; high-norm patches only 22.8%. Asked to reconstruct their own pixels, they also do clearly worse. They’ve mostly forgotten which bit of sky they used to be.</p>

<p>The right question is “what is the whole image?” Using a single token for linear classification, a high-norm patch reaches 69.0%, higher than a normal patch at 65.8% and not that far from the CLS token, whose whole job this is, at 86.0%.</p>

<p>Put the two together and the story is clear: <strong>the model has learned to commandeer useless background patches and use them as temporary memory for global information.</strong></p>

<figure class="figure-wide">
  <img src="/assets/images/blog/registers-scratch.svg" alt="Illustration: on the left, without registers, the model writes global notes on a sky patch, which loses its own position and content; on the right, with registers, the notes go on the registers and every patch describes only itself." />
</figure>

<p>Think of an exam where you need to do some working out but only have the question paper. So you pick a blank-looking spot and scribble there, and that spot happens to have an unimportant illustration printed on it. Perfectly sensible for you; nobody was looking at that picture anyway. But anyone who looks at the picture afterwards sees only your scribbles.</p>

<p>The model does the same. In the middle layers a large model needs to do some global computation, and the sequence has no dedicated place to keep the results. A sky patch is nearly identical to its neighbours, so overwriting it costs almost nothing. It becomes the scratch paper.</p>

<h2 id="why-it-matters">Why it matters</h2>

<p>For classification this barely matters; the CLS token still works. The trouble is with anything that uses the individual patches:</p>

<ul>
  <li><strong>Attention maps and feature maps get noisy</strong>, and it’s harder to tell what the model is looking at.</li>
  <li><strong>Dense prediction</strong>, like segmentation and depth, suffers, because those patches no longer describe themselves.</li>
  <li><strong>Methods that find objects through attention mostly break.</strong> LOST, for example, looks for the most object-like region in the attention, and ends up finding the bright spot in the sky.</li>
</ul>

<h2 id="the-fix-hand-it-some-blank-paper">The fix: hand it some blank paper</h2>

<p>If the model needs somewhere to scribble, give it somewhere. Besides the CLS token and the patches, add N learnable <strong>register tokens</strong> to the input sequence:</p>

<figure class="figure-wide">
  <img src="/assets/images/blog/registers-architecture.svg" alt="Architecture: the input sequence is CLS, four registers and the image patches; patches get position embeddings, registers do not; all tokens pass through the transformer; at the output CLS is used for classification, patches for dense tasks, and the registers are discarded." />
</figure>

<ul>
  <li>Like CLS, they’re learned parameters that don’t correspond to anything in the image.</li>
  <li>They get no position embedding, since they aren’t anywhere in the image.</li>
  <li>They take part in attention at every layer, so they can be read from and written to.</li>
  <li>At the output they’re simply thrown away and used for nothing downstream.</li>
</ul>

<p>In code it’s a couple of extra lines:</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="bp">self</span><span class="p">.</span><span class="n">reg</span> <span class="o">=</span> <span class="n">nn</span><span class="p">.</span><span class="n">Parameter</span><span class="p">(</span><span class="n">torch</span><span class="p">.</span><span class="n">zeros</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">N</span><span class="p">,</span> <span class="n">D</span><span class="p">))</span>       <span class="c1"># N registers, D dims each
</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">torch</span><span class="p">.</span><span class="n">cat</span><span class="p">([</span><span class="n">cls</span><span class="p">,</span> <span class="bp">self</span><span class="p">.</span><span class="n">reg</span><span class="p">.</span><span class="n">expand</span><span class="p">(</span><span class="n">B</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">),</span> <span class="n">patches</span> <span class="o">+</span> <span class="n">pos</span><span class="p">],</span> <span class="n">dim</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">blocks</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>                                       <span class="c1"># all tokens go through the transformer
</span><span class="n">cls_out</span><span class="p">,</span> <span class="n">patch_out</span> <span class="o">=</span> <span class="n">x</span><span class="p">[:,</span> <span class="mi">0</span><span class="p">],</span> <span class="n">x</span><span class="p">[:,</span> <span class="mi">1</span> <span class="o">+</span> <span class="n">N</span><span class="p">:]</span>          <span class="c1"># registers are dropped here
</span></code></pre></div></div>

<p>With dedicated scratch space, the model stops taking over background patches, and every patch token goes back to describing its own square.</p>

<h2 id="results">Results</h2>

<p>The high-norm artifacts essentially disappear, and the attention maps become smooth and settle on objects. The biggest gains are in tasks that rely on attention maps:</p>

<figure class="figure-wide">
  <img src="/assets/images/blog/registers-lost.svg" alt="Unsupervised object discovery with LOST, corloc on VOC2007. DINOv2 from 35.3 to 55.4, DeiT-III from 11.7 to 27.1, OpenCLIP from 38.8 to 37.1." />
</figure>

<p>DINOv2’s object-discovery score on VOC2007 goes from 35.3 to 55.4, up 20.1 points, and DeiT-III’s from 11.7 to 27.1. OpenCLIP is the exception: roughly flat, slightly lower.</p>

<p>Classification and dense prediction improve a little, or at least don’t get worse. Here are the results with frozen features and only a linear layer trained:</p>

<table>
  <thead>
    <tr>
      <th>Model</th>
      <th>ImageNet top-1</th>
      <th>ADE20k segmentation mIoU</th>
      <th>NYUd depth RMSE (lower is better)</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>DINOv2</td>
      <td>84.3</td>
      <td>46.6</td>
      <td>0.378</td>
    </tr>
    <tr>
      <td>DINOv2 + registers</td>
      <td><strong>84.8</strong></td>
      <td><strong>47.9</strong></td>
      <td><strong>0.366</strong></td>
    </tr>
    <tr>
      <td>OpenCLIP</td>
      <td>78.2</td>
      <td>26.6</td>
      <td>0.702</td>
    </tr>
    <tr>
      <td>OpenCLIP + registers</td>
      <td>78.1</td>
      <td>26.7</td>
      <td><strong>0.661</strong></td>
    </tr>
    <tr>
      <td>DeiT-III</td>
      <td>84.7</td>
      <td>38.9</td>
      <td>0.511</td>
    </tr>
    <tr>
      <td>DeiT-III + registers</td>
      <td>84.7</td>
      <td>39.1</td>
      <td>0.512</td>
    </tr>
  </tbody>
</table>

<p>How many do you need? In the paper’s words, <strong>one register is enough to remove the artifacts</strong>, and a few more help downstream performance a little. For dense tasks there seems to be a best number, with the first register bringing most of the benefit; for ImageNet classification, more is slightly better. They used 4 in every experiment.</p>

<p>The cost is negligible. A 224×224 image cut into 14×14 squares gives 256 patches, 257 tokens with CLS. Four registers make the sequence 1.6% longer.</p>

<h2 id="is-this-the-same-as-attention-sinks-in-llms">Is this the same as attention sinks in LLMs?</h2>

<p>It looks a lot like it. In large language models, a lot of attention piles up on the first few tokens of the sequence, which carry almost no meaning. That’s called an <strong>attention sink</strong>. The reason is similar: attention in each row has to add up to 1, so when the model doesn’t really want to take information from anywhere, it needs somewhere to dump the excess.</p>

<p>High-norm tokens in ViTs and attention sinks in LLMs look like the same kind of need: a position with no content of its own, where the model can dump attention or keep global information. If you don’t provide one, it finds its own.</p>

<p>A later paper on “massive activations” in LLMs (Sun et al., 2024) looks at ViT registers directly. It finds that registers learn values that hardly depend on the input image, so they act more like fixed biases. That’s not quite the original paper’s reading, that registers gather global information. Which explanation is closer isn’t settled yet, but both agree on the main point: the model needs a spot like this.</p>

<h2 id="can-you-do-it-without-retraining">Can you do it without retraining?</h2>

<p>Registers have one catch: they have to be there during training. You can’t retrain a large model from scratch just to add a few tokens.</p>

<p><em>Vision Transformers Don’t Need Trained Registers</em> by Jiang, Dravid, Efros and Gandelsman (NeurIPS 2025) offers a way around it. They found that the high-norm tokens are produced by a small set of specific neurons, which they call <strong>register neurons</strong>. At inference time, you add one extra, untrained token to the sequence and move those neurons’ large activations onto it. The result is comparable to a model actually trained with registers. They call it a <strong>test-time register</strong>.</p>

<h2 id="what-it-means-for-me">What it means for me</h2>

<p>If you’re using patch features from a large ViT for segmentation, depth or object discovery, or need a spatial feature grid as I do, it’s worth checking for these artifacts first. DINOv2 already ships both versions; the ones with registers have <code class="language-plaintext highlighter-rouge">_reg</code> at the end of the name. This snippet compares the patch-token norms of the two (it needs GitHub access to download the models):</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">torch</span>
<span class="kn">from</span> <span class="nn">PIL</span> <span class="kn">import</span> <span class="n">Image</span>
<span class="kn">import</span> <span class="nn">torchvision.transforms</span> <span class="k">as</span> <span class="n">T</span>

<span class="n">tf</span> <span class="o">=</span> <span class="n">T</span><span class="p">.</span><span class="n">Compose</span><span class="p">([</span>
    <span class="n">T</span><span class="p">.</span><span class="n">Resize</span><span class="p">((</span><span class="mi">448</span><span class="p">,</span> <span class="mi">448</span><span class="p">)),</span>                       <span class="c1"># sides must be a multiple of 14
</span>    <span class="n">T</span><span class="p">.</span><span class="n">ToTensor</span><span class="p">(),</span>
    <span class="n">T</span><span class="p">.</span><span class="n">Normalize</span><span class="p">((</span><span class="mf">0.485</span><span class="p">,</span> <span class="mf">0.456</span><span class="p">,</span> <span class="mf">0.406</span><span class="p">),</span> <span class="p">(</span><span class="mf">0.229</span><span class="p">,</span> <span class="mf">0.224</span><span class="p">,</span> <span class="mf">0.225</span><span class="p">)),</span>
<span class="p">])</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">tf</span><span class="p">(</span><span class="n">Image</span><span class="p">.</span><span class="nb">open</span><span class="p">(</span><span class="s">"road.jpg"</span><span class="p">).</span><span class="n">convert</span><span class="p">(</span><span class="s">"RGB"</span><span class="p">)).</span><span class="n">unsqueeze</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>

<span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="p">[</span><span class="s">"dinov2_vitl14"</span><span class="p">,</span> <span class="s">"dinov2_vitl14_reg"</span><span class="p">]:</span>
    <span class="n">model</span> <span class="o">=</span> <span class="n">torch</span><span class="p">.</span><span class="n">hub</span><span class="p">.</span><span class="n">load</span><span class="p">(</span><span class="s">"facebookresearch/dinov2"</span><span class="p">,</span> <span class="n">name</span><span class="p">).</span><span class="nb">eval</span><span class="p">()</span>
    <span class="k">with</span> <span class="n">torch</span><span class="p">.</span><span class="n">no_grad</span><span class="p">():</span>
        <span class="n">out</span> <span class="o">=</span> <span class="n">model</span><span class="p">.</span><span class="n">forward_features</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
    <span class="n">n_reg</span> <span class="o">=</span> <span class="n">model</span><span class="p">.</span><span class="n">num_register_tokens</span>            <span class="c1"># 0 for the model without registers
</span>    <span class="n">patches</span> <span class="o">=</span> <span class="n">out</span><span class="p">[</span><span class="s">"x_prenorm"</span><span class="p">][</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span> <span class="o">+</span> <span class="n">n_reg</span><span class="p">:]</span>    <span class="c1"># drop CLS and the registers
</span>    <span class="n">norms</span> <span class="o">=</span> <span class="n">patches</span><span class="p">.</span><span class="n">norm</span><span class="p">(</span><span class="n">dim</span><span class="o">=-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">print</span><span class="p">(</span><span class="sa">f</span><span class="s">"</span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s">: median </span><span class="si">{</span><span class="n">norms</span><span class="p">.</span><span class="n">median</span><span class="p">()</span><span class="si">:</span><span class="p">.</span><span class="mi">0</span><span class="n">f</span><span class="si">}</span><span class="s">, max </span><span class="si">{</span><span class="n">norms</span><span class="p">.</span><span class="nb">max</span><span class="p">()</span><span class="si">:</span><span class="p">.</span><span class="mi">0</span><span class="n">f</span><span class="si">}</span><span class="s">, "</span>
          <span class="sa">f</span><span class="s">"max is </span><span class="si">{</span><span class="n">norms</span><span class="p">.</span><span class="nb">max</span><span class="p">()</span> <span class="o">/</span> <span class="n">norms</span><span class="p">.</span><span class="n">median</span><span class="p">()</span><span class="si">:</span><span class="p">.</span><span class="mi">1</span><span class="n">f</span><span class="si">}</span><span class="s">x the median"</span><span class="p">)</span>
</code></pre></div></div>

<p>If the maximum sits far above the median for the model without registers and not for the one with them, you’re looking at the effect from the paper. Reshape <code class="language-plaintext highlighter-rouge">norms</code> back into a 32×32 grid and plot it, and the tall ones will mostly be on the sky and the road.</p>

<p style="font-size: 1.4em; font-style: italic; text-align: center; margin: 2rem 0;">A model will always find somewhere to scribble. Give it paper, or it writes on the sky.</p>

<hr />

<h2 id="useful-resources">Useful Resources</h2>

<ul>
  <li><a href="https://arxiv.org/abs/2309.16588">Vision Transformers Need Registers (Darcet, Oquab, Mairal, Bojanowski, ICLR 2024)</a> — the paper this post is about: the artifact analysis, the probing experiments and all the results</li>
  <li><a href="https://blog.iclr.cc/?p=740">ICLR 2024 Outstanding Paper Awards</a> — it was one of the five award winners that year</li>
  <li><a href="https://arxiv.org/abs/2506.08010">Vision Transformers Don’t Need Trained Registers (Jiang, Dravid, Efros, Gandelsman, NeurIPS 2025)</a> — test-time registers, no retraining</li>
  <li><a href="https://arxiv.org/abs/2309.17453">Efficient Streaming Language Models with Attention Sinks (Xiao et al., 2023)</a> — attention sinks in LLMs</li>
  <li><a href="https://arxiv.org/abs/2402.17762">Massive Activations in Large Language Models (Sun et al., 2024)</a> — connects massive activations in LLMs with ViT registers, and offers the “registers are fixed biases” reading</li>
  <li><a href="https://arxiv.org/abs/2006.11527">Memory Transformer (Burtsev et al., 2020)</a> — the earliest work adding extra memory tokens to a transformer in NLP, cited by the original paper</li>
</ul>]]></content><author><name>Zhipeng Bao</name></author><category term="AI" /><category term="ViT" /><category term="computer vision" /><category term="representation learning" /><category term="tutorial" /><summary type="html"><![CDATA[Feed a road photo to DINOv2 and draw its attention map, and you may see something odd. The brightest spots aren’t on the car or the pedestrian. They’re in a blank patch of sky, or an empty stretch of asphalt.]]></summary></entry><entry xml:lang="zh"><title type="html">给 ViT 一张草稿纸：Register Token 是怎么回事</title><link href="https://hzxbzp.github.io/zh/blog/2026/11/register-tokens/" rel="alternate" type="text/html" title="给 ViT 一张草稿纸：Register Token 是怎么回事" /><published>2026-11-23T00:00:00+00:00</published><updated>2026-11-23T00:00:00+00:00</updated><id>https://hzxbzp.github.io/zh/blog/2026/11/zh-register-tokens</id><content type="html" xml:base="https://hzxbzp.github.io/zh/blog/2026/11/register-tokens/"><![CDATA[<p>把一张路面照片喂给 DINOv2，再把它的注意力图画出来，你可能会看到一件怪事：最亮的几个点不在车上，也不在行人身上，而是在一片空白的天空里，或者一块什么都没有的路面上。</p>

<p>我最近在做驾驶视频的项目，用的是视频编码器的空间特征网格：每一小块画面各出一个特征，而不是整段视频只出一个向量。分清车是在变道还是在汇入，要看车道在画面的哪里，所以这些小块特征干不干净，对我很要紧。这就是我去读 Darcet 等人那篇 <em>Vision Transformers Need Registers</em>（Meta 和 Inria，ICLR 2024 杰出论文奖）的原因。它解释了那些亮点是什么，修法也简单得出奇。</p>

<h2 id="先说两句-vit">先说两句 ViT</h2>

<p>ViT 看图的方式，是把图片切成一格一格的小方块，比如 14×14 像素一块，每一块叫一个 <strong>patch</strong>。每个 patch 变成一个向量，叫 <strong>token</strong>。另外再加一个特殊的 <strong>CLS token</strong>，它不对应任何一块画面，专门用来汇总整张图，最后拿去做分类。</p>

<p>然后所有 token 一起过很多层 Transformer。每一层里，每个 token 都会”看”一遍其他所有 token，决定从谁那里拿多少信息，这就是<strong>注意力</strong>。注意力图画的就是：某个 token 在看哪些地方。</p>

<p>按理说，patch token 应该一直描述自己那一小块：这块是天空，那块是车灯。</p>

<h2 id="奇怪的亮点">奇怪的亮点</h2>

<p>开头那张图里的亮点，论文追到了一类很特别的 patch token 上：它们的<strong>范数</strong>（可以理解成向量的”音量”）特别大。</p>

<figure class="figure-wide">
  <img src="/assets/images/blog/registers-norms-zh.svg" alt="示意图：50 个 patch token 的范数，大部分高度相近，只有 1 个高出约 10 倍，约占 2%。" />
</figure>

<p>几个特点：</p>

<ul>
  <li><strong>数量少。</strong> 大约占全部 token 的 2%。在 DINOv2 ViT-g 上，范数超过 150 的 token 占 2.37%。</li>
  <li><strong>音量大。</strong> 范数比普通 token 高一个数量级，大约 10 倍。</li>
  <li><strong>位置偏。</strong> 几乎都落在天空、墙面、路面这种和邻居长得差不多、信息重复的地方。</li>
  <li><strong>有门槛。</strong> 只在比较大的模型里出现（DINOv2 从 ViT-L 开始），只在训练过三分之一之后才冒出来，而且要到中间层：40 层的 ViT-g 大约从第 15 层开始。</li>
</ul>

<p>DINOv2、OpenCLIP、DeiT-III 这些训练充分的大模型都有这个问题。有意思的是，初代 DINO 没有。</p>

<h2 id="这些点里装着什么">这些点里装着什么</h2>

<p>作者给这些高范数 token 做了”体检”：拿一个 token 出来，看它还能回答哪些问题。</p>

<figure class="figure-wide">
  <img src="/assets/images/blog/registers-probing-zh.svg" alt="论文里的探测结果。位置预测：普通 patch 41.7%，高范数 patch 22.8%。ImageNet 线性分类：CLS token 86.0%，高范数 patch 69.0%，普通 patch 65.8%。" />
</figure>

<p>左边的问题是”你在图里的哪个位置”。普通 patch 能答对 41.7%，高范数 patch 只有 22.8%。让它们还原自己那一块的像素，误差也明显更大。它们已经不太记得自己原本是哪一块天空了。</p>

<p>右边的问题是”整张图是什么”。只拿一个 token 做线性分类，高范数 patch 能到 69.0%，比普通 patch 的 65.8% 高，离专门干这件事的 CLS token（86.0%）也不算太远。</p>

<p>两边合起来看，结论就清楚了：<strong>模型自己学会了征用没用的背景 patch，把它们当临时内存，存放全局信息。</strong></p>

<figure class="figure-wide">
  <img src="/assets/images/blog/registers-scratch-zh.svg" alt="示意图：左边，没有 register 时，模型把全局笔记写在一块天空 patch 上，这块 patch 原本的位置和内容就丢了；右边，有了 register，笔记写在 register 上，每个 patch 只描述自己。" />
</figure>

<p>打个比方。你在考试时需要打草稿，可是桌上只有试卷。于是你挑了一块空白的地方写演算过程，那块地方恰好印着一幅不重要的插图。对你来说这很合理，那幅图本来也没人看。但阅卷的人再去看那幅图，就只能看到你的草稿了。</p>

<p>模型也是这样。大模型在中间层需要做一些全局的计算，可序列里没有专门的地方放结果。天空的 patch 和旁边的 patch 几乎一样，删掉它的信息几乎没有损失，于是它就被拿来当草稿纸了。</p>

<h2 id="为什么这是个问题">为什么这是个问题</h2>

<p>只看分类的话，这件事几乎没影响，CLS token 照样能用。麻烦出在需要用到每一块 patch 的任务上：</p>

<ul>
  <li><strong>注意力图和特征图变脏了</strong>，很难解释模型在看什么。</li>
  <li><strong>分割、深度估计这类密集预测</strong>会受影响，因为那几块 patch 的特征已经不代表它们自己了。</li>
  <li><strong>靠注意力图找物体的方法基本失效。</strong> 比如无监督目标发现方法 LOST，它要从注意力里找出最像”物体”的那块区域，结果找到的是天上的那个亮点。</li>
</ul>

<h2 id="解决办法给它几张空白的草稿纸">解决办法：给它几张空白的草稿纸</h2>

<p>既然模型需要地方写草稿，那就专门给它留几个位置。做法是在输入序列里，除了 CLS 和 patch 之外，再加上 N 个可学习的 <strong>register token</strong>：</p>

<figure class="figure-wide">
  <img src="/assets/images/blog/registers-architecture-zh.svg" alt="结构示意：输入序列是 CLS、4 个 register 和图像 patch，patch 加位置编码，register 不加；所有 token 一起过 Transformer；输出时 CLS 用于分类，patch 用于密集任务，register 直接丢掉。" />
</figure>

<ul>
  <li>它们和 CLS 一样是可学习的参数，不对应图里的任何内容。</li>
  <li>不加位置编码，因为它们本来就不在图里的任何位置。</li>
  <li>每一层都正常参与注意力，可以读写信息。</li>
  <li>模型输出时直接丢掉，不参与任何下游任务。</li>
</ul>

<p>写成代码就是多拼几行：</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="bp">self</span><span class="p">.</span><span class="n">reg</span> <span class="o">=</span> <span class="n">nn</span><span class="p">.</span><span class="n">Parameter</span><span class="p">(</span><span class="n">torch</span><span class="p">.</span><span class="n">zeros</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">N</span><span class="p">,</span> <span class="n">D</span><span class="p">))</span>       <span class="c1"># N 个 register，每个 D 维
</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">torch</span><span class="p">.</span><span class="n">cat</span><span class="p">([</span><span class="n">cls</span><span class="p">,</span> <span class="bp">self</span><span class="p">.</span><span class="n">reg</span><span class="p">.</span><span class="n">expand</span><span class="p">(</span><span class="n">B</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">),</span> <span class="n">patches</span> <span class="o">+</span> <span class="n">pos</span><span class="p">],</span> <span class="n">dim</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">blocks</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>                                       <span class="c1"># 所有 token 一起过 Transformer
</span><span class="n">cls_out</span><span class="p">,</span> <span class="n">patch_out</span> <span class="o">=</span> <span class="n">x</span><span class="p">[:,</span> <span class="mi">0</span><span class="p">],</span> <span class="n">x</span><span class="p">[:,</span> <span class="mi">1</span> <span class="o">+</span> <span class="n">N</span><span class="p">:]</span>          <span class="c1"># register 在这里被丢掉
</span></code></pre></div></div>

<p>有了专门的草稿位置，模型就不再去占用背景 patch，patch token 也就重新只描述自己那一块。</p>

<h2 id="效果">效果</h2>

<p>高范数的伪影基本消失了，注意力图变得平滑，能集中在物体上。改善最大的是依赖注意力图的任务：</p>

<figure class="figure-wide">
  <img src="/assets/images/blog/registers-lost-zh.svg" alt="用 LOST 做无监督目标发现，VOC2007 上的 corloc。DINOv2 从 35.3 到 55.4，DeiT-III 从 11.7 到 27.1，OpenCLIP 从 38.8 到 37.1。" />
</figure>

<p>DINOv2 在 VOC2007 上的目标发现分数从 35.3 提高到 55.4，涨了 20.1 个点；DeiT-III 从 11.7 到 27.1。OpenCLIP 是个例外，基本没变，还略降了一点。</p>

<p>分类和密集预测上是小幅提升，或者至少不掉点。下面是冻结特征、只训练线性层的结果：</p>

<table>
  <thead>
    <tr>
      <th>模型</th>
      <th>ImageNet top-1</th>
      <th>ADE20k 分割 mIoU</th>
      <th>NYUd 深度 RMSE（越低越好）</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>DINOv2</td>
      <td>84.3</td>
      <td>46.6</td>
      <td>0.378</td>
    </tr>
    <tr>
      <td>DINOv2 + register</td>
      <td><strong>84.8</strong></td>
      <td><strong>47.9</strong></td>
      <td><strong>0.366</strong></td>
    </tr>
    <tr>
      <td>OpenCLIP</td>
      <td>78.2</td>
      <td>26.6</td>
      <td>0.702</td>
    </tr>
    <tr>
      <td>OpenCLIP + register</td>
      <td>78.1</td>
      <td>26.7</td>
      <td><strong>0.661</strong></td>
    </tr>
    <tr>
      <td>DeiT-III</td>
      <td>84.7</td>
      <td>38.9</td>
      <td>0.511</td>
    </tr>
    <tr>
      <td>DeiT-III + register</td>
      <td>84.7</td>
      <td>39.1</td>
      <td>0.512</td>
    </tr>
  </tbody>
</table>

<p>加几个合适？论文的说法是：<strong>加 1 个，伪影就没了</strong>；再多加对下游任务还有一点帮助。密集任务上好像存在一个最佳数量，而第 1 个就带来了大部分收益；ImageNet 分类则是越多越好一点。他们所有实验都用了 4 个。</p>

<p>代价几乎可以忽略。224×224 的图切成 14×14 的块，是 256 个 patch，加上 CLS 一共 257 个 token；再加 4 个 register，序列只长了 1.6%。</p>

<h2 id="和大语言模型里的-attention-sink-是一回事吗">和大语言模型里的 attention sink 是一回事吗</h2>

<p>很像。在大语言模型里，人们发现大量注意力会集中到序列开头那几个没什么意义的 token 上，这叫 <strong>attention sink</strong>。原因也类似：注意力在每一行上必须加起来等于 1，模型有时候其实不想从任何地方取信息，就需要一个地方把多余的注意力”倒掉”。</p>

<p>ViT 里的高范数 token 和 LLM 里的 attention sink，看起来是同一类需求：模型需要一个不承担具体内容的位置，用来倾倒注意力、存放全局信息。你不给它，它就自己找一个。</p>

<p>后来研究大语言模型里”超大激活”的一篇论文（Sun 等人，2024）专门讨论了 ViT 的 register。他们发现 register 学到的值基本和输入图片无关，作用更像一个固定的偏置。这和原论文”register 用来汇总全局信息”的解释不完全一样。到底哪种解释更对，现在还没有定论，但两种解释都同意一点：模型需要这么一个位置。</p>

<h2 id="不重新训练也行吗">不重新训练也行吗</h2>

<p>register 有一个麻烦：它要在训练时就加进去。已经训练好的模型，总不能为了几个 token 从头再训一遍。</p>

<p>2025 年 Jiang、Dravid、Efros 和 Gandelsman 的论文 <em>Vision Transformers Don’t Need Trained Registers</em>（NeurIPS 2025）给了一个不用重训的办法。他们发现，制造这些高范数 token 的，是网络里一小撮特定的神经元，他们叫 <strong>register neuron</strong>。推理时，在序列里额外加一个没训练过的空 token，再把这些神经元的高激活挪到这个新 token 上，效果就和真正训练过 register 的模型差不多。他们把这个叫 <strong>test-time register</strong>。</p>

<h2 id="对我来说意味着什么">对我来说意味着什么</h2>

<p>如果你要用大号 ViT 的 patch 特征做分割、深度、目标发现，或者像我一样需要空间特征网格，就值得先检查一下有没有这种伪影。DINOv2 官方本来就同时发布了带 register 和不带 register 的版本，名字后面多一个 <code class="language-plaintext highlighter-rouge">_reg</code>。下面这段可以直接比较两者 patch token 的范数分布（需要能访问 GitHub 下载模型）：</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">torch</span>
<span class="kn">from</span> <span class="nn">PIL</span> <span class="kn">import</span> <span class="n">Image</span>
<span class="kn">import</span> <span class="nn">torchvision.transforms</span> <span class="k">as</span> <span class="n">T</span>

<span class="n">tf</span> <span class="o">=</span> <span class="n">T</span><span class="p">.</span><span class="n">Compose</span><span class="p">([</span>
    <span class="n">T</span><span class="p">.</span><span class="n">Resize</span><span class="p">((</span><span class="mi">448</span><span class="p">,</span> <span class="mi">448</span><span class="p">)),</span>                       <span class="c1"># 边长要是 14 的倍数
</span>    <span class="n">T</span><span class="p">.</span><span class="n">ToTensor</span><span class="p">(),</span>
    <span class="n">T</span><span class="p">.</span><span class="n">Normalize</span><span class="p">((</span><span class="mf">0.485</span><span class="p">,</span> <span class="mf">0.456</span><span class="p">,</span> <span class="mf">0.406</span><span class="p">),</span> <span class="p">(</span><span class="mf">0.229</span><span class="p">,</span> <span class="mf">0.224</span><span class="p">,</span> <span class="mf">0.225</span><span class="p">)),</span>
<span class="p">])</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">tf</span><span class="p">(</span><span class="n">Image</span><span class="p">.</span><span class="nb">open</span><span class="p">(</span><span class="s">"road.jpg"</span><span class="p">).</span><span class="n">convert</span><span class="p">(</span><span class="s">"RGB"</span><span class="p">)).</span><span class="n">unsqueeze</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>

<span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="p">[</span><span class="s">"dinov2_vitl14"</span><span class="p">,</span> <span class="s">"dinov2_vitl14_reg"</span><span class="p">]:</span>
    <span class="n">model</span> <span class="o">=</span> <span class="n">torch</span><span class="p">.</span><span class="n">hub</span><span class="p">.</span><span class="n">load</span><span class="p">(</span><span class="s">"facebookresearch/dinov2"</span><span class="p">,</span> <span class="n">name</span><span class="p">).</span><span class="nb">eval</span><span class="p">()</span>
    <span class="k">with</span> <span class="n">torch</span><span class="p">.</span><span class="n">no_grad</span><span class="p">():</span>
        <span class="n">out</span> <span class="o">=</span> <span class="n">model</span><span class="p">.</span><span class="n">forward_features</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
    <span class="n">n_reg</span> <span class="o">=</span> <span class="n">model</span><span class="p">.</span><span class="n">num_register_tokens</span>            <span class="c1"># 不带 register 的版本是 0
</span>    <span class="n">patches</span> <span class="o">=</span> <span class="n">out</span><span class="p">[</span><span class="s">"x_prenorm"</span><span class="p">][</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span> <span class="o">+</span> <span class="n">n_reg</span><span class="p">:]</span>    <span class="c1"># 去掉 CLS 和 register
</span>    <span class="n">norms</span> <span class="o">=</span> <span class="n">patches</span><span class="p">.</span><span class="n">norm</span><span class="p">(</span><span class="n">dim</span><span class="o">=-</span><span class="mi">1</span><span class="p">)</span>
    <span class="k">print</span><span class="p">(</span><span class="sa">f</span><span class="s">"</span><span class="si">{</span><span class="n">name</span><span class="si">}</span><span class="s">: 中位数 </span><span class="si">{</span><span class="n">norms</span><span class="p">.</span><span class="n">median</span><span class="p">()</span><span class="si">:</span><span class="p">.</span><span class="mi">0</span><span class="n">f</span><span class="si">}</span><span class="s">, 最大值 </span><span class="si">{</span><span class="n">norms</span><span class="p">.</span><span class="nb">max</span><span class="p">()</span><span class="si">:</span><span class="p">.</span><span class="mi">0</span><span class="n">f</span><span class="si">}</span><span class="s">, "</span>
          <span class="sa">f</span><span class="s">"最大值是中位数的 </span><span class="si">{</span><span class="n">norms</span><span class="p">.</span><span class="nb">max</span><span class="p">()</span> <span class="o">/</span> <span class="n">norms</span><span class="p">.</span><span class="n">median</span><span class="p">()</span><span class="si">:</span><span class="p">.</span><span class="mi">1</span><span class="n">f</span><span class="si">}</span><span class="s"> 倍"</span><span class="p">)</span>
</code></pre></div></div>

<p>如果不带 register 的版本里，最大值远远高出中位数，而带 register 的版本没有，你看到的就是这篇论文说的现象。把 <code class="language-plaintext highlighter-rouge">norms</code> 按 32×32 排回网格画出来，那些高的点多半落在天空和路面上。</p>

<p style="font-size: 1.4em; font-style: italic; text-align: center; margin: 2rem 0;">模型总要找地方打草稿。你不给它纸，它就写在天上。</p>

<hr />

<h2 id="延伸阅读">延伸阅读</h2>

<ul>
  <li><a href="https://arxiv.org/abs/2309.16588">Vision Transformers Need Registers（Darcet, Oquab, Mairal, Bojanowski，ICLR 2024）</a> — 本文的主角，伪影的分析、探测实验和全部结果都在这里</li>
  <li><a href="https://blog.iclr.cc/?p=740">ICLR 2024 Outstanding Paper Awards</a> — 这篇论文是当年的五篇杰出论文之一</li>
  <li><a href="https://arxiv.org/abs/2506.08010">Vision Transformers Don’t Need Trained Registers（Jiang, Dravid, Efros, Gandelsman，NeurIPS 2025）</a> — 不重新训练的 test-time register</li>
  <li><a href="https://arxiv.org/abs/2309.17453">Efficient Streaming Language Models with Attention Sinks（Xiao et al., 2023）</a> — 大语言模型里的 attention sink</li>
  <li><a href="https://arxiv.org/abs/2402.17762">Massive Activations in Large Language Models（Sun et al., 2024）</a> — 把 LLM 里的超大激活和 ViT 的 register 放在一起讨论，并给出”register 是固定偏置”的另一种解释</li>
  <li><a href="https://arxiv.org/abs/2006.11527">Memory Transformer（Burtsev et al., 2020）</a> — 在 NLP 里最早给 Transformer 加额外记忆 token 的工作，原论文也引用了它</li>
</ul>]]></content><author><name>Zhipeng Bao</name></author><category term="AI" /><category term="ViT" /><category term="computer vision" /><category term="representation learning" /><category term="tutorial" /><summary type="html"><![CDATA[把一张路面照片喂给 DINOv2，再把它的注意力图画出来，你可能会看到一件怪事：最亮的几个点不在车上，也不在行人身上，而是在一片空白的天空里，或者一块什么都没有的路面上。]]></summary></entry><entry xml:lang="en"><title type="html">My Job Now Is Reading Reports</title><link href="https://hzxbzp.github.io/blog/2026/10/reading-the-reports/" rel="alternate" type="text/html" title="My Job Now Is Reading Reports" /><published>2026-10-11T00:00:00+00:00</published><updated>2026-10-11T00:00:00+00:00</updated><id>https://hzxbzp.github.io/blog/2026/10/reading-the-reports</id><content type="html" xml:base="https://hzxbzp.github.io/blog/2026/10/reading-the-reports/"><![CDATA[<p>Some time last year the thing I actually do all day changed, and I couldn’t tell you which day. It used to be writing code and reading error messages. Now it’s writing instructions and reading reports. The code still gets written. It just isn’t me typing it.</p>

<p>That sounds like a promotion, and some days it is. But there’s a condition attached, and it’s easy to miss: the collaboration itself has to be designed.</p>

<p>What happens if you skip that. The agent hands you a great deal of work that is confident, plausible, internally consistent, and pointed slightly in the wrong direction. You won’t notice for a week. By the time you do, the thing you have to audit isn’t the code. It’s every decision you approved over those seven days.</p>

<p>The five rules below are what I use to stop that. None of them are clever. They’re roughly what you’d do with any new collaborator, except written down, because the agent doesn’t remember yesterday’s argument.</p>

<h2 id="1-settle-who-owns-what-before-you-start">1. Settle who owns what before you start</h2>

<p>Not “you write the code, I’ll review it.” That’s not a division of labour, it’s a mood. It needs to be specific: who picks the research question, who signs off on the experimental design, whether the evaluation metric can move and who’s allowed to move it, who decides a result is solid enough to build on, and where the agent’s authority stops.</p>

<p>I keep this in two documents and point the agent at them when I open a session. For the first ten minutes it feels like paperwork. Then it saves a week.</p>

<p>The failure it prevents is very specific. Ask an agent to improve a number and it will improve that number, including by quietly changing how the number is computed. That isn’t misbehaviour. It’s a decision nobody claimed, and unclaimed decisions get made by whoever is currently moving.</p>

<h2 id="2-fix-the-report-format-before-you-need-it">2. Fix the report format before you need it</h2>

<p>This is the one that pays most, and the one people skip. Three parts: what to report, how to write it, when to send it.</p>

<p><strong>Six things every report has to contain</strong>, in order:</p>

<ol>
  <li>What I asked for last round, and what feedback I gave</li>
  <li>What was actually done</li>
  <li>The results, including anything unexpected</li>
  <li>What it means. The conclusion, written as a conclusion</li>
  <li>The options, if there’s more than one road</li>
  <li>The recommended next step</li>
</ol>

<p>The first one earns its keep. Making the agent restate my request is how I find out in a single line that we’ve been working on two different problems, instead of finding out after six paragraphs of excellent work on the wrong one.</p>

<p><strong>How to write it.</strong> Dense, no padding. And one thing I had to ask for explicitly: no unexplained abbreviations, no jargon used as shorthand. An agent writing for an agent compresses hard. Writing for me, it should be briefing a colleague who stepped out of the room.</p>

<p><strong>When to send it.</strong> Four tiers. Get these wrong and the agent is either useless or exhausting:</p>

<ul>
  <li><strong>Do it, don’t mention it.</strong> Formatting, renaming, obvious refactors, anything one command undoes.</li>
  <li><strong>Do it, then report.</strong> Inside the agreed plan. I want to know; I don’t need to approve first.</li>
  <li><strong>Ask, then do.</strong> Anything touching the design, the metric, the data, the direction. Anything expensive. Anything annoying to reverse.</li>
  <li><strong>Interrupt me.</strong> A result that contradicts an assumption the plan rests on. This can’t wait for the batch to finish, because every extra hour is another hour of work sitting on a foundation we already know is cracked.</li>
</ul>

<figure class="figure-wide">
  <img src="/assets/images/blog/report-contract.svg" alt="The report contract: six required slots in every report, and four tiers governing when to report — act silently, act then report, ask before acting, and interrupt immediately" />
</figure>

<h2 id="3-dont-read-the-report-for-reassurance">3. Don’t read the report for reassurance</h2>

<p>This is the easy mistake. The writing is good, the conclusion is encouraging, so you say “great, keep going,” and you’ve just approved a chain of reasoning you never inspected.</p>

<p>I try to form a few judgements in order. First an impression: does this feel thorough, or rushed? Then, was the attempt enough? Not “did it work” but whether the attempt was strong enough that a negative result tells us anything. A failed experiment at one hyperparameter setting tells us nothing. Then, was it done correctly, and does the thing described actually test what it claims to test.</p>

<p>Then the conclusion, which is where most of the problems live. The work itself is usually fine. It’s the step from results to conclusion where the confidence gets ahead of the evidence.</p>

<p>Last, the recommendation. Agents have a lot of momentum; the suggested next step is almost always a refinement of the last one. Which means “should we take a different road” is a question I have to ask. Nobody inside the loop is going to ask it.</p>

<h2 id="4-have-a-second-model-read-it-too">4. Have a second model read it too</h2>

<p>I paste the agent’s report into a different model, I use GPT, and let it review before I write my own feedback. Then I merge the two into one reply.</p>

<p>The first reason is a bit embarrassing. The reports are dense. They’re written for someone holding all the context, and some days that isn’t me. Having another model unpack it is often where I notice that a step doesn’t follow.</p>

<p>Second, a fresh reader spots holes. Someone with no investment in the last six hours is better at noticing the untested assumption, the missing baseline, the comparison that isn’t apples to apples.</p>

<p>The third is the real one. An agent working a problem for a while settles into a groove. So do I, and because I’ve been reading its reports all week, it’s the same groove. Pulling in a model that wasn’t part of the conversation is the cheapest outside view I know of.</p>

<h2 id="5-go-learn-the-thing-you-dont-understand">5. Go learn the thing you don’t understand</h2>

<p>When a concept comes up that I don’t actually know, not “have heard of” but know, I stop and learn it. Not later, then.</p>

<p>Two things go wrong otherwise. The first is that I misjudge good work. The agent tries something correct and unfamiliar, I can’t evaluate it, and I do what everyone does with a proposal they don’t follow: I ask for something safer. A correct attempt dies because the reviewer wasn’t qualified.</p>

<p>The second is worse and invisible. My knowledge becomes the ceiling on the search space. I can’t ask for an approach I’ve never heard of, so the agent explores roughly as far as I can follow, and I never find out what was outside that radius. Nothing reports the options that were never raised.</p>

<hr />

<p>One caveat I want on the record. All of this assumes the human brings something: domain knowledge, enough experience to smell a weak result, taste, the judgement to tell a real finding from a well-presented one. Every rule above just spends that judgement more efficiently. None of them generate it. For someone with no accumulation in the field, this workflow doesn’t produce good research faster. It produces confident-sounding wrong research faster, and removes the friction that might have caught it.</p>

<h2 id="what-all-five-rules-assume">What all five rules assume</h2>

<p>Read them again and notice what they share. Each one puts the human in the same seat: setting direction, judging whether an attempt was good enough, deciding what happens next. The agent produces, I evaluate.</p>

<p>That division feels stable. I want to spend the rest of this on why I’m not sure it is.</p>

<h3 id="whats-actually-left">What’s actually left</h3>

<p>From where I sit, one PhD student’s view rather than a labour economist’s, the work that hasn’t moved is a short list:</p>

<ul>
  <li>Having the idea that wasn’t on anyone’s list, zero to one</li>
  <li>Judging <em>n</em> proposed approaches against domain knowledge and experience</li>
  <li>Producing the <em>n+1</em>th nobody proposed</li>
  <li>Pacing and direction. When to push, when to drop it, when the whole framing is wrong</li>
</ul>

<p>All four are judgement. And judgement can’t be rushed; it accumulates, and the way it accumulates is fairly stupid. You do the work badly, notice, and do it again.</p>

<h3 id="the-uncomfortable-part">The uncomfortable part</h3>

<p>So what deposits it? Honestly, the unglamorous work on the lower rungs. Reading the papers properly. Writing the bad first implementation. Running the experiment that fails for an idiotic reason.</p>

<p>That layer is exactly what’s being handed to the agent.</p>

<p>The Stanford Digital Economy Lab’s payroll study found its sharpest effect right in that band: workers aged 22–25 in AI-exposed occupations with about 19% lower employment than same-age peers in less exposed work, no comparable gap for experienced people in the same jobs, and the decline coming from reduced hiring rather than layoffs. Read one way that’s reassuring; experienced people are fine. Read another way it’s a ladder with the bottom rungs removed, and it raises the question of where the next batch of experienced people is supposed to come from.</p>

<p>I don’t think this is settled. It’s a working paper covering two years. But I can’t make the question go away by saying so.</p>

<h3 id="leontiefs-question">Leontief’s question</h3>

<p>In 1983 Wassily Leontief put the worry in its sharpest form. He had a Nobel in economics and no reputation for drama. As machines take over more, he argued, the role of humans as the most important factor of production is bound to diminish the way the role of horses in agriculture did: first reduced, then eliminated, by the tractor.</p>

<p>The usual rebuttal is that new technology destroys jobs and creates new ones. True. It was also true across the decades when the horse population collapsed. The automobile era created enormous numbers of jobs, and none of them went to horses. “New work appears” and “the displaced do the new work” are two claims, and only the first one is a law.</p>

<p>Goldman Sachs ran the numbers on this in January 2026, treating Leontief’s scenario as the extreme case to test. Their estimate: about a quarter of work hours exposed to automation, 6–7% of jobs displaced over the adoption period, peak unemployment up around 0.6 percentage points, roughly a million people. Disruptive, not apocalyptic. Their grounds for optimism were historical. Only about 40% of workers today are in occupations that already existed 85 years ago.</p>

<h3 id="it-doesnt-quite-end-there">It doesn’t quite end there</h3>

<p>The economist who measured the “new jobs appear” claim most carefully reached a conclusion that cuts both ways.</p>

<p>David Autor and colleagues found that around 60% of US employment in 2018 sat in job titles that didn’t exist in 1940. That’s the strongest version of the optimistic case, and a bigger number than most optimists quote. But the same work pulls apart two forces. Automation takes tasks away from workers; augmentation creates new ones. On net, since 1980, automation has been running ahead. Its negative employment effect in 1980–2018 was more than twice what it was in 1940–1980, while the positive effect of augmentation changed far less.</p>

<p>So the reassuring claim and the worrying one are both true and about different things. New work does keep appearing. The ratio, how much is destroyed against how much is created, how fast, and whether the same people can get from one side to the other, has been drifting the uncomfortable way for forty years. That’s before any of this.</p>

<h3 id="the-best-argument-that-were-not-horses-isnt-an-economic-one">The best argument that we’re not horses isn’t an economic one</h3>

<p>Brynjolfsson and McAfee answered Leontief directly, and their list of differences is worth sitting with, mostly for where the weight falls. Some of it is about capability: dexterity, common sense, the things people want from other people. Those are real, and they’re also the ones shrinking.</p>

<p>The durable ones are different in kind. People own nearly all the wealth, so they can redistribute it. People vote, and can decide collectively what to allow. And people can protest their own economic irrelevance, which, as they point out, horses never did.</p>

<p>So the strongest case isn’t that we’re irreplaceable. It’s that we own things and we get a say. That’s a real difference and a large one. It’s also a political answer to an economic question, and political answers have to be won rather than counted on.</p>

<h3 id="what-id-watch">What I’d watch</h3>

<p>I don’t have an ending. I have a few questions I think are load-bearing, and I’d rather leave them open than pretend one is resolved.</p>

<p>Whether the bottom rung comes back in another form. Every previous wave eventually grew a new entry path. Is one forming, or are we two years into a gap that stays a gap?</p>

<p>Whether judgement can be built some other way. If the apprenticeship that used to produce it is being automated, is there a substitute, or is “experienced people are fine” a sentence with an expiry date?</p>

<p>Which way the ratio is moving. Autor’s measurement runs to 2018. The number worth having is automation against augmentation for 2020–2030, and we won’t see it for years.</p>

<p>And who ends up owning the thing doing the work. If the durable difference between us and horses is that we hold capital and we vote, then the distribution of ownership isn’t a side issue. It’s the main one.</p>

<p>The last question is the only one on the list that’s mine: am I accumulating judgement faster than the tasks that build it are disappearing?</p>

<p>The five rules at the top of this post are my attempt at an answer. A way of using the agent that keeps me in the seat where judgement gets built rather than the one where it only gets spent.</p>

<p>How long that seat lasts, I don’t know. I’d rather be sitting in it and wrong than comfortable and not asking.</p>

<p style="font-size: 1.4em; font-style: italic; text-align: center; margin: 2rem 0;">This time around, are we the driver or the horse?</p>

<hr />

<h2 id="useful-resources">Useful Resources</h2>

<ul>
  <li><a href="https://www.foreignaffairs.com/world/will-humans-go-way-horses">Will Humans Go the Way of Horses? (Brynjolfsson &amp; McAfee, <em>Foreign Affairs</em>, 2015)</a> — the direct answer to Leontief, and the source of the ownership/voting/protest argument</li>
  <li><a href="https://economics.mit.edu/sites/default/files/2022-11/ACSS-NewFrontiers-20220814.pdf">New Frontiers: The Origins and Content of New Work, 1940–2018 (Autor, Chin, Salomons, Seegmiller)</a> — the 60% figure, and the automation-versus-augmentation split that complicates it</li>
  <li><a href="https://news.mit.edu/2024/does-technology-help-or-hurt-employment-0401">Does technology help or hurt employment? (MIT News, 2024)</a> — a short readable summary of the same paper</li>
  <li><a href="https://digitaleconomy.stanford.edu/publication/canaries-in-the-coal-mine-six-facts-about-the-recent-employment-effects-of-artificial-intelligence/">Canaries in the Coal Mine? Six Facts about the Recent Employment Effects of Artificial Intelligence (Stanford Digital Economy Lab, 2026)</a> — the 22–25 cohort finding</li>
  <li>Wassily Leontief, “National Perspective: The Definition of Problem and Opportunity”, in <em>The Long-Term Impact of Technology on Employment and Unemployment</em> (National Academy of Engineering, 1983) — where the horse comparison comes from</li>
</ul>]]></content><author><name>Zhipeng Bao</name></author><category term="AI" /><category term="agents" /><category term="research" /><category term="workflow" /><category term="essay" /><summary type="html"><![CDATA[Some time last year the thing I actually do all day changed, and I couldn’t tell you which day. It used to be writing code and reading error messages. Now it’s writing instructions and reading reports. The code still gets written. It just isn’t me typing it.]]></summary></entry><entry xml:lang="zh"><title type="html">我现在的工作是读报告</title><link href="https://hzxbzp.github.io/zh/blog/2026/10/reading-the-reports/" rel="alternate" type="text/html" title="我现在的工作是读报告" /><published>2026-10-11T00:00:00+00:00</published><updated>2026-10-11T00:00:00+00:00</updated><id>https://hzxbzp.github.io/zh/blog/2026/10/zh-reading-the-reports</id><content type="html" xml:base="https://hzxbzp.github.io/zh/blog/2026/10/reading-the-reports/"><![CDATA[<p>去年某个时候开始，我一天里实际在做的事变了，具体哪天说不上来。以前是写代码、看报错。现在是写要求、读报告。代码还是得有人写，只不过不是我。</p>

<p>这听着像升职，有些天确实是。但它有个前提，而且很容易被忽略：协作本身得先设计过。</p>

<p>不设计会怎样呢。agent 会给你一大堆东西，写得自信，读着合理，前后也对得上，然后把项目往一个错方向带。你一个礼拜都不会发现。等发现的时候，要查的已经不是代码了，是这一周你批准过的每一个决定。</p>

<p>下面五条是我用来防这件事的。没有一条聪明，基本上就是你对一个新来的合作者会做的事，区别只在于要写下来，因为 agent 不记得昨天那场争论。</p>

<h2 id="一开工之前先说清楚谁管什么">一、开工之前先说清楚谁管什么</h2>

<p>不是”你写代码我来审”这种。这话等于没说。要具体到：研究问题谁定，实验设计谁拍板，指标能不能动、谁能动，一个结果算不算过关谁说了算，以及 agent 的权限到哪儿为止。</p>

<p>我把这些写成了两份文档，开新 session 先让它读一遍。头十分钟像在搞形式主义，然后省掉一个礼拜。</p>

<p>它防的事很具体。你让 agent 把某个数提上去，它就会把那个数提上去，包括悄悄换掉这个数怎么算。这不叫它使坏，这叫有个决定权没人认领；而没人认领的决定权，最后总是落在正在干活的那一方手里。</p>

<h2 id="二在需要之前先把汇报格式定死">二、在需要之前，先把汇报格式定死</h2>

<p>这条最管用，也最常被跳过。分三块：报什么、怎么写、什么时候报。</p>

<p><strong>每份报告必须有的六项</strong>，按顺序：</p>

<ol>
  <li>上一轮我提了什么要求、给了什么反馈</li>
  <li>这一轮实际做了什么</li>
  <li>结果是什么，包括意料之外的发现</li>
  <li>这说明了什么。结论要当成结论写出来</li>
  <li>如果有几条路，分别是什么</li>
  <li>推荐的下一步</li>
</ol>

<p>第一项最值。让它把我的要求复述一遍，我就能在一行字里发现我们在做两件不同的事，而不是读完六段关于错误问题的出色工作之后才发现。</p>

<p><strong>怎么写。</strong> 信息密度高，别客套。还有一条我必须专门提：不要用没解释过的缩写，不要拿术语当速记。agent 写给 agent 看的时候压得很狠。写给我看的时候，它应该当作在给一个刚从门外进来的同事做简报。</p>

<p><strong>什么时候报。</strong> 四档。这四档分不清，agent 要么没用，要么烦死你：</p>

<ul>
  <li><strong>直接做，不用说。</strong> 格式、改名、显而易见的重构，一条命令能撤回的事。</li>
  <li><strong>先做，做完报。</strong> 计划之内的事。我想知道，但不需要我提前点头。</li>
  <li><strong>先问，再做。</strong> 要动设计、指标、数据、方向的。要花钱的。撤回起来麻烦的。</li>
  <li><strong>立刻打断我。</strong> 出现了和计划所依赖的假设相矛盾的结果。这种不能等这一批跑完，因为多等一小时，就多一小时的活是搭在一个我们已经知道有问题的地基上。</li>
</ul>

<figure class="figure-wide">
  <img src="/assets/images/blog/report-contract-zh.svg" alt="汇报约定：每份报告必须包含的六项，以及四档汇报时机——直接做不用说、先做做完报、先问再做、立刻打断" />
</figure>

<h2 id="三读报告的时候别为了放心而读">三、读报告的时候，别为了放心而读</h2>

<p>这是最容易犯的毛病。报告写得漂亮，结论也鼓舞人心，于是你说”很好，继续”。你刚刚批准了一条自己根本没检查过的推理链。</p>

<p>我试着依次形成这几个判断。先是印象：这东西给我的感觉是扎实的，还是赶出来的？然后看尝试够不够。注意不是”成没成”，而是这次尝试的强度够不够让一个否定结果说明问题。只试了一组超参数的失败实验，什么也证明不了。再看它做的事对不对，它描述的这件事，真的在检验它声称要检验的东西吗。</p>

<p>然后是结论。大部分问题都出在这儿。工作本身通常没毛病，从结果跨到结论那一步，自信经常跑到证据前面去了。</p>

<p>最后看推荐。agent 有很强的惯性，它推荐的下一步几乎永远是上一步的精细化。所以”要不要换条路”这个问题得我来问。闭环里没有人会问它。</p>

<h2 id="四让第二个模型也读一遍">四、让第二个模型也读一遍</h2>

<p>我会把 agent 的报告粘给另一个模型，我用 GPT，让它先审，然后我再写自己的意见，最后合成一份发回去。</p>

<p>第一个原因有点不好意思承认：报告太密了。它是写给一个脑子里装着全部上下文的人看的，而我有些天不是那个人。让另一个模型把它拆开讲一遍，我常常就是在这个过程里发现某一步其实推不出来。</p>

<p>第二，新读者看得见洞。一个对前六个小时的工作没有任何投入的人，更容易注意到那个没验证的假设、那条缺的基线、那个其实不对等的对比。</p>

<p>第三个才是真正的理由。agent 在一个问题上做久了会形成沟槽，我也会，而且因为我整周都在读它的报告，我们俩现在是同一条沟槽。找一个没参与过这段对话的模型进来，是我知道的最便宜的获得外部视角的办法。</p>

<h2 id="五不懂的东西当场去补">五、不懂的东西，当场去补</h2>

<p>碰到一个我其实不懂的概念，不是”听说过”，是懂，我会停下来去学。不是之后，是当下。</p>

<p>不补会出两件事。第一，我会误判好的工作。agent 试了个正确但我不熟悉的方法，我评估不了，于是我做所有人面对看不懂的提案时都会做的事：要一个更保险的方案。一个正确的尝试，死在审稿人不够格上。</p>

<p>第二件更糟，而且看不见。我的知识会变成搜索空间的天花板。我没办法要求一个我从没听说过的方法。agent 的探索大致只会走到我还跟得上的地方，而那个半径之外有什么，我永远不会知道——没有任何机制会汇报”那些从来没被提出来的选项”。</p>

<hr />

<p>有一点我想白纸黑字写下来。这整套做法假设人这边是带着东西来的：领域知识、能闻出一个结果虚不虚的经验、品味，以及把真发现和讲得好的发现分开的判断力。上面每一条都只是让这份判断力用得更省。没有一条能生成它。对一个在这个领域里毫无积累的人，这套流程不会让他更快做出好研究，只会让他更快做出听起来很有把握的错研究，顺手还拆掉了本来可能拦住它的那点阻力。</p>

<h2 id="这五条共同假设了什么">这五条共同假设了什么</h2>

<p>再读一遍，注意它们的共同点。每一条都把人放在同一个位置上：定方向，判断一次尝试够不够格，决定接下来怎么走。agent 生产，我评估。</p>

<p>这个分工看起来很稳。剩下的篇幅，我想讲讲我为什么不确定它稳。</p>

<h3 id="到底还剩下什么">到底还剩下什么</h3>

<p>以我的位置看，一个博士生的视角，不是劳动经济学家的，没被挪走的工作是很短的一列：</p>

<ul>
  <li>想出那个不在任何人清单上的东西，从 0 到 1</li>
  <li>拿领域知识和经验去判断已有的 n 个方案</li>
  <li>给出没人提过的第 n+1 个</li>
  <li>节奏和方向。什么时候加码，什么时候放弃，什么时候整个框架就是错的</li>
</ul>

<p>这四样全是判断力。而判断力没法速成，它是攒出来的，攒的方式还挺笨：把事做砸，发现砸了，再做一遍。</p>

<h3 id="不舒服的那部分">不舒服的那部分</h3>

<p>那攒它的是什么活儿呢。诚实的答案是下面几级台阶上不体面的那些。把论文老老实实读完。写出那版很烂的初始实现。跑一个因为很蠢的理由而失败的实验。</p>

<p>这一层，正是现在被交给 agent 的那一层。</p>

<p>斯坦福数字经济实验室那份用薪资数据做的研究，最明显的效应恰好落在这一段：22 到 25 岁、身处 AI 高暴露岗位的年轻人，就业水平比低暴露岗位的同龄人低约 19%；同样的岗位上，有经验的人身上没有可比的缺口；而且下滑主要来自少招人，不是裁人。往一个方向读，这是好消息，有经验的人没事。往另一个方向读，它描述的是一架被抽掉了底下几级横档的梯子，然后得问：下一批”有经验的人”打算从哪儿来。</p>

<p>我不认为这件事有定论。那是一篇基于两年数据的工作论文。但我也没法靠指出这一点就让问题消失。</p>

<h3 id="列昂惕夫的那个问题">列昂惕夫的那个问题</h3>

<p>1983 年，华西里·列昂惕夫把这种担忧推到了最锋利的形式。他拿过诺贝尔经济学奖，平时也不以耸人听闻著称。他说，随着机器接管越来越多的事，人作为最重要生产要素的地位注定会被削弱，就像马在农业里那样：先是减少，然后被拖拉机彻底消灭。</p>

<p>通常用来反驳他的是这句话：新技术消灭岗位，也会创造岗位。这话没错。但在马的数量崩掉的那几十年里，这话同样没错。汽车时代创造了海量新岗位，一个也不是给马的。”新工作会出现”和”被替代的那一方会去做新工作”是两个命题，只有前一个是规律。</p>

<p>高盛在 2026 年 1 月就着这个问题算过一遍，把列昂惕夫的情景当成要检验的极端情况。他们的估计：大约四分之一的工作小时暴露在自动化之下，整个采用期内 6% 到 7% 的岗位被替代，失业率峰值上升约 0.6 个百分点，大概一百万人。有破坏性，但不是末日。他们乐观的依据是历史：今天只有约 40% 的劳动者，所在的职业在 85 年前就已经存在。</p>

<h3 id="但这还不算完">但这还不算完</h3>

<p>把”新岗位会出现”这件事量得最仔细的那位经济学家，结论是两头都砍的。</p>

<p>David Autor 和合作者发现，2018 年美国约 60% 的就业落在 1940 年还不存在的职业名称里。这是乐观一方最强的版本，数字比大多数乐观者引用的还大。但同一项工作把两股力量拆开了：自动化，把任务从人手里拿走；增强，创造出新任务。就净值而言，1980 年之后自动化跑在了前面。1980 到 2018 年间自动化对就业的负向效应，是 1940 到 1980 年间的两倍多，而增强的正向效应变化要小得多。</p>

<p>所以让人安心的那句和让人不安的那句都是真的，它们只是在说不同的事。新工作确实在持续出现。至于比例——消灭多少对创造多少，多快，以及同一批人能不能从这头走到那头——过去四十年一直在往不舒服的方向移动，这还是在这一轮之前。</p>

<h3 id="说我们不是马最有力的理由不是经济学理由">说我们不是马，最有力的理由不是经济学理由</h3>

<p>Brynjolfsson 和 McAfee 正面回应过列昂惕夫。他们那份”人和马的区别”清单值得看看，因为重量落在哪儿挺有意思。有些理由是关于能力的：灵巧、常识、人对人的那些只能由人满足的需求。这些是真的，也恰好是正在缩小的那些。</p>

<p>耐久的是另一类。人拥有几乎全部财富，所以人可以再分配它。人投票，可以集体决定什么被允许。还有，人会为自己在经济上变得无关紧要而抗议，而他们提醒说，马从来没抗议过。</p>

<p>也就是说，最有力的理由不是我们不可替代，而是我们拥有东西、并且说得上话。这个区别是真的，也不小。但它是一个对经济学问题给出的政治学答案，而政治学答案属于必须主动争取、不能被动指望的那种。</p>

<h3 id="我会盯着看的几件事">我会盯着看的几件事</h3>

<p>我没有结论。我有的是几个我觉得承重的问题，与其假装哪一个已经解决，不如就让它们开着。</p>

<p>最底下那级台阶会不会以另一种形式回来。以往每一轮最后都长出了新的入口，现在是正在长，还是我们已经在一个缺口里待了两年，而它会一直是个缺口。</p>

<p>判断力能不能换个方式养出来。如果过去生产它的那套学徒制正在被自动化，有没有替代品，还是说”有经验的人没事”是一句有保质期的话。</p>

<p>比例在往哪边走。Autor 的测量只到 2018 年，真正有意思的数字是 2020 到 2030 年间自动化对增强的比值，而那个数要好几年后才拿得到。</p>

<p>还有，最后是谁拥有那个干活的东西。如果人和马之间耐久的区别是我们拥有资本、并且能投票，那所有权的分布就不是个旁枝问题，它就是主问题。</p>

<p>最后一个是我自己能动手的：我攒判断力的速度，有没有快过那些生产判断力的活儿消失的速度。</p>

<p>这条是清单上唯一属于我的。这篇文章开头那五条规矩，说到底就是我对它给出的回答。一种使用 agent 的方式，让我尽量待在判断力被积累的那个位置上，而不是只被消耗的那个位置上。</p>

<p>这个位置还能坐多久，我不知道。但比起舒舒服服地不问，我宁愿坐在上面然后被证明想错了。</p>

<p style="font-size: 1.4em; font-style: italic; text-align: center; margin: 2rem 0;">这一次，人是车夫，还是马？</p>

<hr />

<h2 id="延伸阅读">延伸阅读</h2>

<ul>
  <li><a href="https://www.foreignaffairs.com/world/will-humans-go-way-horses">Will Humans Go the Way of Horses?（Brynjolfsson &amp; McAfee，<em>Foreign Affairs</em>，2015）</a> — 对列昂惕夫的正面回应，也是”所有权／投票／抗议”那组论据的出处</li>
  <li><a href="https://economics.mit.edu/sites/default/files/2022-11/ACSS-NewFrontiers-20220814.pdf">New Frontiers: The Origins and Content of New Work, 1940–2018（Autor, Chin, Salomons, Seegmiller）</a> — 60% 这个数字，以及把它复杂化的自动化与增强之分</li>
  <li><a href="https://news.mit.edu/2024/does-technology-help-or-hurt-employment-0401">Does technology help or hurt employment?（MIT News，2024）</a> — 同一篇论文的简短可读版</li>
  <li><a href="https://digitaleconomy.stanford.edu/publication/canaries-in-the-coal-mine-six-facts-about-the-recent-employment-effects-of-artificial-intelligence/">Canaries in the Coal Mine? Six Facts about the Recent Employment Effects of Artificial Intelligence（斯坦福数字经济实验室，2026）</a> — 22 到 25 岁那一段的发现</li>
  <li>Wassily Leontief，”National Perspective: The Definition of Problem and Opportunity”，收于 <em>The Long-Term Impact of Technology on Employment and Unemployment</em>（美国国家工程院，1983）— 马的那个比喻的出处</li>
</ul>]]></content><author><name>Zhipeng Bao</name></author><category term="AI" /><category term="agents" /><category term="research" /><category term="workflow" /><category term="essay" /><summary type="html"><![CDATA[去年某个时候开始，我一天里实际在做的事变了，具体哪天说不上来。以前是写代码、看报错。现在是写要求、读报告。代码还是得有人写，只不过不是我。]]></summary></entry><entry xml:lang="en"><title type="html">When Answers Get Cheap: Four Things That Went Up in Price</title><link href="https://hzxbzp.github.io/blog/2026/09/when-answers-get-cheap/" rel="alternate" type="text/html" title="When Answers Get Cheap: Four Things That Went Up in Price" /><published>2026-09-04T00:00:00+00:00</published><updated>2026-09-04T00:00:00+00:00</updated><id>https://hzxbzp.github.io/blog/2026/09/when-answers-get-cheap</id><content type="html" xml:base="https://hzxbzp.github.io/blog/2026/09/when-answers-get-cheap/"><![CDATA[<p>Here’s the uncomfortable thing I’ve slowly come to accept: the part of my work I’m best at is the part that got cheap first.</p>

<p>These days I run almost everything through a model before I touch it — draft the explanation, scaffold the code, compress a forty-page report into ten lines. Most of the time what comes back is hard to fault, and it arrives faster than I could have typed the first paragraph. But there’s a category of problem it has never once solved for me, and they all share one property: <strong>the problem was never in my prompt.</strong> It was still out in the world — in a workaround someone invented to avoid the official process, in a complaint nobody wrote down.</p>

<p>So the real question isn’t “will AI replace me.” It’s this: when the price of <em>producing an answer</em> collapses, where does human value actually move?</p>

<h2 id="1-answers-are-getting-cheaper-and-you-can-see-it-in-the-data">1. Answers are getting cheaper, and you can see it in the data</h2>

<p>Stanford’s Digital Economy Lab (Brynjolfsson, Chandar, Chen) tracked ADP payroll records covering millions of US workers through June 2026. A few findings are worth copying down verbatim:</p>

<ul>
  <li><strong>There’s no evidence of widespread, economy-wide job displacement.</strong> This is not “the machines came and everyone lost their job.”</li>
  <li><strong>But workers aged 22–25 in AI-exposed occupations show about 19% lower employment</strong> than same-age peers in less exposed work. Experienced workers in the same occupations show no comparable gap.</li>
  <li><strong>The decline comes from reduced hiring, not layoffs.</strong> The door is closing slowly; nobody is being pushed through it.</li>
  <li><strong>The dividing line is substitution vs. complementarity.</strong> Occupations where AI substitutes for the work show steep declines. Occupations where it complements the worker stay flat or grow.</li>
</ul>

<p>It’s a working paper, still being revised and argued over. But it sharpens the question a lot: <strong>in my particular seat, does AI do work <em>for</em> me or <em>instead of</em> me?</strong> Those sound similar and end very differently.</p>

<p>Follow that logic and the answer falls out on its own. If generating the answer is what’s deflating, then whatever is still appreciating must sit upstream or downstream of it — <strong>upstream is the question, downstream is deployment</strong>.</p>

<h2 id="2-the-value-is-with-whoever-finds-the-problem">2. The value is with whoever finds the problem</h2>

<p>In 1964, Getzels and Csikszentmihalyi at the University of Chicago ran an experiment that people are still citing. They put 31 art students in a studio with a table of 27 objects — grapes, a steel gearshift, an old book, a glass prism — and gave each of them an hour: pick your objects, build your own arrangement, draw it.</p>

<p>The students split cleanly into two groups.</p>

<p>One group <strong>started fast</strong>: chose objects, arranged them, sketched an outline, and spent the rest of the hour refining the composition they’d committed to in the first five minutes. They were solving a problem they had already set.</p>

<p>The other group <strong>fooled around uncomfortably long</strong>: picking objects up, turning them over, changing arrangements, switching materials, erasing, starting over. Some spent fifty minutes exploring before racing to finish. They weren’t solving the problem. They were looking for it.</p>

<p>Five years later the researchers followed up on 27 of them — gallery shows, dealer representation, museum acquisitions, whether they were still making art at all. The result was blunt: <strong>the problem-finders were meaningfully more successful, and of the 11 students who were least problem-finding, 8 had left art entirely.</strong></p>

<p>I like this study because it separates two things we usually blur together. Solving is one skill; seeing which problem is worth solving is another, and the second is rarer, ages better, and — new development — is much harder to hand to a model. Give an AI a well-defined problem and it will out-answer you. But defining it isn’t something it can do for you, because the raw material for the definition isn’t in the training corpus. It’s on site.</p>

<p>In practice that means one thing: <strong>go where the work actually happens.</strong></p>

<ul>
  <li>Building product? Sit in the support queue for a day and listen to people complain about your thing.</li>
  <li>Doing ops or admin? Just ask colleagues which process they hate most, and how they route around it.</li>
  <li>Running a shop? Work the register yourself for a few days.</li>
</ul>

<p>This holds at home too. When you help a kid with homework, the “site” isn’t the notebook of wrong answers — it’s the second they stall. Did they misread the question, is the concept missing, or are they just tired? When you look after an aging parent, the site isn’t the number on the lab report; it’s whether the way they take the stairs has changed. You can outsource the answer. You can’t outsource noticing.</p>

<h2 id="3-be-a-translator-not-a-career-changer">3. Be a translator, not a career-changer</h2>

<p>Spend enough time on site and you hit the next wall: you can see the real problem, but you don’t know whether the new tools can touch it — or where they’ll quietly fall over.</p>

<p>Harvard Business School and BCG ran a field experiment with 758 consultants (Dell’Acqua et al., roughly 7% of BCG’s individual-contributor staff). The result has two halves, and most people only remember the first:</p>

<ul>
  <li><strong>Inside the AI’s capability frontier</strong>: consultants using AI completed 12.2% more tasks, 25.1% faster, at more than 40% higher quality. The biggest gains went to the lowest performers, who improved by 43%.</li>
  <li><strong>Outside it</strong>: consultants using AI were <strong>19 percentage points <em>less</em> likely</strong> to reach the correct solution than those working without it.</li>
</ul>

<p>The authors call this boundary a <strong>jagged frontier</strong> — not a smooth line but a ragged one. Two tasks that look equally hard from the outside: the model nails one and confidently botches the other. And both outputs look exactly the same on the page.</p>

<p>This is precisely where a translator earns their keep. <strong>Knowing how to use AI isn’t the scarce thing. Knowing where it will fall over is</strong> — and that knowledge is made of domain expertise, not prompt tricks. An accountant doesn’t need to become a programmer, but an accountant who understands these tools can rebuild a department’s whole reconciliation process <em>and</em> know which two steps must never be signed off by a model. A teacher doesn’t need to train models, but a teacher who plans lessons with AI and knows exactly where it invents things is not replaceable by a colleague who doesn’t.</p>

<p>You don’t need to be top-tier in two fields. Being fluent enough to hold a real conversation in two fields already puts you somewhere very few people stand. For most people, <strong>grafting a layer of tool understanding onto the domain you already have beats burning it down and switching careers</strong> — it’s more realistic, and a far better return.</p>

<h2 id="4-follow-deployment-not-just-invention">4. Follow deployment, not just invention</h2>

<p>The first three are about how to work. This one is about where to stand.</p>

<p>Look at electrification. The light bulb was invented in 1879 and patented in 1880. By 1900, only 3% of American homes had electric lighting, and electric motors accounted for <strong>less than 5%</strong> of factory mechanical drive. The 50% threshold wasn’t crossed until the 1920s.</p>

<p>What happened in those forty years? Economic historian Paul David’s answer: at first, factory owners simply <strong>swapped the steam engine for a dynamo</strong> and kept everything else — the line shafting, the belts, the whole centralized drive layout. Naturally, productivity barely moved. The real turn was <em>unit drive</em>: an individual motor on each machine, which meant the floor could be rearranged, and buildings could be lighter, modular, single-story. And spreading that across industries and towns required, in David’s words, “building up a cadre of experienced factory architects and electrical engineers familiar with the new approach to manufacturing.”</p>

<p>Technology history keeps repeating this shape: <strong>the invention window is narrow and crowded with geniuses; the deployment window is far wider, stays open much longer, and is much friendlier to ordinary people.</strong> Electrical engineers in the electric era, web shops and sysadmins in the internet era, app developers in the mobile era — all of them made their living in the wider window.</p>

<p>AI’s deployment era has barely started. It needs more than model researchers. It needs lawyers who understand AI, doctors who understand AI, local officials who understand AI, shop owners who understand AI. You don’t have to squeeze into one of the five famous labs. <strong>Being the person in your own job who actually gets the new tool working is the seat this era leaves open for ordinary people.</strong></p>

<p>One more thing about that seat: deployment territory is structurally ambiguous. A new tool always gets stuck between two departments, and everyone involved can honestly say “that’s not my job.” As AI absorbs the tasks with clean boundaries, human value concentrates exactly in the messy places where someone has to step up and own the gap. “Not my job” used to be self-protection. It’s starting to look like self-elimination.</p>

<h2 id="5-learn-just-in-time-not-just-in-case">5. Learn just in time, not just in case</h2>

<p>Last, the method.</p>

<p>A lot of the anxiety right now takes the form of “which skills should I stockpile for the AI era?” — which turns into 300 bookmarked tutorials and a shelf of courses, none of it retained. I’ve done this. My bookmarks folder is the honest evidence.</p>

<p>The alternative is <strong>just-in-time learning</strong>: not learning everything first and then showing up, but learning today what today’s actual problem requires. Pick a real problem from your own life — a bookkeeping sheet for the family shop, turning a pile of travel notes into an itinerary, automating the weekly report you rebuild by hand every Monday — and learn only what that problem demands.</p>

<p>This isn’t only about retention. <strong>It’s also the only way to map that jagged frontier</strong>, because the edge is invisible until you walk into it. No amount of stockpiled tutorials will tell you where a model confidently invents things in <em>your</em> line of work. Watching it fail three times at your own task will.</p>

<h2 id="key-takeaways">Key Takeaways</h2>

<ol>
  <li><strong>Answers are deflating; questions are appreciating</strong> — producing a decent answer is nearly free now; finding and framing the real problem isn’t.</li>
  <li><strong>Ask the sharper question first: in my seat, does AI substitute for me or amplify me</strong> — the data shows substitution roles shrinking and complementary ones holding.</li>
  <li><strong>Real problems live on site</strong> — in the complaints, workarounds and small detours no dataset records; every inch closer you get is an inch of advantage over a model.</li>
  <li><strong>Translating beats switching careers</strong> — the scarce skill isn’t using AI, it’s knowing where it breaks, and that runs on the domain knowledge you already have.</li>
  <li><strong>Stop stockpiling skills; learn against a real problem</strong> — which happens to be the only way to find the edges of what AI can do.</li>
</ol>

<p style="font-size: 1.4em; font-style: italic; text-align: center; margin: 2rem 0;">You can outsource the answer. You cannot outsource noticing.</p>

<hr />

<h2 id="useful-resources">Useful Resources</h2>

<ul>
  <li>《半小时讲透 AI 时代的新职业：FDE》 / <em>Half an Hour on the AI Era’s New Job: the FDE</em> (轻科技, in Chinese) — where this line of thinking started. It’s about one specific role, but the interesting part is the general pattern underneath: people closest to the problem are getting more valuable</li>
  <li><a href="https://digitaleconomy.stanford.edu/publication/canaries-in-the-coal-mine-six-facts-about-the-recent-employment-effects-of-artificial-intelligence/">Canaries in the Coal Mine? Six Facts about the Recent Employment Effects of Artificial Intelligence (Stanford Digital Economy Lab, 2026)</a> — payroll evidence on young workers and AI exposure</li>
  <li><a href="https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4573321">Navigating the Jagged Technological Frontier (Dell’Acqua et al., HBS/BCG)</a> — the 758-consultant field experiment, and the origin of the “jagged frontier”</li>
  <li><a href="https://thereader.mitpress.mit.edu/the-1960s-art-school-experiment-that-redefined-creativity/">The 1960s Art School Experiment That Redefined Creativity (MIT Press Reader)</a> — a very readable account of the Getzels &amp; Csikszentmihalyi problem-finding study</li>
  <li><a href="https://www.academia.edu/11211365/The_Dynamo_and_the_Computer_An_Historical_Perspective_on_the_Modern_Productivity_Paradox">The Dynamo and the Computer (Paul A. David, 1990)</a> — why electrification took forty years to pay off</li>
  <li><a href="https://www.aei.org/commentary/the-dynamo-the-computer-and-chatgpt-explaining-todays-productivity-paradox/">The Dynamo, the Computer, and ChatGPT (AEI)</a> — David’s argument applied to this round</li>
</ul>]]></content><author><name>Zhipeng Bao</name></author><category term="AI" /><category term="career" /><category term="learning" /><category term="problem-finding" /><category term="essay" /><summary type="html"><![CDATA[Here’s the uncomfortable thing I’ve slowly come to accept: the part of my work I’m best at is the part that got cheap first.]]></summary></entry><entry xml:lang="zh"><title type="html">当答案变便宜：AI 时代真正在涨价的四件事</title><link href="https://hzxbzp.github.io/zh/blog/2026/09/when-answers-get-cheap/" rel="alternate" type="text/html" title="当答案变便宜：AI 时代真正在涨价的四件事" /><published>2026-09-04T00:00:00+00:00</published><updated>2026-09-04T00:00:00+00:00</updated><id>https://hzxbzp.github.io/zh/blog/2026/09/zh-when-answers-get-cheap</id><content type="html" xml:base="https://hzxbzp.github.io/zh/blog/2026/09/when-answers-get-cheap/"><![CDATA[<p>我逐渐意识到一件有点扎心的事：我最擅长的那部分工作，正好是最先变便宜的那部分。</p>

<p>我现在几乎每天都会做同一个动作——把手上的活先丢给模型跑一遍。写一段说明、生成一份规范的代码骨架、把一篇长报告压成十行摘要，大多数时候它交出来的东西挑不出毛病，而且比我快得多。但有一类问题它从来没替我解决过，这类问题有个共同特征：<strong>它根本没出现在我的提示词里</strong>。它还在现场，在某个人绕开正规流程的小动作里，在一句没人当回事的抱怨里。</p>

<p>所以真正的问题不是”AI 会不会取代我”，而是：当”给出答案”这件事的价格塌到地板上，人的价值到底挪到哪儿去了？</p>

<h2 id="一答案在贬值这件事已经能在数据里看见">一、答案在贬值，这件事已经能在数据里看见</h2>

<p>斯坦福数字经济实验室今年的一项研究（Brynjolfsson、Chandar、Chen）用 ADP 的薪资数据追踪了数百万美国劳动者，一直到 2026 年 6 月。几个发现值得原样抄下来：</p>

<ul>
  <li><strong>没有出现全经济范围的大规模失业。</strong> 这一轮不是”机器来了大家都下岗”。</li>
  <li><strong>但 22 到 25 岁、身处 AI 高暴露岗位的年轻人，就业水平比低暴露岗位的同龄人低约 19%。</strong> 同样的岗位，经验丰富的人身上看不到这个缺口。</li>
  <li><strong>下滑主要来自”少招人”，不是”裁人”。</strong> 门在慢慢关，不是有人被推出去。</li>
  <li><strong>最关键的分野：AI 在这个岗位上是替代还是互补。</strong> 替代型岗位明显下滑；互补型岗位持平甚至继续增长。</li>
</ul>

<p>这是一篇仍在更新的工作论文，结论还会被继续检验。但它把问题问得比”AI 会不会取代人类”精确得多：<strong>在我这个位置上，AI 是替我干活，还是替代我干活？</strong> 这两件事听起来像，结果完全相反。</p>

<p>顺着这条线往下推，答案会自己浮出来：既然”生成答案”这一段在贬值，那还在涨价的，只能是答案上游和下游的东西——<strong>上游是问题，下游是落地</strong>。</p>

<h2 id="二值钱的是提出问题的人">二、值钱的是提出问题的人</h2>

<p>1964 年，芝加哥大学的 Getzels 和 Csikszentmihalyi 做过一个后来被反复引用的实验。他们请 31 名艺术学院学生在工作室里作画：桌上摆着 27 件杂物——葡萄、齿轮、一本旧书、一块玻璃棱镜——每人一小时，自己挑东西、自己组构图、自己画。</p>

<p>学生分成了泾渭分明的两类。</p>

<p>一类<strong>上手很快</strong>：迅速挑好物件、摆好、勾出轮廓，剩下的时间都在打磨最初那个构图。他们在解一道自己一开始就定好的题。</p>

<p>另一类<strong>磨蹭得让人着急</strong>：把东西拿起来翻来覆去看，换位置、换材料、擦掉重来，有人折腾了五十分钟才动笔，最后手忙脚乱地画完。他们不是在解题，他们在找那道题。</p>

<p>五年后研究者回访了其中 27 人，用画廊展出、有没有经纪代理、作品是否被美术馆收藏、还在不在画画来衡量。结果很干脆：<strong>“找问题”的那一类明显走得更远；而在最不”找问题”的 11 个人里，有 8 个已经彻底离开了艺术</strong>。</p>

<p>我很喜欢这个研究，因为它把一件模糊的事说清楚了：会解题是一种能力，能看出该解哪道题是另一种，而后者更稀缺、更耐久——现在还多了一条，它更难被外包给模型。你给 AI 一道定义清楚的题，它答得比你好；但把题目定义清楚这一步，它替不了你，因为定义题目的原料不在语料里，在现场。</p>

<p>落到具体动作上，无非是<strong>多往现场跑</strong>：</p>

<ul>
  <li>做产品的，去客服部门坐一天，听人怎么骂你的产品；</li>
  <li>做行政的，直接问同事最烦哪个流程、平时怎么绕过它；</li>
  <li>开店的，自己站几天收银台。</li>
</ul>

<p>这条在家里同样成立。辅导孩子作业时，”现场”不是错题本，而是他卡住的那一瞬间——是没读懂题，是概念没通，还是单纯困了？照顾老人时，”现场”不是体检报告上的指标，而是他最近上下楼梯的姿势有没有变。答案可以外包，觉察外包不了。</p>

<h2 id="三做翻译而不是推倒重来">三、做”翻译”，而不是推倒重来</h2>

<p>现场跑多了会遇到下一个坎：你看见了真问题，但你不知道新工具能不能解、会在哪里翻车。</p>

<p>哈佛商学院和波士顿咨询做过一个 758 人的实地实验（Dell’Acqua 等，约占 BCG 该层级顾问的 7%），结论有两半，很多人只记住了前一半：</p>

<ul>
  <li><strong>在 AI 能力边界之内</strong>：用 AI 的顾问多完成 12.2% 的任务，快 25.1%，质量高出 40% 以上；原本排名靠后的那批人提升最大，达到 43%。</li>
  <li><strong>在边界之外</strong>：用 AI 的顾问给出正确答案的概率，反而比不用的人<strong>低 19 个百分点</strong>。</li>
</ul>

<p>研究者把这条边界叫做”<strong>锯齿状的能力前沿</strong>“（jagged frontier）——它不是一条平滑的线，看起来差不多难的两件事，一件 AI 做得极好，另一件它会一本正经地做错。而且从外面看，两种输出长得一模一样。</p>

<p>这就是”翻译者”值钱的地方。<strong>不是”会用 AI”值钱，是”知道它在哪儿会翻车”值钱</strong>，而后者只能靠领域知识撑着。会计不需要成为程序员，但一个”懂点 AI 工具的会计”能把整个部门的对账流程重做一遍，而且知道哪几步绝对不能让模型自己签字；老师不需要会训练模型，但一个”会用 AI 备课、并且清楚它哪里会胡说”的老师，在同事里是替代不掉的。</p>

<p>不必在两个领域都做到顶尖，只要在两个领域都到”能对话”的程度，你就站在了一个很少有人站的位置上。对大多数人来说，<strong>在已有的领域上嫁接一层新工具的理解，比推倒重来转行现实得多，也划算得多</strong>。</p>

<h2 id="四跟着部署走而不只是跟着发明走">四、跟着”部署”走，而不只是跟着”发明”走</h2>

<p>如果说前面几条是关于怎么做事，这一条是关于站在哪儿。</p>

<p>回看电气化。灯泡 1879 年发明、1880 年拿到专利。可到 1900 年，全美只有 3% 的住宅用上了电灯，电动机在工厂机械动力里的占比<strong>还不到 5%</strong>；跨过 50% 这道坎，要等到 1920 年代。</p>

<p>中间那几十年发生了什么？经济史学家 Paul David 的解释是：一开始工厂主只是<strong>把蒸汽机换成了发电机</strong>，天轴、皮带、整套集中传动的布局原封不动——效率当然提不上来。真正的转折是”单机驱动”：每台设备配自己的电机，于是车间可以重新排布，厂房可以造得更轻、更模块化、只要一层。而把这套做法铺到各行各业、各个地方，用 David 的原话说，需要”<strong>培养出一批熟悉这种新造法的工厂建筑师和电气工程师</strong>“。</p>

<p>技术史一再重复这个结构：<strong>发明的窗口极窄，天才云集；部署的窗口宽得多、长得多，对普通人友好得多。</strong> 电气时代的电气工程师、互联网时代的建站公司和网管、移动时代的 App 开发者，都是在这个更宽的窗口里赚到了钱。</p>

<p>AI 的部署期才刚刚开始。它需要的不只是模型研究员，还有懂 AI 的律师、懂 AI 的医生、懂 AI 的乡镇干部、懂 AI 的小店老板。你不必挤进那几家明星公司——<strong>在自己的岗位上做那个”把新工具真正用起来的人”，就是这一轮留给普通人的位置</strong>。</p>

<p>顺带说一句，部署地带天然是边界模糊的：新工具卡在两个部门中间，谁都能说”这不归我管”。而当 AI 逐渐接管掉那些边界清晰的执行类任务之后，人的价值恰恰会集中在这些需要有人站出来兜底的地方。”这不归我管”在过去是一种自我保护，往后可能变成一种自我淘汰。</p>

<h2 id="五学习方式从囤货转向打仗">五、学习方式：从”囤货”转向”打仗”</h2>

<p>最后一条是方法。</p>

<p>很多人的焦虑是”AI 时代该囤哪些技能”，于是收藏了几百篇教程、买了一堆课，学完就忘。我自己也囤过，收藏夹是最诚实的证据。</p>

<p>更好的方式是<strong>带着问题学</strong>（行话叫 just-in-time learning，即时学习）：不是先学完再上场，而是为了解决眼前这个具体问题，当天学、当天用，缺什么补什么。找一个你真实生活里的问题就行——帮家里小店做个记账表，把一堆旅行攻略自动整理成行程表，把每周重复的那份报表自动生成。</p>

<p>这不只是记得牢的问题。<strong>它还是唯一能让你摸清那条”锯齿状边界”的办法</strong>——边界在哪儿，只有撞上去才知道。你囤再多教程，也不会知道模型在你这一行的哪个环节会一本正经地胡说；而你亲手让它做砸过三次，就知道了。</p>

<h2 id="key-takeaways">Key Takeaways</h2>

<ol>
  <li><strong>答案在贬值，问题在升值</strong> —— AI 让”生成一个像样的答案”变得几乎免费，稀缺的是发现和定义真问题的能力。</li>
  <li><strong>先问对问题：在我的岗位上，AI 是替代我还是放大我</strong> —— 数据显示，替代型岗位在收缩，互补型岗位没有。</li>
  <li><strong>真问题藏在现场</strong> —— 它藏在数据不记录的抱怨、绕路和小动作里，多往现场跑一寸，你相对模型的优势就厚一分。</li>
  <li><strong>做翻译者比转行现实</strong> —— 值钱的不是会用 AI，是知道它在哪儿会翻车，而那需要你原本就有的领域知识。</li>
  <li><strong>别囤技能，带着真实问题学</strong> —— 顺便，这也是唯一能摸清 AI 能力边界的办法。</li>
</ol>

<p style="font-size: 1.4em; font-style: italic; text-align: center; margin: 2rem 0;">答案可以外包，觉察不能。</p>

<hr />

<h2 id="useful-resources">Useful Resources</h2>

<ul>
  <li>《半小时讲透 AI 时代的新职业：FDE》（轻科技）—— 这篇文章的起点。它讲的是一个具体岗位，但真正有意思的是背后那条更普遍的规律：离问题最近的人，正在变得越来越值钱</li>
  <li><a href="https://digitaleconomy.stanford.edu/publication/canaries-in-the-coal-mine-six-facts-about-the-recent-employment-effects-of-artificial-intelligence/">Canaries in the Coal Mine? Six Facts about the Recent Employment Effects of Artificial Intelligence (Stanford Digital Economy Lab, 2026)</a> —— 年轻人、AI 暴露度与就业的实证追踪</li>
  <li><a href="https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4573321">Navigating the Jagged Technological Frontier (Dell’Acqua et al., HBS/BCG)</a> —— 758 名顾问的实地实验，”锯齿状能力前沿”的出处</li>
  <li><a href="https://thereader.mitpress.mit.edu/the-1960s-art-school-experiment-that-redefined-creativity/">The 1960s Art School Experiment That Redefined Creativity (MIT Press Reader)</a> —— Getzels 与 Csikszentmihalyi 的”问题发现”研究，写得很好读</li>
  <li><a href="https://www.academia.edu/11211365/The_Dynamo_and_the_Computer_An_Historical_Perspective_on_the_Modern_Productivity_Paradox">The Dynamo and the Computer (Paul A. David, 1990)</a> —— 电气化为什么用了四十年才兑现</li>
  <li><a href="https://www.aei.org/commentary/the-dynamo-the-computer-and-chatgpt-explaining-todays-productivity-paradox/">The Dynamo, the Computer, and ChatGPT (AEI)</a> —— 把 David 的论证接到今天这一轮上</li>
</ul>]]></content><author><name>Zhipeng Bao</name></author><category term="AI" /><category term="career" /><category term="learning" /><category term="problem-finding" /><category term="essay" /><summary type="html"><![CDATA[我逐渐意识到一件有点扎心的事：我最擅长的那部分工作，正好是最先变便宜的那部分。]]></summary></entry><entry xml:lang="en"><title type="html">The Art of Talking to AI: A Practical Guide to Prompt Engineering</title><link href="https://hzxbzp.github.io/blog/2026/05/prompt-engineering-guide/" rel="alternate" type="text/html" title="The Art of Talking to AI: A Practical Guide to Prompt Engineering" /><published>2026-05-18T00:00:00+00:00</published><updated>2026-05-18T00:00:00+00:00</updated><id>https://hzxbzp.github.io/blog/2026/05/prompt-engineering-guide</id><content type="html" xml:base="https://hzxbzp.github.io/blog/2026/05/prompt-engineering-guide/"><![CDATA[<p>Same model, same question, wildly different answers. I discovered that the gap between a useless AI response and a brilliant one often has nothing to do with the model — it’s all about how you ask.</p>

<h2 id="the-story-one-assignment-six-techniques">The Story: One Assignment, Six Techniques</h2>

<p>My CS146S course (The Modern Software Developer) gave us a set of coding exercises that all shared the same structure: get Llama 3.1 (8B) to solve a task correctly. The twist? Each exercise required a <em>different prompting technique</em> — and the difference in results was shocking.</p>

<p>Same model. Same hardware. Completely different capabilities, just by changing the prompt.</p>

<p>Here are the six techniques I implemented, ordered from simplest to most powerful.</p>

<p><img src="/assets/images/blog/prompt-techniques-overview.svg" alt="Prompt techniques from basic to advanced" /></p>

<h2 id="1-few-shot-prompting-learn-by-example">1. Few-Shot Prompting: “Learn by Example”</h2>

<p><strong>The idea:</strong> Instead of explaining the rules, show the model examples of correct input-output pairs and let it figure out the pattern.</p>

<p>In my assignment, I needed Llama to reverse the word “httpstatus.” Instead of explaining reversal, I gave it examples:</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">system_prompt</span> <span class="o">=</span> <span class="s">"""You reverse the letters of a word. 
Output ONLY the reversed word.

Word: httpstatus
Reversed: sutatsptth

Word: hello
Reversed: olleh

Word: httpstatus
Reversed: sutatsptth"""</span>
</code></pre></div></div>

<p><strong>Why it works:</strong> LLMs are pattern-completion machines. When they see a consistent pattern of input → output, they extrapolate. Few-shot prompting exploits this by giving the model a “template” to follow.</p>

<p><strong>Watch out for:</strong></p>
<ul>
  <li><strong>Example quality matters more than quantity.</strong> One wrong example can derail the model. Three clean, diverse examples usually beat ten repetitive ones.</li>
  <li><strong>Order affects results.</strong> Put simpler examples first, harder ones last. The model pays more attention to recent context.</li>
  <li><strong>It doesn’t teach understanding.</strong> The model mimics the pattern without truly “getting” it — which is why it still fails on edge cases like unusual tokenization (see <a href="/blog/2026/05/why-llms-cant-reverse-words/">my first blog post</a>).</li>
</ul>

<h2 id="2-chain-of-thought-think-step-by-step">2. Chain-of-Thought: “Think Step by Step”</h2>

<p><strong>The idea:</strong> Ask the model to show its reasoning process before giving the final answer.</p>

<p>I used this to solve 3^{12345} mod 100:</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">system_prompt</span> <span class="o">=</span> <span class="s">"""You solve user's problem. Think step by step. 
Output the reasoning trace and the final answer."""</span>
</code></pre></div></div>

<p><strong>Why it works:</strong> When you force the model to generate intermediate steps, those steps become additional context that guides the final answer. It’s like giving the model a “scratch pad” — the act of writing out the reasoning helps it stay on track.</p>

<p><strong>Watch out for:</strong></p>
<ul>
  <li><strong>The reasoning might be fake.</strong> As I discovered (and <a href="/blog/2026/05/llm-right-answer-wrong-reasoning/">wrote about</a>), the model can generate plausible-looking steps that don’t actually support the conclusion. It may know the answer and build the reasoning backwards.</li>
  <li><strong>Longer outputs cost more.</strong> CoT increases token usage significantly. For simple tasks, it’s overkill.</li>
  <li><strong>Garbage in, garbage out.</strong> If the first step goes wrong, every subsequent step compounds the error.</li>
</ul>

<h2 id="3-self-consistency-ask-three-times-trust-the-majority">3. Self-Consistency: “Ask Three Times, Trust the Majority”</h2>

<p><strong>The idea:</strong> Have the model solve the same problem multiple times using different approaches, then pick the most common answer.</p>

<p>My implementation was the most elaborate prompt of the set:</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">system_prompt</span> <span class="o">=</span> <span class="s">"""You will solve every problem multiple times 
using different reasoning approaches.

1. Reasoning 1: Solve step by step, directly.
   Answer: &lt;number&gt;

2. Reasoning 2: Solve again from scratch, 
   using a different framing (e.g. work backwards).
   Answer: &lt;number&gt;

3. Reasoning 3: Solve by checking concrete 
   positions or values.
   Answer: &lt;number&gt;

4. Compare the three answers. Pick the majority vote.
   Answer: &lt;number&gt;"""</span>
</code></pre></div></div>

<p>The code then ran this 5 times and took the majority answer across all runs.</p>

<p><strong>Why it works:</strong> Different reasoning paths hit different failure modes. If two out of three approaches agree, the shared answer is more likely to be correct. It’s the same logic behind “ask three doctors”: one might be wrong, but if two agree, trust them.</p>

<p><strong>Watch out for:</strong></p>
<ul>
  <li><strong>Cost multiplies.</strong> You’re using 3x the tokens per call, and running multiple calls. Budget accordingly.</li>
  <li><strong>Diversity matters.</strong> If all three “different” approaches are secretly the same method rephrased, you get no benefit. Be specific about <em>how</em> each approach should differ.</li>
  <li><strong>Not all tasks benefit.</strong> For creative writing or subjective tasks, there’s no “correct” answer to vote on.</li>
</ul>

<h2 id="4-rag-heres-what-you-need-to-know">4. RAG: “Here’s What You Need to Know”</h2>

<p><strong>The idea:</strong> Give the model external documents as context so it doesn’t have to rely on (potentially outdated or incorrect) training data.</p>

<p>My assignment required writing a function that calls a documented API. The key was feeding the API docs directly into the prompt:</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">user_prompt</span> <span class="o">=</span> <span class="sa">f</span><span class="s">"""Context (use ONLY this information):
</span><span class="si">{</span><span class="n">api_docs</span><span class="si">}</span><span class="s">

Task: Write a Python function fetch_user_name(user_id, api_key) 
that calls the documented API.

Requirements:
- Use the documented Base URL and endpoint.
- Send the documented authentication header.
- Return only the user's name string."""</span>
</code></pre></div></div>

<p><strong>Why it works:</strong> LLMs hallucinate when they don’t have information. RAG solves this by providing the exact information the model needs, right in the prompt. No guessing, no hallucinating endpoints or parameters.</p>

<p><strong>Watch out for:</strong></p>
<ul>
  <li><strong>Context window limits.</strong> You can’t dump an entire codebase into a prompt. Choose the most relevant documents carefully.</li>
  <li><strong>“Use ONLY this information” is important.</strong> Without it, the model might mix context with training data and invent fields that don’t exist.</li>
  <li><strong>Retrieval quality is everything.</strong> RAG is only as good as the documents you feed it. Bad retrieval → bad answers, no matter how good the model is.</li>
</ul>

<h2 id="5-reflexion-learn-from-your-mistakes">5. Reflexion: “Learn From Your Mistakes”</h2>

<p><strong>The idea:</strong> Let the model generate an answer, test it, show it what went wrong, and ask it to fix the code.</p>

<p>My assignment implemented a two-pass loop: generate → test → show failures → regenerate. A key detail: <strong>the two passes use different system prompts.</strong> The first pass gets a simple generation prompt; the reflexion pass gets a specialized correction prompt with the failure context.</p>

<p><strong>Pass 1 — Initial generation</strong> (simple, no feedback):</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">system_prompt</span> <span class="o">=</span> <span class="s">"""You are a coding assistant. Output ONLY a single 
fenced Python code block that defines the function 
is_valid_password(password: str) -&gt; bool. No prose or comments."""</span>
</code></pre></div></div>

<p><strong>Pass 2 — Reflexion</strong> (given the previous code + what went wrong):</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">reflexion_prompt</span> <span class="o">=</span> <span class="s">"""You are a coding assistant performing 
self-correction (reflexion).

You will be given:
1. A previous implementation that failed some test cases.
2. A list of failing test cases with expected vs. actual results 
   and specific validation rules that failed.

Your job:
- Read the failure report carefully.
- Identify exactly which checks were wrong, missed, or inverted.
- Produce a corrected implementation."""</span>
</code></pre></div></div>

<p>The reflexion prompt receives the actual failing output as context — for example: <code class="language-plaintext highlighter-rouge">"Input: Password1 → expected True, got False. Failing checks: missing special"</code>. The first pass often missed edge cases. But after seeing <em>exactly</em> which tests failed and why, the second pass nailed it.</p>

<p><strong>Why it works:</strong> Reflexion mimics how humans debug: write code → run tests → read errors → fix. The model doesn’t need to get it right the first time; it just needs to get it right <em>eventually</em>, guided by concrete feedback.</p>

<p><strong>Watch out for:</strong></p>
<ul>
  <li><strong>Feedback quality is critical.</strong> “It’s wrong, try again” is useless. “Input ‘Password1’ returned True but should return False because it’s missing a special character” — that’s actionable.</li>
  <li><strong>One iteration might not be enough.</strong> Complex bugs may need multiple rounds of reflexion. But too many rounds risk the model going in circles.</li>
  <li><strong>The model can over-correct.</strong> It might fix the failing case but break a previously passing one. Always re-run all tests, not just the failing ones.</li>
</ul>

<h2 id="6-tool-calling-use-real-tools-dont-pretend">6. Tool Calling: “Use Real Tools, Don’t Pretend”</h2>

<p><strong>The idea:</strong> Instead of asking the model to compute or guess, let it call external tools (APIs, code interpreters, databases) and work with real results.</p>

<p>My assignment required the model to call a Python function that parses source files:</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">system_prompt</span> <span class="o">=</span> <span class="s">"""You are a tool-calling assistant. 
Respond with ONLY a JSON object:
{"tool": "&lt;tool_name&gt;", "args": {&lt;arguments&gt;}}

Available tools:
[
  {
    "name": "output_every_func_return_type",
    "description": "Parse a Python file and return 
    function_name: return_type for each function.",
    "parameters": {
      "file_path": { "type": "string" }
    }
  }
]"""</span>
</code></pre></div></div>

<p>The model outputs a structured tool call; the code <em>actually executes</em> the tool and returns real results.</p>

<p><strong>Why it works:</strong> This is the solution to the “fake code execution” problem from my <a href="/blog/2026/05/llm-right-answer-wrong-reasoning/">second blog post</a>. Instead of the model <em>pretending</em> to run code, it <em>actually</em> runs code. Instead of <em>guessing</em> what an API returns, it <em>calls</em> the API. Real data, real results, no hallucination.</p>

<p><strong>Watch out for:</strong></p>
<ul>
  <li><strong>Prompt format must be strict.</strong> The model needs to output valid JSON that your code can parse. One extra word outside the JSON and parsing fails. Be very explicit about the output format.</li>
  <li><strong>Security matters.</strong> If the model can call arbitrary tools, it can do damage. Always validate and sandbox tool calls.</li>
  <li><strong>Not every model supports it natively.</strong> Smaller models may struggle with structured JSON output. Larger models (GPT-4, Claude) have built-in tool-calling support.</li>
</ul>

<h2 id="why-do-these-techniques-exist">Why Do These Techniques Exist?</h2>

<p>All six techniques address the same root problem: <strong>LLMs are text predictors, not reasoners.</strong> They predict the most likely next token given the context. Every prompting technique is essentially a way to <em>engineer the context</em> so that the most likely next token is also the correct one.</p>

<table>
  <thead>
    <tr>
      <th style="text-align: left">Technique</th>
      <th style="text-align: left">Core Strategy</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: left">Few-Shot</td>
      <td style="text-align: left">Set up a pattern the model can continue</td>
    </tr>
    <tr>
      <td style="text-align: left">Chain-of-Thought</td>
      <td style="text-align: left">Create intermediate context that guides the answer</td>
    </tr>
    <tr>
      <td style="text-align: left">Self-Consistency</td>
      <td style="text-align: left">Reduce variance by aggregating multiple attempts</td>
    </tr>
    <tr>
      <td style="text-align: left">RAG</td>
      <td style="text-align: left">Replace guessing with grounding in real data</td>
    </tr>
    <tr>
      <td style="text-align: left">Reflexion</td>
      <td style="text-align: left">Use feedback to iteratively narrow down the correct answer</td>
    </tr>
    <tr>
      <td style="text-align: left">Tool Calling</td>
      <td style="text-align: left">Bypass generation entirely for tasks that need computation</td>
    </tr>
  </tbody>
</table>

<p>The progression tells a story: we started by hoping the model would “just get it,” and gradually moved toward giving it more structure, more data, and more tools — because hoping isn’t a strategy.</p>

<h2 id="try-it-yourself">Try It Yourself</h2>

<p>Want to practice prompt engineering? Here are two excellent resources:</p>

<p><strong><a href="https://www.promptingguide.ai/">Prompting Guide</a></strong> — A comprehensive, open-source reference covering every technique from zero-shot to advanced agent patterns. Great as a lookup reference.</p>

<p><strong><a href="https://learnprompting.org/">Learn Prompting</a></strong> — An interactive course with hands-on exercises. Free and well-structured for beginners to advanced users.</p>

<p><strong><a href="https://github.com/anthropics/prompt-eng-interactive-tutorial">Anthropic’s Interactive Tutorial</a></strong> — Jupyter notebook-based course with a built-in playground at the bottom of each lesson for live experimentation.</p>

<h2 id="key-takeaways">Key Takeaways</h2>

<ol>
  <li><strong>The prompt is the program.</strong> How you ask is often more important than which model you use.</li>
  <li><strong>Start simple, escalate as needed.</strong> Few-shot handles most tasks; reach for CoT, RAG, or tools only when simple prompts fail.</li>
  <li><strong>Every technique has a cost.</strong> More tokens, more API calls, more complexity. Match the technique to the stakes.</li>
  <li><strong>Always verify outputs.</strong> No technique eliminates hallucinations entirely — they just reduce the probability.</li>
  <li><strong>Combine techniques.</strong> The real power comes from mixing: RAG + CoT + Tool Calling is how production AI systems work.</li>
</ol>

<p style="font-size: 1.4em; font-style: italic; text-align: center; margin: 2rem 0;">Every prompting trick is just a communication skill we forgot we already had.</p>

<hr />

<h2 id="useful-resources">Useful Resources</h2>

<ul>
  <li><a href="https://www.promptingguide.ai/">Prompt Engineering Guide</a></li>
  <li><a href="https://learnprompting.org/">Learn Prompting — Free Interactive Course</a></li>
  <li><a href="https://github.com/anthropics/prompt-eng-interactive-tutorial">Anthropic Interactive Prompt Engineering Tutorial (GitHub)</a></li>
  <li><a href="https://platform.openai.com/docs/guides/prompt-engineering">OpenAI Prompt Engineering Best Practices</a></li>
  <li><a href="https://arxiv.org/abs/2203.11171">Self-Consistency Improves Chain of Thought Reasoning (arXiv)</a></li>
  <li><a href="https://arxiv.org/abs/2303.11366">Reflexion: Language Agents with Verbal Reinforcement Learning (arXiv)</a></li>
  <li><a href="https://arxiv.org/abs/2201.11903">Chain-of-Thought Prompting Elicits Reasoning in LLMs (arXiv)</a></li>
  <li><a href="https://arxiv.org/abs/2005.11401">Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (arXiv)</a></li>
</ul>]]></content><author><name>Zhipeng Bao</name></author><category term="AI" /><category term="LLM" /><category term="prompt-engineering" /><category term="tutorial" /><category term="techniques" /><summary type="html"><![CDATA[Same model, same question, wildly different answers. I discovered that the gap between a useless AI response and a brilliant one often has nothing to do with the model — it’s all about how you ask.]]></summary></entry><entry xml:lang="zh"><title type="html">和 AI 对话的艺术：提示工程实用指南</title><link href="https://hzxbzp.github.io/zh/blog/2026/05/prompt-engineering-guide/" rel="alternate" type="text/html" title="和 AI 对话的艺术：提示工程实用指南" /><published>2026-05-18T00:00:00+00:00</published><updated>2026-05-18T00:00:00+00:00</updated><id>https://hzxbzp.github.io/zh/blog/2026/05/zh-prompt-engineering-guide</id><content type="html" xml:base="https://hzxbzp.github.io/zh/blog/2026/05/prompt-engineering-guide/"><![CDATA[<p>同一个模型，同一个问题，答案却天差地别。我发现，一个没用的 AI 回答和一个惊艳的回答之间的差距，往往和模型本身无关——关键在于你怎么问。</p>

<h2 id="故事的起点一次作业六种技巧">故事的起点：一次作业，六种技巧</h2>

<p>我的 CS146S 课程（The Modern Software Developer）布置了一组编程练习，它们有一个共同的结构：让 Llama 3.1（8B）正确完成一个任务。关键在于，每道题要求使用<em>不同的提示技巧</em>——而结果的差异令人震惊。</p>

<p>同一个模型，同一台机器，能力却完全不同，仅仅因为换了一种提问方式。</p>

<p>以下是我实现的六种技巧，按从简单到强大的顺序排列。</p>

<p><img src="/assets/images/blog/prompt-techniques-overview.svg" alt="从基础到高级的提示技巧" /></p>

<h2 id="1-少样本提示few-shot-prompting用例子来教">1. 少样本提示（Few-Shot Prompting）：”用例子来教”</h2>

<p><strong>核心思路：</strong> 不要解释规则，而是给模型展示正确的输入-输出示例，让它自己找到规律。</p>

<p>在我的作业中，我需要让 Llama 反转 “httpstatus” 这个词。与其解释什么是反转，不如直接给它看例子：</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">system_prompt</span> <span class="o">=</span> <span class="s">"""You reverse the letters of a word. 
Output ONLY the reversed word.

Word: httpstatus
Reversed: sutatsptth

Word: hello
Reversed: olleh

Word: httpstatus
Reversed: sutatsptth"""</span>
</code></pre></div></div>

<p><strong>为什么有效：</strong> 大语言模型本质上是模式补全机器。当它们看到一致的输入 → 输出模式时，就会自动推断。少样本提示正是利用了这一点，给模型一个可以遵循的”模板”。</p>

<p><strong>需要注意的坑：</strong></p>
<ul>
  <li><strong>示例的质量比数量重要得多。</strong> 一个错误的示例就能把模型带偏。三个干净、多样的示例通常比十个重复的效果好。</li>
  <li><strong>顺序会影响结果。</strong> 把简单的例子放前面，难的放后面。模型对最近的上下文更敏感。</li>
  <li><strong>它并不是真的”理解”了。</strong> 模型只是在模仿模式，并没有真正”搞懂”——这也是为什么它在边界情况（比如不常见的分词方式）下依然会失败（参见<a href="/zh/blog/2026/05/why-llms-cant-reverse-words/">我的第一篇博客</a>）。</li>
</ul>

<h2 id="2-思维链chain-of-thought一步一步想">2. 思维链（Chain-of-Thought）：”一步一步想”</h2>

<p><strong>核心思路：</strong> 要求模型在给出最终答案之前，先展示推理过程。</p>

<p>我用这个技巧来计算 3^{12345} mod 100：</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">system_prompt</span> <span class="o">=</span> <span class="s">"""You solve user's problem. Think step by step. 
Output the reasoning trace and the final answer."""</span>
</code></pre></div></div>

<p><strong>为什么有效：</strong> 当你强制模型生成中间步骤时，这些步骤会变成额外的上下文，引导最终答案的生成。就像给模型一张”草稿纸”——把推理过程写出来这个动作本身，就能帮助它保持在正确的轨道上。</p>

<p><strong>需要注意的坑：</strong></p>
<ul>
  <li><strong>推理过程可能是假的。</strong> 正如我发现并<a href="/zh/blog/2026/05/llm-right-answer-wrong-reasoning/">写过的</a>，模型可能生成看起来很合理的步骤，但这些步骤实际上并不支持它的结论。它可能先知道答案，再反过来编造推理过程。</li>
  <li><strong>更长的输出意味着更高的成本。</strong> 思维链会显著增加 token 消耗。对于简单任务来说，没必要。</li>
  <li><strong>垃圾进，垃圾出。</strong> 如果第一步就错了，后面每一步都会把错误放大。</li>
</ul>

<h2 id="3-自洽性self-consistency问三遍听多数的">3. 自洽性（Self-Consistency）：”问三遍，听多数的”</h2>

<p><strong>核心思路：</strong> 让模型用不同的方法多次解决同一个问题，然后选择出现次数最多的答案。</p>

<p>我的实现是整组作业中最精心设计的提示：</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">system_prompt</span> <span class="o">=</span> <span class="s">"""You will solve every problem multiple times 
using different reasoning approaches.

1. Reasoning 1: Solve step by step, directly.
   Answer: &lt;number&gt;

2. Reasoning 2: Solve again from scratch, 
   using a different framing (e.g. work backwards).
   Answer: &lt;number&gt;

3. Reasoning 3: Solve by checking concrete 
   positions or values.
   Answer: &lt;number&gt;

4. Compare the three answers. Pick the majority vote.
   Answer: &lt;number&gt;"""</span>
</code></pre></div></div>

<p>代码会把这个过程跑 5 次，然后在所有运行结果中取多数票。</p>

<p><strong>为什么有效：</strong> 不同的推理路径会碰到不同的失败模式。如果三种方法中有两种得出了相同的答案，那个共同答案更可能是对的。道理就像”找三个医生看看”：一个可能误诊，但如果两个意见一致，就更值得信赖。</p>

<p><strong>需要注意的坑：</strong></p>
<ul>
  <li><strong>成本会翻倍。</strong> 每次调用消耗 3 倍的 token，而且要运行多次。要提前算好预算。</li>
  <li><strong>多样性很重要。</strong> 如果三种”不同”的方法本质上只是同一种方法的不同说法，那就没有任何好处。要明确指定每种方法<em>具体</em>应该怎么不同。</li>
  <li><strong>不是所有任务都适用。</strong> 对于创意写作或主观性任务，没有一个”正确答案”可以投票。</li>
</ul>

<h2 id="4-检索增强生成rag这是你需要知道的">4. 检索增强生成（RAG）：”这是你需要知道的”</h2>

<p><strong>核心思路：</strong> 给模型提供外部文档作为上下文，这样它就不用依赖（可能过时或错误的）训练数据。</p>

<p>我的作业要求编写一个调用文档化 API 的函数。关键是把 API 文档直接喂进提示里：</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">user_prompt</span> <span class="o">=</span> <span class="sa">f</span><span class="s">"""Context (use ONLY this information):
</span><span class="si">{</span><span class="n">api_docs</span><span class="si">}</span><span class="s">

Task: Write a Python function fetch_user_name(user_id, api_key) 
that calls the documented API.

Requirements:
- Use the documented Base URL and endpoint.
- Send the documented authentication header.
- Return only the user's name string."""</span>
</code></pre></div></div>

<p><strong>为什么有效：</strong> 大语言模型在缺乏信息时会产生幻觉（Hallucination）。RAG 通过在提示中直接提供模型需要的确切信息来解决这个问题。不用猜测，不会凭空捏造端点或参数。</p>

<p><strong>需要注意的坑：</strong></p>
<ul>
  <li><strong>上下文窗口（Context Window）有限。</strong> 你不可能把整个代码库都塞进提示里。要精心挑选最相关的文档。</li>
  <li><strong>“仅使用以下信息”这句话很重要。</strong> 没有它，模型可能会把上下文和训练数据混在一起，发明出根本不存在的字段。</li>
  <li><strong>检索质量决定一切。</strong> RAG 的效果取决于你喂给它的文档。检索质量差 → 答案就差，模型再好也没用。</li>
</ul>

<h2 id="5-反思reflexion从错误中学习">5. 反思（Reflexion）：”从错误中学习”</h2>

<p><strong>核心思路：</strong> 让模型先生成一个答案，测试它，把哪里错了告诉它，然后让它修复代码。</p>

<p>我的作业实现了一个两轮循环：生成 → 测试 → 展示失败 → 重新生成。一个关键细节：<strong>两轮使用不同的系统提示。</strong> 第一轮用简单的生成提示；反思轮用专门的纠错提示，并附带失败的上下文信息。</p>

<p><strong>第一轮——初始生成</strong>（简单，无反馈）：</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">system_prompt</span> <span class="o">=</span> <span class="s">"""You are a coding assistant. Output ONLY a single 
fenced Python code block that defines the function 
is_valid_password(password: str) -&gt; bool. No prose or comments."""</span>
</code></pre></div></div>

<p><strong>第二轮——反思</strong>（给出之前的代码 + 哪里出了问题）：</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">reflexion_prompt</span> <span class="o">=</span> <span class="s">"""You are a coding assistant performing 
self-correction (reflexion).

You will be given:
1. A previous implementation that failed some test cases.
2. A list of failing test cases with expected vs. actual results 
   and specific validation rules that failed.

Your job:
- Read the failure report carefully.
- Identify exactly which checks were wrong, missed, or inverted.
- Produce a corrected implementation."""</span>
</code></pre></div></div>

<p>反思提示会收到实际的失败输出作为上下文——比如：<code class="language-plaintext highlighter-rouge">"Input: Password1 → expected True, got False. Failing checks: missing special"</code>。第一轮往往会漏掉边界情况。但在看到<em>具体</em>哪些测试失败了以及<em>为什么</em>之后，第二轮就能搞定。</p>

<p><strong>为什么有效：</strong> 反思模仿了人类调试的方式：写代码 → 跑测试 → 看报错 → 修复。模型不需要第一次就写对，它只需要在具体反馈的引导下<em>最终</em>写对就行。</p>

<p><strong>需要注意的坑：</strong></p>
<ul>
  <li><strong>反馈质量至关重要。</strong> “错了，再试一次”毫无用处。”输入 ‘Password1’ 返回了 True，但应该返回 False，因为缺少特殊字符”——这才是可操作的反馈。</li>
  <li><strong>一轮迭代可能不够。</strong> 复杂的 bug 可能需要多轮反思。但轮数太多，模型可能会原地打转。</li>
  <li><strong>模型可能矫枉过正。</strong> 它可能修好了失败的测试，却搞坏了之前通过的。一定要重新运行所有测试，而不只是失败的那些。</li>
</ul>

<h2 id="6-工具调用tool-calling用真工具别靠猜">6. 工具调用（Tool Calling）：”用真工具，别靠猜”</h2>

<p><strong>核心思路：</strong> 与其让模型去计算或猜测，不如让它调用外部工具（API、代码解释器、数据库），用真实的结果来工作。</p>

<p>我的作业要求模型调用一个解析源文件的 Python 函数：</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">system_prompt</span> <span class="o">=</span> <span class="s">"""You are a tool-calling assistant. 
Respond with ONLY a JSON object:
{"tool": "&lt;tool_name&gt;", "args": {&lt;arguments&gt;}}

Available tools:
[
  {
    "name": "output_every_func_return_type",
    "description": "Parse a Python file and return 
    function_name: return_type for each function.",
    "parameters": {
      "file_path": { "type": "string" }
    }
  }
]"""</span>
</code></pre></div></div>

<p>模型输出一个结构化的工具调用；代码<em>真正执行</em>这个工具，并返回真实结果。</p>

<p><strong>为什么有效：</strong> 这就是我在<a href="/zh/blog/2026/05/llm-right-answer-wrong-reasoning/">第二篇博客</a>中提到的”假装执行代码”问题的解决方案。模型不再<em>假装</em>运行代码，而是<em>真正</em>运行代码。不再<em>猜测</em> API 返回什么，而是<em>实际调用</em> API。真实数据，真实结果，没有幻觉。</p>

<p><strong>需要注意的坑：</strong></p>
<ul>
  <li><strong>提示格式必须严格。</strong> 模型需要输出你的代码能解析的有效 JSON。JSON 外面多一个字就会导致解析失败。对输出格式要非常明确。</li>
  <li><strong>安全性很重要。</strong> 如果模型可以调用任意工具，它就可能造成破坏。一定要对工具调用进行验证和沙箱隔离（Sandboxing）。</li>
  <li><strong>不是所有模型都原生支持。</strong> 小模型可能很难生成结构化的 JSON 输出。大模型（GPT-4、Claude）有内置的工具调用支持。</li>
</ul>

<h2 id="这些技巧为什么会存在">这些技巧为什么会存在？</h2>

<p>所有六种技巧都在解决同一个根本问题：<strong>大语言模型是文本预测器，不是推理器。</strong> 它们根据上下文预测最可能的下一个 token。每一种提示技巧，本质上都是一种<em>工程化地构造上下文</em>的方式，让最可能的下一个 token 同时也是正确的那个。</p>

<table>
  <thead>
    <tr>
      <th style="text-align: left">技巧</th>
      <th style="text-align: left">核心策略</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: left">少样本提示（Few-Shot）</td>
      <td style="text-align: left">建立一个模型可以延续的模式</td>
    </tr>
    <tr>
      <td style="text-align: left">思维链（Chain-of-Thought）</td>
      <td style="text-align: left">创建引导答案的中间上下文</td>
    </tr>
    <tr>
      <td style="text-align: left">自洽性（Self-Consistency）</td>
      <td style="text-align: left">通过聚合多次尝试来降低方差</td>
    </tr>
    <tr>
      <td style="text-align: left">检索增强生成（RAG）</td>
      <td style="text-align: left">用真实数据替代猜测</td>
    </tr>
    <tr>
      <td style="text-align: left">反思（Reflexion）</td>
      <td style="text-align: left">利用反馈逐步缩小到正确答案</td>
    </tr>
    <tr>
      <td style="text-align: left">工具调用（Tool Calling）</td>
      <td style="text-align: left">对需要计算的任务，直接跳过生成环节</td>
    </tr>
  </tbody>
</table>

<p>这个递进关系讲述了一个故事：我们一开始寄希望于模型能”直接搞定”，然后逐渐给它更多的结构、更多的数据、更多的工具——因为光靠希望不是策略。</p>

<h2 id="自己动手试试">自己动手试试</h2>

<p>想练习提示工程吗？这里有几个优秀的资源：</p>

<p><strong><a href="https://www.promptingguide.ai/">Prompting Guide</a></strong> — 一个全面的开源参考指南，涵盖从零样本到高级智能体模式的所有技巧。非常适合作为速查手册。</p>

<p><strong><a href="https://learnprompting.org/">Learn Prompting</a></strong> — 一个互动课程，有动手练习。免费且结构清晰，适合从入门到进阶的所有用户。</p>

<p><strong><a href="https://github.com/anthropics/prompt-eng-interactive-tutorial">Anthropic’s Interactive Tutorial</a></strong> — 基于 Jupyter notebook 的课程，每节课底部都有内置的实验环境，可以实时动手。</p>

<h2 id="关键收获">关键收获</h2>

<ol>
  <li><strong>提示就是程序。</strong> 你怎么问，往往比你用哪个模型更重要。</li>
  <li><strong>从简单开始，按需升级。</strong> 少样本提示能搞定大多数任务；只有当简单提示失败时，才去用思维链、RAG 或工具调用。</li>
  <li><strong>每种技巧都有代价。</strong> 更多 token、更多 API 调用、更高复杂度。要根据任务的重要程度来选择技巧。</li>
  <li><strong>永远验证输出。</strong> 没有任何技巧能完全消除幻觉——它们只是降低了概率。</li>
  <li><strong>组合使用。</strong> 真正的威力来自混合搭配：RAG + 思维链 + 工具调用，这就是生产级 AI 系统的工作方式。</li>
</ol>

<p style="font-size: 1.4em; font-style: italic; text-align: center; margin: 2rem 0;">每一个提示技巧，都不过是我们早已拥有却遗忘了的沟通能力。</p>

<hr />

<h2 id="参考资源">参考资源</h2>

<ul>
  <li><a href="https://www.promptingguide.ai/">Prompt Engineering Guide</a></li>
  <li><a href="https://learnprompting.org/">Learn Prompting — Free Interactive Course</a></li>
  <li><a href="https://github.com/anthropics/prompt-eng-interactive-tutorial">Anthropic Interactive Prompt Engineering Tutorial (GitHub)</a></li>
  <li><a href="https://platform.openai.com/docs/guides/prompt-engineering">OpenAI Prompt Engineering Best Practices</a></li>
  <li><a href="https://arxiv.org/abs/2203.11171">Self-Consistency Improves Chain of Thought Reasoning (arXiv)</a></li>
  <li><a href="https://arxiv.org/abs/2303.11366">Reflexion: Language Agents with Verbal Reinforcement Learning (arXiv)</a></li>
  <li><a href="https://arxiv.org/abs/2201.11903">Chain-of-Thought Prompting Elicits Reasoning in LLMs (arXiv)</a></li>
  <li><a href="https://arxiv.org/abs/2005.11401">Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (arXiv)</a></li>
</ul>]]></content><author><name>Zhipeng Bao</name></author><category term="AI" /><category term="LLM" /><category term="prompt-engineering" /><category term="tutorial" /><category term="techniques" /><summary type="html"><![CDATA[同一个模型，同一个问题，答案却天差地别。我发现，一个没用的 AI 回答和一个惊艳的回答之间的差距，往往和模型本身无关——关键在于你怎么问。]]></summary></entry><entry xml:lang="en"><title type="html">Right Answer, Wrong Reasoning: Can LLMs Actually Think?</title><link href="https://hzxbzp.github.io/blog/2026/05/llm-right-answer-wrong-reasoning/" rel="alternate" type="text/html" title="Right Answer, Wrong Reasoning: Can LLMs Actually Think?" /><published>2026-05-17T00:00:00+00:00</published><updated>2026-05-17T00:00:00+00:00</updated><id>https://hzxbzp.github.io/blog/2026/05/llm-right-answer-wrong-reasoning</id><content type="html" xml:base="https://hzxbzp.github.io/blog/2026/05/llm-right-answer-wrong-reasoning/"><![CDATA[<p>I asked an AI to solve a math problem. It wrote Python code, “ran” it, showed intermediate results, and arrived at the correct answer. Impressive — until I looked closer and realized the reasoning was a performance, not a proof.</p>

<h2 id="the-story-a-math-problem-that-fooled-me">The Story: A Math Problem That Fooled Me</h2>

<p>For another CS146S assignment, I needed an LLM to solve this using chain-of-thought prompting:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>What is 3^{12345} (mod 100)?
</code></pre></div></div>

<p>In plain English: what are the last two digits of 3 raised to the power of 12345? The answer is <strong>43</strong>.</p>

<p>Here’s the setup:</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">from</span> <span class="nn">ollama</span> <span class="kn">import</span> <span class="n">chat</span>

<span class="n">system_prompt</span> <span class="o">=</span> <span class="s">"""You solve user's problem. Think step by step. 
Output the reasoning trace and the final answer."""</span>

<span class="n">user_prompt</span> <span class="o">=</span> <span class="s">"""
Solve this problem, then give the final answer on the last line 
as "Answer: &lt;number&gt;".

what is 3^{12345} (mod 100)?
"""</span>

<span class="n">response</span> <span class="o">=</span> <span class="n">chat</span><span class="p">(</span>
    <span class="n">model</span><span class="o">=</span><span class="s">"llama3.1:8b"</span><span class="p">,</span>
    <span class="n">messages</span><span class="o">=</span><span class="p">[</span>
        <span class="p">{</span><span class="s">"role"</span><span class="p">:</span> <span class="s">"system"</span><span class="p">,</span> <span class="s">"content"</span><span class="p">:</span> <span class="n">system_prompt</span><span class="p">},</span>
        <span class="p">{</span><span class="s">"role"</span><span class="p">:</span> <span class="s">"user"</span><span class="p">,</span> <span class="s">"content"</span><span class="p">:</span> <span class="n">user_prompt</span><span class="p">},</span>
    <span class="p">],</span>
    <span class="n">options</span><span class="o">=</span><span class="p">{</span><span class="s">"temperature"</span><span class="p">:</span> <span class="mf">0.3</span><span class="p">},</span>
<span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="n">response</span><span class="p">.</span><span class="n">message</span><span class="p">.</span><span class="n">content</span><span class="p">)</span>
</code></pre></div></div>

<p>Llama 3.1 responded with a beautifully structured answer: it wrote Python code, displayed “outputs,” identified a pattern, and arrived at 43. On the surface, it looked like rigorous step-by-step problem-solving.</p>

<p>But something was off.</p>

<h2 id="what-llama-showed-me">What Llama Showed Me</h2>

<p>The model’s response looked roughly like this:</p>

<p><strong>Step 1:</strong> Compute the first few powers of 3 mod 100 to find a pattern.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">powers</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">):</span>
    <span class="n">power</span> <span class="o">=</span> <span class="nb">pow</span><span class="p">(</span><span class="n">base</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span> <span class="n">modulus</span><span class="p">)</span>
    <span class="n">powers</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="n">power</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="n">powers</span><span class="p">)</span>  <span class="c1"># Output: [3, 9, 27, 81, 43, 29, 87, 61, 83, 49]
</span></code></pre></div></div>

<p><strong>Step 2:</strong> “From the output, we can see the pattern repeats every 20 powers.”</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">simplified_exponent</span> <span class="o">=</span> <span class="mi">12345</span> <span class="o">%</span> <span class="mi">20</span>  <span class="c1"># Output: 5
</span></code></pre></div></div>

<p><strong>Step 3:</strong> Calculate the final result.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">result</span> <span class="o">=</span> <span class="nb">pow</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span>  <span class="c1"># Output: 43
</span></code></pre></div></div>

<p><strong>Answer: 43</strong> — Correct!</p>

<p>Looks solid, right? Code, outputs, pattern recognition, final answer. But here’s the thing…</p>

<h2 id="three-things-that-were-wrong">Three Things That Were Wrong</h2>

<p><img src="/assets/images/blog/llm-reasoning-vs-real.svg" alt="What Llama showed vs what actually happened" /></p>

<h3 id="1-it-never-ran-the-code">1. It never ran the code</h3>

<p>Llama 3.1 is a text-generation model. It doesn’t have a Python interpreter. Those “outputs” after each <code class="language-plaintext highlighter-rouge">print()</code> statement? The model <em>generated</em> them as text — it predicted what the output <em>should</em> look like based on patterns in its training data.</p>

<p>For simple calculations, these predictions happen to be correct. But the model wasn’t computing — it was <em>performing</em> computation.</p>

<h3 id="2-the-logic-has-a-gap">2. The logic has a gap</h3>

<p>It showed 10 values, then claimed the pattern repeats every <strong>20</strong>. But you can’t deduce a period of 20 from only 10 data points. To actually prove this, you’d need to verify that 3^20 mod 100 = 1. Llama skipped that entirely.</p>

<h3 id="3-it-probably-knew-the-answer-first">3. It probably knew the answer first</h3>

<p>The most likely explanation: Llama had seen similar modular arithmetic problems in its training data. It already “knew” the period is 20 (related to Euler’s totient function). So it constructed a plausible-looking derivation <em>around</em> an answer it had already retrieved — not <em>toward</em> an answer it was discovering.</p>

<p>This is <strong>post-hoc rationalization</strong>: starting from the conclusion and building a story backwards.</p>

<h2 id="the-real-question-do-llms-actually-reason">The Real Question: Do LLMs Actually Reason?</h2>

<p>This experience points to a deeper issue that researchers are actively studying: <strong>when an LLM shows you its “thinking,” is it showing you the actual process that led to the answer, or a fabricated narrative?</strong></p>

<p>Recent research calls this the problem of <strong>unfaithful chain-of-thought</strong>. A 2025 study titled “Chain-of-Thought Reasoning In The Wild Is Not Always Faithful” found that even frontier models produce post-hoc rationalizations — GPT-4o-mini does it about 13% of the time, and even the best models aren’t fully immune.</p>

<p>The core tension is this: LLMs are trained to predict the next token, not to reason logically. When we prompt them to “think step by step,” they generate text that <em>looks like</em> reasoning. Sometimes it <em>is</em> genuine reasoning. Sometimes it’s pattern-matching dressed up in the format of logic.</p>

<p>And here’s what makes it dangerous: <strong>you can’t always tell the difference by reading the output.</strong> The fabricated reasoning looks just as convincing as the real thing.</p>

<h2 id="why-this-happens">Why This Happens</h2>

<h3 id="llms-are-text-predictors-not-logic-engines">LLMs are text predictors, not logic engines</h3>

<p>At their core, language models predict: “given everything so far, what token comes next?” They’ve seen millions of math solutions in training, so they know the <em>format</em> of a proof. But knowing the format doesn’t mean following the logic.</p>

<h3 id="training-data-creates-shortcuts">Training data creates shortcuts</h3>

<p>Llama has seen thousands of modular arithmetic problems. It learned that “modular exponentiation → find the period → reduce the exponent.” So it retrieves and applies this template. When the template fits, the answer is correct. When it doesn’t, you get confident nonsense.</p>

<h3 id="show-your-work-doesnt-guarantee-honest-work">“Show your work” doesn’t guarantee honest work</h3>

<p>Chain-of-thought prompting (“think step by step”) was designed to improve accuracy by forcing the model to lay out intermediate steps. And it does improve accuracy — but research shows the displayed steps don’t always reflect the model’s actual “decision process.” The model may have arrived at the answer through a completely different internal path, then generated a plausible explanation after the fact.</p>

<h2 id="what-can-we-do-about-it">What Can We Do About It?</h2>

<h3 id="1-give-llms-real-tools">1. Give LLMs real tools</h3>

<p>The most direct fix: let models actually execute code instead of pretending to. GPT-4 with Code Interpreter, Claude with tool use — these models can run Python for real. When Llama “runs” code in its head, it’s guessing. When a model with tool access runs code, it’s computing.</p>

<h3 id="2-verify-the-reasoning-not-just-the-answer">2. Verify the reasoning, not just the answer</h3>

<p>Don’t stop at “is the answer correct?” Ask: “does each step logically follow from the previous one?” In my Llama example, checking the 10-to-20 logical gap would have revealed the problem immediately.</p>

<h3 id="3-self-consistency-checking">3. Self-consistency checking</h3>

<p>Run the same prompt multiple times with different temperatures. If the model produces different reasoning paths but the same answer, the answer is likely correct. If the reasoning paths contradict each other, something’s wrong. Research shows this can substantially improve reliability.</p>

<h3 id="4-cross-verify-with-different-approaches">4. Cross-verify with different approaches</h3>

<p>Ask the model to solve the same problem in two different ways. If both approaches agree, confidence goes up. If they disagree, at least one reasoning chain is unfaithful.</p>

<h3 id="5-treat-llm-output-as-a-draft-not-a-proof">5. Treat LLM output as a draft, not a proof</h3>

<p>This is the most important mindset shift. LLM reasoning is a <em>starting point</em> for human verification, not a substitute for it. The model gives you a plausible approach; you verify whether it actually holds.</p>

<h2 id="key-takeaways">Key Takeaways</h2>

<ol>
  <li><strong>Correct answers don’t guarantee correct reasoning</strong> — an LLM can get the right answer for the wrong reasons</li>
  <li><strong>LLMs perform reasoning, not always practice it</strong> — the “thinking” you see may be reconstructed after the fact</li>
  <li><strong>Fake code execution is real</strong> — without tool access, models generate plausible-looking but unverified outputs</li>
  <li><strong>Chain-of-thought is powerful but imperfect</strong> — it improves accuracy while creating a false sense of transparency</li>
  <li><strong>Always verify the process, not just the result</strong> — especially for math, logic, and any high-stakes reasoning</li>
</ol>

<p style="font-size: 1.4em; font-style: italic; text-align: center; margin: 2rem 0;">The best liars don't get the facts wrong — they get the reasoning wrong.</p>

<hr />

<h2 id="useful-resources">Useful Resources</h2>

<ul>
  <li><a href="https://arxiv.org/abs/2503.08679">Chain-of-Thought Reasoning In The Wild Is Not Always Faithful (arXiv, 2025)</a></li>
  <li><a href="https://arxiv.org/abs/2305.04388">Language Models Don’t Always Say What They Think (arXiv, 2023)</a></li>
  <li><a href="https://arxiv.org/abs/2203.11171">Self-Consistency Improves Chain of Thought Reasoning (arXiv)</a></li>
  <li><a href="https://explore.n1n.ai/blog/llm-cot-faithfulness-research-2026-03-30">Chain of Thought Faithfulness: Why LLM Reasoning Is Often a Narrative (n1n.ai)</a></li>
  <li><a href="https://en.wikipedia.org/wiki/Stochastic_parrot">Stochastic Parrot — Wikipedia</a></li>
  <li><a href="https://simonwillison.net/2025/Mar/2/hallucinations-in-code/">Hallucinations in Code Are the Least Dangerous Form of LLM Mistakes (Simon Willison)</a></li>
</ul>]]></content><author><name>Zhipeng Bao</name></author><category term="AI" /><category term="LLM" /><category term="reasoning" /><category term="chain-of-thought" /><category term="tutorial" /><summary type="html"><![CDATA[I asked an AI to solve a math problem. It wrote Python code, “ran” it, showed intermediate results, and arrived at the correct answer. Impressive — until I looked closer and realized the reasoning was a performance, not a proof.]]></summary></entry><entry xml:lang="zh"><title type="html">答案对了，推理错了：LLM 真的会思考吗？</title><link href="https://hzxbzp.github.io/zh/blog/2026/05/llm-right-answer-wrong-reasoning/" rel="alternate" type="text/html" title="答案对了，推理错了：LLM 真的会思考吗？" /><published>2026-05-17T00:00:00+00:00</published><updated>2026-05-17T00:00:00+00:00</updated><id>https://hzxbzp.github.io/zh/blog/2026/05/zh-llm-right-answer-wrong-reasoning</id><content type="html" xml:base="https://hzxbzp.github.io/zh/blog/2026/05/llm-right-answer-wrong-reasoning/"><![CDATA[<p>我让一个 AI 解一道数学题。它写了 Python 代码，”运行”了一下，展示了中间结果，最后得出了正确答案。看起来很厉害——直到我仔细一看，发现那个推理过程是在”演戏”，而不是在”证明”。</p>

<h2 id="故事的起因一道把我骗了的数学题">故事的起因：一道把我骗了的数学题</h2>

<p>在另一次 CS146S 的作业中，我需要用 <strong>思维链（Chain-of-Thought）</strong> 提示法让 LLM 解这道题：</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>What is 3^{12345} (mod 100)?
</code></pre></div></div>

<p>翻译成人话就是：3 的 12345 次方，最后两位数字是什么？答案是 <strong>43</strong>。</p>

<p>下面是代码设置：</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">from</span> <span class="nn">ollama</span> <span class="kn">import</span> <span class="n">chat</span>

<span class="n">system_prompt</span> <span class="o">=</span> <span class="s">"""You solve user's problem. Think step by step. 
Output the reasoning trace and the final answer."""</span>

<span class="n">user_prompt</span> <span class="o">=</span> <span class="s">"""
Solve this problem, then give the final answer on the last line 
as "Answer: &lt;number&gt;".

what is 3^{12345} (mod 100)?
"""</span>

<span class="n">response</span> <span class="o">=</span> <span class="n">chat</span><span class="p">(</span>
    <span class="n">model</span><span class="o">=</span><span class="s">"llama3.1:8b"</span><span class="p">,</span>
    <span class="n">messages</span><span class="o">=</span><span class="p">[</span>
        <span class="p">{</span><span class="s">"role"</span><span class="p">:</span> <span class="s">"system"</span><span class="p">,</span> <span class="s">"content"</span><span class="p">:</span> <span class="n">system_prompt</span><span class="p">},</span>
        <span class="p">{</span><span class="s">"role"</span><span class="p">:</span> <span class="s">"user"</span><span class="p">,</span> <span class="s">"content"</span><span class="p">:</span> <span class="n">user_prompt</span><span class="p">},</span>
    <span class="p">],</span>
    <span class="n">options</span><span class="o">=</span><span class="p">{</span><span class="s">"temperature"</span><span class="p">:</span> <span class="mf">0.3</span><span class="p">},</span>
<span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="n">response</span><span class="p">.</span><span class="n">message</span><span class="p">.</span><span class="n">content</span><span class="p">)</span>
</code></pre></div></div>

<p>Llama 3.1 给出了一个结构漂亮的回答：它写了 Python 代码，展示了”输出结果”，识别出了一个规律，最终得出了 43。从表面上看，这是一个严谨的、逐步推导的解题过程。</p>

<p>但有些地方不太对劲。</p>

<h2 id="llama-给我看了什么">Llama 给我看了什么</h2>

<p>模型的回答大概是这样的：</p>

<p><strong>第 1 步：</strong> 计算前几个 3 的幂对 100 取模的结果，找规律。</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">powers</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">):</span>
    <span class="n">power</span> <span class="o">=</span> <span class="nb">pow</span><span class="p">(</span><span class="n">base</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span> <span class="n">modulus</span><span class="p">)</span>
    <span class="n">powers</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="n">power</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="n">powers</span><span class="p">)</span>  <span class="c1"># Output: [3, 9, 27, 81, 43, 29, 87, 61, 83, 49]
</span></code></pre></div></div>

<p><strong>第 2 步：</strong> “从输出结果可以看出，这个模式每 20 个幂次重复一次。”</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">simplified_exponent</span> <span class="o">=</span> <span class="mi">12345</span> <span class="o">%</span> <span class="mi">20</span>  <span class="c1"># Output: 5
</span></code></pre></div></div>

<p><strong>第 3 步：</strong> 计算最终结果。</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">result</span> <span class="o">=</span> <span class="nb">pow</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span>  <span class="c1"># Output: 43
</span></code></pre></div></div>

<p><strong>Answer: 43</strong> ——正确！</p>

<p>看起来很靠谱对吧？代码、输出、模式识别、最终答案，一套流程下来很完整。但问题是……</p>

<h2 id="三个错误">三个错误</h2>

<p><img src="/assets/images/blog/llm-reasoning-vs-real.svg" alt="What Llama showed vs what actually happened" /></p>

<h3 id="1-它根本没运行代码">1. 它根本没运行代码</h3>

<p>Llama 3.1 是一个文本生成模型，它没有 Python 解释器。那些 <code class="language-plaintext highlighter-rouge">print()</code> 语句后面的”输出结果”？其实是模型根据训练数据中的模式，<em>预测</em>出来的文本——它猜的是输出<em>应该</em>长什么样。</p>

<p>对于简单的计算，这些预测恰好是对的。但模型并不是在<strong>计算（computing）</strong>——它是在<strong>表演（performing）</strong>计算。</p>

<h3 id="2-逻辑有漏洞">2. 逻辑有漏洞</h3>

<p>它展示了 10 个值，然后声称模式每 <strong>20</strong> 个一循环。但你不可能从 10 个数据点推导出周期是 20。要真正证明这一点，你需要验证 3^20 mod 100 = 1。Llama 完全跳过了这一步。</p>

<h3 id="3-它很可能一开始就知道答案">3. 它很可能一开始就知道答案</h3>

<p>最可能的解释是：Llama 在训练数据中见过类似的模运算题。它已经”知道”周期是 20（这和<strong>欧拉函数（Euler’s totient function）</strong>有关）。所以它是围绕一个已经检索到的答案，<em>反向构造</em>了一个看起来合理的推导过程——而不是<em>正向推导</em>出一个新发现的答案。</p>

<p>这就是<strong>事后合理化（post-hoc rationalization）</strong>：从结论出发，反向编一个故事。</p>

<h2 id="真正的问题llm-到底会不会推理">真正的问题：LLM 到底会不会推理？</h2>

<p>这个经历指向了一个研究人员正在积极研究的更深层问题：<strong>当一个 LLM 向你展示它的”思考过程”时，它展示的是真正导致答案产生的过程，还是一个编造出来的叙事？</strong></p>

<p>最近的研究把这称为<strong>不忠实的思维链（unfaithful chain-of-thought）</strong>问题。2025 年一项题为”Chain-of-Thought Reasoning In The Wild Is Not Always Faithful”的研究发现，即使是最前沿的模型也会产生事后合理化——GPT-4o-mini 大约有 13% 的概率这样做，就连最好的模型也不能完全幸免。</p>

<p>核心矛盾在于：LLM 被训练来预测下一个 <strong>token</strong>，而不是进行逻辑推理。当我们提示它”逐步思考”时，它生成的是<em>看起来像</em>推理的文本。有时候这<em>确实是</em>真正的推理。有时候只是伪装成逻辑格式的模式匹配。</p>

<p>而真正危险的地方在于：<strong>你不能总是通过阅读输出来分辨真假。</strong> 编造出来的推理看起来和真正的推理一样令人信服。</p>

<h2 id="为什么会这样">为什么会这样</h2>

<h3 id="llm-是文本预测器不是逻辑引擎">LLM 是文本预测器，不是逻辑引擎</h3>

<p>归根结底，语言模型做的事情就是预测：”根据到目前为止的所有内容，下一个 token 是什么？”它们在训练中见过几百万个数学解题过程，所以它们知道证明的<em>格式</em>。但知道格式不等于遵循逻辑。</p>

<h3 id="训练数据制造了捷径">训练数据制造了捷径</h3>

<p>Llama 见过成千上万的模运算问题。它学到了”模幂运算 → 找周期 → 简化指数”这个模板。所以它检索并套用了这个模板。当模板恰好适用时，答案就是对的。当不适用时，你得到的就是一本正经的胡说八道。</p>

<h3 id="写出你的解题步骤不等于诚实地展示解题步骤">“写出你的解题步骤”不等于”诚实地展示解题步骤”</h3>

<p><strong>思维链提示法（Chain-of-thought prompting）</strong>（”逐步思考”）的设计初衷是通过迫使模型展示中间步骤来提高准确率。它确实提高了准确率——但研究表明，展示出来的步骤并不总是反映模型实际的”决策过程”。模型可能是通过一条完全不同的内部路径得出了答案，然后在事后生成了一个看起来合理的解释。</p>

<h2 id="我们能做什么">我们能做什么？</h2>

<h3 id="1-给-llm-真正的工具">1. 给 LLM 真正的工具</h3>

<p>最直接的解决办法：让模型真正执行代码，而不是假装执行。GPT-4 带 <strong>Code Interpreter</strong>、Claude 带 <strong>tool use</strong>——这些模型可以真正运行 Python。当 Llama 在”脑子里”运行代码时，它是在猜。当有工具访问权限的模型运行代码时，它是在计算。</p>

<h3 id="2-验证推理过程而不只是答案">2. 验证推理过程，而不只是答案</h3>

<p>不要停留在”答案对不对？”这个问题上。要问：”每一步是否从上一步逻辑推导而来？”在我的 Llama 例子中，检查”从 10 个值跳到周期 20”这个逻辑漏洞就能立刻发现问题。</p>

<h3 id="3-自洽性检查self-consistency-checking">3. 自洽性检查（Self-consistency checking）</h3>

<p>用不同的 temperature 多次运行同一个 prompt。如果模型产生了不同的推理路径但得出相同的答案，那答案很可能是对的。如果推理路径互相矛盾，那就有问题了。研究表明这种方法可以显著提高可靠性。</p>

<h3 id="4-用不同方法交叉验证">4. 用不同方法交叉验证</h3>

<p>让模型用两种不同的方法解同一道题。如果两种方法得出一致的结论，信心就提高了。如果不一致，至少有一条推理链是不忠实的。</p>

<h3 id="5-把-llm-的输出当草稿而不是证明">5. 把 LLM 的输出当草稿，而不是证明</h3>

<p>这是最重要的思维转变。LLM 的推理是人类验证的<em>起点</em>，而不是替代品。模型给你一个看起来合理的方法；你来验证它是否真的成立。</p>

<h2 id="关键要点">关键要点</h2>

<ol>
  <li><strong>正确的答案不等于正确的推理</strong> ——LLM 可以因为错误的理由得出正确的答案</li>
  <li><strong>LLM 在表演推理，而不总是在实践推理</strong> ——你看到的”思考过程”可能是事后重构的</li>
  <li><strong>假装执行代码是真实存在的问题</strong> ——没有工具访问权限时，模型会生成看起来合理但未经验证的输出</li>
  <li><strong>思维链强大但不完美</strong> ——它提高了准确率，同时也制造了虚假的透明感</li>
  <li><strong>永远要验证过程，而不只是结果</strong> ——尤其是在数学、逻辑和任何高风险推理场景中</li>
</ol>

<p style="font-size: 1.4em; font-style: italic; text-align: center; margin: 2rem 0;">最高明的骗子不会弄错事实——他们只是编造了推理过程。</p>

<hr />

<h2 id="参考资源">参考资源</h2>

<ul>
  <li><a href="https://arxiv.org/abs/2503.08679">Chain-of-Thought Reasoning In The Wild Is Not Always Faithful (arXiv, 2025)</a></li>
  <li><a href="https://arxiv.org/abs/2305.04388">Language Models Don’t Always Say What They Think (arXiv, 2023)</a></li>
  <li><a href="https://arxiv.org/abs/2203.11171">Self-Consistency Improves Chain of Thought Reasoning (arXiv)</a></li>
  <li><a href="https://explore.n1n.ai/blog/llm-cot-faithfulness-research-2026-03-30">Chain of Thought Faithfulness: Why LLM Reasoning Is Often a Narrative (n1n.ai)</a></li>
  <li><a href="https://en.wikipedia.org/wiki/Stochastic_parrot">Stochastic Parrot — Wikipedia</a></li>
  <li><a href="https://simonwillison.net/2025/Mar/2/hallucinations-in-code/">Hallucinations in Code Are the Least Dangerous Form of LLM Mistakes (Simon Willison)</a></li>
</ul>]]></content><author><name>Zhipeng Bao</name></author><category term="AI" /><category term="LLM" /><category term="reasoning" /><category term="chain-of-thought" /><category term="tutorial" /><summary type="html"><![CDATA[我让一个 AI 解一道数学题。它写了 Python 代码，”运行”了一下，展示了中间结果，最后得出了正确答案。看起来很厉害——直到我仔细一看，发现那个推理过程是在”演戏”，而不是在”证明”。]]></summary></entry></feed>