AI Wiki中文/EN

Chain of thought: a visible path is another generated sequence

思维链提示

Factor a tiny path distribution and separate a correct final answer from a valid intermediate trace.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

A correct answer and a correct route are different observations

An authored arithmetic task starts with 12 items, removes 3, and sells each remaining item for 2 units. The intended answer is 18. A generated solution might say that 8 items remain, then still end at 18. Checking the final number accepts it; checking the two stated transitions does not.

Chain-of-thought prompting asks a language model to generate intermediate steps before its answer, often by showing demonstrations in that format. Wei and colleagues, section 2, study such demonstrations and explicitly leave open how completely the generated text characterizes the model’s internal computation. A readable explanation is evidence about what the model wrote, not a transcript of every computation that caused its answer.

The original paper’s section 3.1 contrasts question–answer examples with examples that also contain intermediate explanations. Its first version uses eight manually composed arithmetic exemplars and varies their order. That is a specific prompting experiment, not a guarantee that any instruction to “think” improves any model. The finite program here exposes probability and checking choices without running a language model.

An authored probability table separates a correct answer from valid intermediate steps.
An authored probability table separates a correct answer from valid intermediate steps.

Generating steps changes the sequence being modeled

Let xx be the question, zz the generated intermediate text and yy the final answer. A joint conditional distribution factors as:

pθ(z,y∣x)=pθ(z∣x)pθ(y∣x,z).p_\theta(z,y\mid x)=p_\theta(z\mid x)p_\theta(y\mid x,z).

This is the chain rule of probability. It does not assert that the intermediate text is logically sound or causally faithful to internal representations. A model conditions later tokens on earlier generated tokens, including earlier errors.

If the intermediate text is divided into TT steps, its generation can be written as:

pθ(z1:T,y∣x)=[∏t=1Tpθ(zt∣x,z<t)]pθ(y∣x,z1:T).p_\theta(z_{1:T},y\mid x)=\left[\prod_{t=1}^T p_\theta(z_t\mid x,z_{<t})\right]p_\theta(y\mid x,z_{1:T}).

A “step” may be a token, sentence or equation. Changing this unit changes the branching and checking interfaces, not the probability chain rule. Yao and colleagues, sections 2–3, make the step decomposition explicit when extending a single chain into a search tree.

The answer distribution sums over paths that end at the same answer:

pθ(y∣x)=∑zpθ(z,y∣x).p_\theta(y\mid x)=\sum_z p_\theta(z,y\mid x).

This is the answer marginal of this joint model, not necessarily the output distribution of a different prompt that asks for an immediate answer. Changing the prompt changes the conditioned distribution. In a real model the sum is generally too large to enumerate.

Greedy generation chooses a locally likely next step and then a locally likely answer:

ztgreedy=arg⁡max⁡ztpθ(zt∣x,z<tgreedy),ygreedy=arg⁡max⁡ypθ(y∣x,zgreedy).z_t^{\mathrm{greedy}}=\arg\max_{z_t}p_\theta(z_t\mid x,z_{<t}^{\mathrm{greedy}}),\qquad y^{\mathrm{greedy}}=\arg\max_y p_\theta(y\mid x,z^{\mathrm{greedy}}).

This need not maximize the probability of a complete path. Nor does the most probable complete path necessarily end at the most probable answer after summing paths:

(zMAP,yMAP)=arg⁡max⁡z,ypθ(z,y∣x),ymarginal=arg⁡max⁡y∑zpθ(z,y∣x).(z^{\mathrm{MAP}},y^{\mathrm{MAP}})=\arg\max_{z,y}p_\theta(z,y\mid x),\qquad y^{\mathrm{marginal}}=\arg\max_y\sum_zp_\theta(z,y\mid x).

These are different decision rules. Self-consistency approximates answer aggregation through samples; tree search explicitly explores alternatives. Neither turns likelihood into a proof of validity.

For a task with an executable specification, define local checks gtg_t and a final-answer check hh. A strict path validator can require:

V(z,y;x)=h(y;x)∏t=1Tgt(x,z≤t,y),gt,h∈{0,1}.V(z,y;x)=h(y;x)\prod_{t=1}^T g_t(x,z_{\le t},y),\qquad g_t,h\in\{0,1\}.

Here each check must state what it verifies. In the two-step arithmetic example, one check validates subtraction, another multiplication. A locally valid second operation can still build on a wrong intermediate value. General natural-language reasoning usually lacks such complete, inexpensive checks.

For NN generated paths with average intermediate and answer lengths Lz,LyL_z,L_y, a simple output-token budget is:

Boutput≈N(Lz+Ly).B_{\mathrm{output}}\approx N(L_z+L_y).

This is a token count, not a FLOP or latency formula. Prompt length, caching, batching, architecture and verifier calls also matter. Writing more steps spends computation; it does not establish that the computation was useful.

Enumerate four possible paths

The program has two intermediate values, 9 and 8, with probabilities 0.55 and 0.45. Given 9, it ends at 18 with probability 0.6 and 16 with probability 0.4. Given 8, those probabilities are 0.1 and 0.9. These numbers are authored, not estimated from a model.

"""Original finite chain model, not a prompted language model."""
import json
import numpy as np


def joint(first, conditional):
    first=np.asarray(first,dtype=float);conditional=np.asarray(conditional,dtype=float)
    if (first.ndim!=1 or conditional.ndim!=2 or conditional.shape[0]!=len(first)
        or not len(first) or not np.isfinite(first).all() or not np.isfinite(conditional).all()
        or np.any(first<0) or np.any(conditional<0) or not np.isclose(first.sum(),1)
        or not np.allclose(conditional.sum(axis=1),1)):
        raise ValueError("Normalized first-step and conditional distributions required")
    return first[:,None]*conditional


def check_trace(intermediate, answer, start=12, removed=3, price=2):
    return [intermediate==start-removed,answer==intermediate*price]


def demo():
    states=[9,8];answers=[18,16]
    first=np.array([.55,.45]);conditional=np.array([[.6,.4],[.1,.9]])
    table=joint(first,conditional)
    i=int(np.argmax(first));j=int(np.argmax(conditional[i]))
    mi,mj=np.unravel_index(np.argmax(table),table.shape)
    rows=[]
    for a,s in enumerate(states):
        for b,y in enumerate(answers):
            flags=check_trace(s,y)
            rows.append(dict(intermediate=s,answer=y,probability=float(table[a,b]),
                local_checks=flags,all_steps_correct=all(flags),final_correct=y==18))
    return dict(joint=table.tolist(),answer_marginal=table.sum(axis=0).tolist(),
        greedy_trace=[states[i],answers[j]],maximum_joint_trace=[states[mi],answers[mj]],
        modal_answer=answers[int(np.argmax(table.sum(axis=0)))],traces=rows,
        correct_answer_mass=sum(r['probability'] for r in rows if r['final_correct']),
        valid_trace_mass=sum(r['probability'] for r in rows if r['all_steps_correct']),
        invalid_but_correct_mass=sum(r['probability'] for r in rows if r['final_correct'] and not r['all_steps_correct']))


if __name__=='__main__':print(json.dumps(demo(),indent=2))

The four joint masses are 0.33,0.22,0.045,0.405. Greedy generation picks 9 → 18, but the maximum-joint path is 8 → 16. Summing by final answer gives probability 0.375 for 18 and 0.625 for 16. The modal answer is wrong because this synthetic generator favors it.

Only the 9 → 18 trace has two valid transitions, with mass 0.33. The final answer is correct with mass 0.375, leaving 0.045 mass on a correct number reached through invalid statements. Meanwhile 8 → 16 has a locally correct multiplication but an incorrect subtraction. These distinctions are directly checked in the output.

For SS intermediate states and AA answer categories, storing and evaluating the table takes O(SA)O(SA) time and memory. The program validates normalized, finite nonnegative distributions. It is a finite probability model and arithmetic checker, not an implementation of a transformer, a natural-language parser or a test of prompted reasoning performance.

An explanation can be useful without being a complete causal account

Intermediate text can expose a mistaken calculation or missing premise and make debugging easier. It can also contain plausible-looking errors, omit a decisive assumption, or arrive at a correct answer accidentally. Evaluate answer correctness, stated-step validity and any claim of faithfulness separately.

The prompt format, demonstrations, sampling settings and stopping rules are part of the method. A result obtained with one model size and benchmark does not define a universal threshold for reasoning. Longer traces can also introduce more chances for error. Compare alternatives under a declared output and verification budget.

The toy’s exact arithmetic checks are unusually strong. In open-ended tasks, the checker may itself be a fallible model or a person. A checker agreeing with an explanation is another observation, not automatic proof that the hidden computation followed that explanation.

Check the route as well as the destination

  1. What is the joint probability of the path 8 → 18?

Answer: 0.45×0.1=0.0450.45\times0.1=0.045. The path ends correctly but fails both stated arithmetic checks.

  1. Why does greedy generation not select the largest joint-mass path in this example?

Answer: It first commits to the more likely intermediate value 9. Its best continuation has joint mass 0.33; the initially less likely value 8 has a continuation with mass 0.405. Local maximization did not compare those complete products.

  1. Is 8 → 16 completely invalid, or does it contain a valid local operation?

Answer: The subtraction is wrong, but multiplying the claimed 8 by 2 to get 16 is locally valid. Local consistency with a false premise does not make the solution correct.

  1. Would a higher correct-answer rate alone prove that generated steps faithfully reveal a model’s internal computation?

Answer: No. It measures an output-level result. Establishing a causal account of the internal computation requires additional evidence beyond final answers or plausible explanations.

From one generated chain to controlled exploration

Wei’s sections 2–3.1 define the prompting comparison and its experimental setup. Yao’s sections 2–3 separate generation, step granularity and search control. Continue with self-consistency to aggregate sampled answers, process supervision to label steps, and tree of thoughts to retain alternative partial solutions.

Make a prediction, then check

Does a correct final answer guarantee that every generated step is valid?

Choose one answer

Learning objectives

  • Trace conditional generation and explain why readable steps are not a proof of internal computation.
  • Reproduce the finite example and state its experimental limits.

Prerequisites & connections

Explore related knowledge →

References

  1. Chain of Thought Prompting Elicits Reasoning in Large Language Models — v1
    Jason Wei; Xuezhi Wang; Dale Schuurmans; Maarten Bosma; Ed Chi; Quoc Le; Denny Zhou · 2022
  2. Tree of Thoughts: Deliberate Problem Solving with Large Language Models — v1
    Shunyu Yao; Dian Yu; Jeffrey Zhao; Izhak Shafran; Thomas L. Griffiths; Yuan Cao; Karthik Narasimhan · 2023

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-20 · Single AI author. Viewed PDF2, sections2/3.1: intermediate explanations, input-rationale-answer demonstrations, eight exemplars and shuffled order; caveat about characterizing internal computation. No language model reproduced. Read section3, viewed PDF3/4: thought decomposition, sample/propose generation, value/vote evaluation, bounded BFS and DFS/backtracking. Teaching generator/evaluator are explicit rules, not LM replicas. Seven paired equations and four explained exercises. Authored joint probabilities, greedy versus joint MAP versus answer marginal, and correct-final/valid-step distinction verified. No claim that generated words expose all internal computation.

  • Authored joint probabilities, greedy versus joint MAP versus answer marginal, and correct-final/valid-step distinction verified. No claim that generated words expose all internal computation.
  • Four computed SVG variants per topic;11 numeric/geometry tests and36 responsive cases passed. Twelve selected final captures directly viewed. Full article acceptance recorded separately.

Source locations checked:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.