"I can solve your math problem, but only if you ask me to think step by step. Otherwise I just guess. Please do not ask why."
A Foundation Model Pretending to Be a Scientist
Large language models (LLMs) have transformed what "reasoning" means in AI systems. They do not use resolution or structure mapping internally; instead, they approximate reasoning through next-token prediction over sequences that resemble reasoning traces. This approximation is sometimes remarkably effective and sometimes spectacularly wrong. Understanding when and why LLMs reason well (or poorly) is essential for building discovery systems that use them. This section maps the techniques (chain-of-thought, scratchpads, tool use, reasoning models), examines a landmark case study (AlphaGeometry), and catalogs the systematic failure modes you must design around.
1. The Surprising Emergence of Reasoning
A system whose sole training objective is "predict the next word" can prove olympiad geometry theorems, identify drug candidates for untreatable diseases, and derive physical laws from raw data. In the previous section, we defined five forms of reasoning and gave each a clean computational realization. Transformers take a radically different approach: they contain no resolution engine and no structure mapping algorithm. Yet when prompted appropriately, models like Claude, GPT-4, and Gemini can solve syllogisms, identify analogies, propose abductive explanations, and prove mathematical theorems. How?
Mechanistic interpretability, the subfield that reverse-engineers the internal computations of neural networks into human-readable algorithms, supports the working hypothesis that transformers learn to simulate reasoning processes during pretraining. When the training corpus contains mathematical proofs, the model learns patterns like "if the premises include \(P \rightarrow Q\) and \(P\), the text usually continues with \(Q\)." This does not constitute deduction in the logical sense; the model does not verify soundness. It is, however, a useful statistical approximation that produces correct results on a wide range of inputs. (As of 2025, mechanistic interpretability work by Anthropic and others has identified specific attention heads and circuit structures that implement reasoning-like operations, moving beyond the purely statistical approximation view, though a complete mechanistic account remains an open problem.)
The critical insight for discovery AI practitioners: LLM reasoning is a capability that must be elicited, tested, and bounded, not a guarantee that can be assumed. The techniques in this section are the elicitation tools; the failure modes at the end are the boundaries. In short: LLMs do not reason by default; they reason when the prompt turns thinking into text.
2. Chain-of-Thought Prompting
The most widely adopted of these elicitation techniques, and the natural starting point, is a deceptively simple idea: asking the model to show its work.
On GSM8K, a benchmark of 8,500 grade-school math word problems requiring two to eight reasoning steps, some large language models answered multi-step word problems correctly less than 18% of the time when prompted directly (exact figures vary by model size and family). A single change to the prompt format, with no retraining and no new data, raised accuracy above 55%. The difference was not a better model; it was a better way of asking.
Wei et al. (2022) introduced chain-of-thought (CoT) prompting: instruct the model to produce intermediate reasoning steps before the final answer, rather than jumping directly to the conclusion.
In chain-of-thought prompting, you structure a model's input (via instructions or few-shot examples) so that the output includes explicit intermediate reasoning steps before the final answer. This converts problems that exceed a transformer's fixed computational depth into individually tractable sub-problems, each benefiting from the full context of prior steps. The mechanism is autoregressive amplification, where each generated token is appended to the input context so that later tokens can attend to earlier reasoning steps, effectively giving the model a growing working memory. Use CoT when a task requires multiple dependent reasoning steps (multi-hop questions, arithmetic, logical deduction). Prefer direct prompting for single-step classification, sentiment analysis, or tasks where latency and token cost outweigh accuracy gains.
Why Chain-of-Thought Works
Consider the computation graph. Without CoT, the model must compress a multi-step reasoning chain into a single forward pass (a fixed number of transformer layers). With CoT, each intermediate step becomes part of the input context for subsequent steps, giving the model a variable-length "working memory" through its own output tokens. The model can attend to its previously generated reasoning steps when producing the next one.
The mathematical framing: for a question \(Q\) with answer \(A\) and reasoning chain \(R = (r_1, r_2, \ldots, r_k)\):
$$ P(A \mid Q) = \sum_R P(A \mid R, Q) \cdot P(R \mid Q) $$Direct prompting asks for \(P(A \mid Q)\) in one shot. CoT prompting samples \(R\) first, then computes \(P(A \mid R, Q)\), which is often a much easier conditional distribution because the reasoning chain \(R\) has already done the hard work.
import anthropic
client = anthropic.Anthropic()
def reason_with_cot(question: str, domain: str = "science") -> dict:
"""Elicit chain-of-thought reasoning from Claude.
Returns both the reasoning chain and final answer,
separated for downstream processing.
"""
system_prompt = f"""You are a {domain} reasoning assistant.
When given a question, think through it step by step.
Structure your response as:
REASONING:
[numbered steps of your reasoning]
ANSWER:
[your final answer]
CONFIDENCE:
[high/medium/low with brief justification]"""
response = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=2048,
system=system_prompt,
messages=[{"role": "user", "content": question}]
)
text = response.content[0].text
# Parse structured output
parts = {}
for section in ["REASONING", "ANSWER", "CONFIDENCE"]:
start = text.find(f"{section}:")
if start != -1:
# Find next section or end
next_sections = [
text.find(f"{s}:", start + len(section))
for s in ["REASONING", "ANSWER", "CONFIDENCE"]
if text.find(f"{s}:", start + len(section)) != -1
]
end = min(next_sections) if next_sections else len(text)
parts[section.lower()] = text[start + len(section) + 1:end].strip()
return parts
# Example: scientific reasoning question
result = reason_with_cot(
"A sealed container holds gas at 300K and 1 atm. "
"The temperature is doubled to 600K. "
"What happens to the pressure, and why?"
)
print("Reasoning:", result.get("reasoning", "")[:200], "...")
print("Answer:", result.get("answer", ""))
print("Confidence:", result.get("confidence", ""))
Chain-of-thought prompting does not make the model "smarter." It changes the computational graph by converting internal (fixed-depth) computation into external (variable-length) computation. The model's per-step accuracy remains roughly constant, but multi-step problems become tractable because each step can attend to all previous steps. This is why CoT helps most on problems requiring many reasoning steps (multi-digit arithmetic, multi-hop logic) and helps least on problems requiring a single insight (creative leaps, perceptual judgments). For discovery AI, this means CoT is excellent for systematic hypothesis evaluation but less useful for the abductive leap that generates the hypothesis in the first place.
Exercise 4.2.1
Consider a model that answers single-step reasoning questions correctly 90% of the time. If a problem requires a chain of 7 independent reasoning steps, what is the probability that the entire chain is correct? Now suppose chain-of-thought prompting raises per-step accuracy to 95%. Compute the new chain-level accuracy for 7 steps. By what factor did CoT improve the final answer reliability?
Hint
For independent steps, multiply per-step probabilities: \(P(\text{all correct}) = p^k\) where \(p\) is per-step accuracy and \(k\) is the number of steps. Compare \(0.90^7\) with \(0.95^7\) and compute the ratio of the two results.
Common Misconception
A widespread misconception is that chain-of-thought prompting teaches the model new reasoning abilities or "unlocks" latent intelligence. In reality, CoT does not add any capability the model lacks; it restructures the computation so that multi-step problems are decomposed into single steps the model can already handle. If the model cannot perform a single reasoning step correctly (for example, applying a rule it never encountered during training), no amount of chain-of-thought scaffolding will fix that gap. CoT amplifies existing per-step competence across longer chains; it does not create competence from scratch.
3. Scratchpad and Extended Thinking
The scratchpad technique, introduced by Nye et al. (2021), takes chain-of-thought further. Instead of merely asking the model to "think step by step," we provide an explicit workspace where the model can perform intermediate computations, store partial results, and revise its approach.
Mental Model
Think of extended thinking like a chef's prep kitchen versus a live cooking show. In the live show (standard prompting), the chef must plate each ingredient the moment it comes out, with no chance to taste, adjust, or start over. In the prep kitchen (extended thinking), the chef can try a sauce, realize it needs more acid, discard a failed reduction, and rework the dish before it ever reaches the dining room. The thinking tokens are the prep kitchen: a private workspace where the model can explore dead ends, catch its own mistakes, and revise its approach before committing to a final answer. The diner (the user) only sees the polished plate, but the quality depends on the freedom to experiment behind the scenes.
Modern reasoning models formalize this through extended thinking: the model generates a potentially long internal reasoning trace (the "thinking" tokens) before producing the visible response. Claude's extended thinking, OpenAI's o1 and o3 models, and DeepSeek-R1 all implement variants of this approach. The key difference from basic CoT is that the model may backtrack, consider alternatives, and self-correct within the thinking trace.
def reason_with_extended_thinking(question: str) -> dict:
"""Use Claude's extended thinking for complex reasoning.
Extended thinking allocates additional compute at inference
time, allowing the model to explore and self-correct.
"""
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=16000,
temperature=1, # Required for extended thinking
thinking={
"type": "enabled",
"budget_tokens": 10000 # Up to 10k tokens for reasoning
},
messages=[{
"role": "user",
"content": question
}]
)
result = {"thinking": "", "answer": ""}
for block in response.content:
if block.type == "thinking":
result["thinking"] = block.thinking
elif block.type == "text":
result["answer"] = block.text
return result
# Example: a multi-step scientific reasoning problem
result = reason_with_extended_thinking(
"A researcher observes that a protein's enzymatic activity "
"increases when the temperature rises from 25C to 37C, "
"but drops sharply at 42C. Meanwhile, circular dichroism "
"spectroscopy shows no change in secondary structure at 37C "
"but significant changes at 42C. What can we conclude about "
"the relationship between structure and function, and what "
"experiment would confirm it?" # circular dichroism (CD) spectroscopy measures protein secondary structure by detecting differential absorption of polarized light
)
print(f"Thinking tokens used: ~{len(result['thinking'].split())}")
print(f"Answer preview: {result['answer'][:300]}...")
Step-Through: Chain-of-Thought Probability Gain
Self-consistency decoding (Wang et al., 2022) improves CoT reliability by sampling multiple reasoning chains at high temperature and selecting the most common final answer via majority vote, on the assumption that correct reasoning paths are more likely to converge than incorrect ones. Trace through this method with a tiny example. Suppose we ask a model "What is 17 times 24?" five times at high temperature and get these five sampled answers: 408, 408, 412, 408, 396.
Step 1: Collect answers: {408, 408, 412, 408, 396}.
Step 2: Count frequencies: 408 appears 3 times, 412 appears 1 time, 396 appears 1 time.
Step 3: Majority vote selects 408 (frequency 3/5 = 60%).
Step 4: Confidence score = 3/5 = 0.60. Since no single sample exceeded 80% agreement, flag this answer as "moderate confidence."
Step 5: Verify: 17 x 24 = 408. The majority vote recovered the correct answer even though 2 out of 5 individual samples were wrong. A single sample had only a 60% chance of being correct; majority voting over 5 samples raised reliability because the errors were diverse (412 and 396 are different wrong answers that do not reinforce each other).
4. Tool-Augmented Reasoning
Extended thinking and scratchpads expand the model's internal workspace, yet some reasoning steps require not more thinking but access to external ground truth that no amount of token generation can provide.
Pure language model reasoning hits hard limits: arithmetic errors on large numbers, inability to access current data, hallucinated facts. Tool-augmented reasoning addresses these limits by letting the model delegate specific subtasks to external tools: calculators, databases, code interpreters, search engines.
The architecture, which we explore in depth in Chapter 12: Building MCP Servers, follows a simple pattern: the model decides when to use a tool and what to ask; the tool provides a reliable answer; the model incorporates the answer into its reasoning chain. Figure 4.3 illustrates the general structure of this neural-symbolic loop as realized in AlphaGeometry.
import json
tools = [
{
"name": "calculate",
"description": "Evaluate a mathematical expression. "
"Use for any arithmetic, algebra, or calculus.",
"input_schema": {
"type": "object",
"properties": {
"expression": {
"type": "string",
"description": "Math expression, e.g. '2**10 * 3.14'"
}
},
"required": ["expression"]
}
},
{
"name": "lookup_constant",
"description": "Look up a physical or chemical constant.",
"input_schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Constant name, e.g. 'speed_of_light'"
}
},
"required": ["name"]
}
}
]
CONSTANTS = {
"speed_of_light": {"value": 2.998e8, "unit": "m/s"},
"boltzmann": {"value": 1.381e-23, "unit": "J/K"},
"avogadro": {"value": 6.022e23, "unit": "mol^-1"},
"planck": {"value": 6.626e-34, "unit": "J*s"},
"gas_constant": {"value": 8.314, "unit": "J/(mol*K)"},
}
def handle_tool_call(tool_name: str, tool_input: dict) -> str:
"""Execute a tool call and return the result."""
if tool_name == "calculate":
try:
# Safe eval for math expressions
result = eval(tool_input["expression"], {"__builtins__": {}},
{"abs": abs, "round": round, "min": min, "max": max})
return json.dumps({"result": result})
except Exception as e:
return json.dumps({"error": str(e)})
elif tool_name == "lookup_constant":
name = tool_input["name"].lower().replace(" ", "_")
if name in CONSTANTS:
return json.dumps(CONSTANTS[name])
return json.dumps({"error": f"Unknown constant: {name}"})
return json.dumps({"error": f"Unknown tool: {tool_name}"})
def reason_with_tools(question: str) -> str:
"""Reasoning loop with tool use for scientific calculations."""
client = anthropic.Anthropic()
messages = [{"role": "user", "content": question}]
while True:
response = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=4096,
tools=tools,
messages=messages
)
# Collect all content blocks
tool_results = []
final_text = ""
for block in response.content:
if block.type == "text":
final_text += block.text
elif block.type == "tool_use":
result = handle_tool_call(block.name, block.input)
tool_results.append({
"type": "tool_result",
"tool_use_id": block.id,
"content": result
})
if response.stop_reason == "end_turn":
return final_text
# Feed tool results back for continued reasoning
messages.append({"role": "assistant", "content": response.content})
messages.append({"role": "user", "content": tool_results})
# Example: requires both constant lookup and calculation
answer = reason_with_tools(
"What is the de Broglie wavelength of an electron "
"moving at 1% of the speed of light? "
"Show your work using the formula lambda = h / (m * v)."
)
print(answer)
AlphaGeometry (Trinh et al., 2024) demonstrates the most sophisticated integration of neural and symbolic reasoning to date. It solves olympiad-level geometry problems by combining two systems, as shown in Figure 4.3:
- A neural language model trained on synthetic geometry proofs. This model proposes auxiliary constructions ("add point \(E\) as the midpoint of \(AC\)") that unlock proof paths the symbolic engine cannot find on its own.
- A symbolic deduction engine (DD+AR: Deductive Database with Algebraic Reasoning) that applies geometry rules (angle chasing, congruence, similarity) deterministically and exhaustively.
The architecture loops: the symbolic engine attempts a proof, gets stuck, asks the neural model for a construction, adds it to the diagram, and retries. This loop solved 25 out of 30 olympiad geometry problems, approaching the performance of gold-medalist humans. (A successor system, AlphaGeometry 2, announced in 2024, raised this to 28 out of 30, surpassing gold-medalist average performance by combining a Gemini-based language model with a faster symbolic engine.)
For discovery AI, AlphaGeometry is a template: use neural models for the creative, abductive step (proposing constructions, hypotheses) and symbolic systems for the deductive, verification step (checking consequences, proving theorems). Neither alone is sufficient. The integration pattern recurs in Chapter 35: Symbolic Regression and Chapter 53: AI Scientists. Figure 4.2.1 illustrates neuro-symbolic reasoning loop.
Real-World Application: Drug Repurposing with Tool-Augmented Reasoning
Insilico Medicine's Chemistry42 platform uses tool-augmented LLM reasoning to propose drug repurposing candidates. The language model generates hypotheses about which existing drugs might bind novel protein targets, then delegates molecular docking calculations and absorption, distribution, metabolism, excretion, and toxicity (ADMET) property checks to specialized chemistry engines. According to the company, this loop identified a candidate for idiopathic pulmonary fibrosis that reached Phase II clinical trials, reportedly compressing a step that traditionally takes years of screening into weeks of iterative neural-symbolic search.
5. Reasoning Models: Scaling Test-Time Compute
Tool augmentation addresses the reliability of individual reasoning steps, but a separate question remains: can we make models reason more deeply by giving them more time to think?
The 2024-2025 generation of "reasoning models" represents a paradigm shift: instead of making models larger (scaling training compute), these systems make models think longer (scaling test-time compute, the computational budget spent during inference rather than during training). The key idea is reinforcement learning (RL) on reasoning traces: the model learns not just to produce correct answers but to produce effective reasoning chains that lead to correct answers.
The landscape includes OpenAI's o1 and o3 series, DeepSeek-R1, and Claude's extended thinking mode. (As of mid-2025, this space continues to evolve rapidly; newer entries such as OpenAI's o4-mini and Google's Gemini 2.5 with "thinking mode" have joined the field, each offering different cost/performance tradeoffs for reasoning tasks.) These models share several architectural principles:
- Internal chain-of-thought: the model generates a potentially long reasoning trace before the final answer
- Backtracking and self-correction: the trace may explore dead ends, recognize errors, and try alternative approaches
- Compute-accuracy tradeoff: more thinking tokens generally yield better answers, with diminishing returns
- Verification loops: the model checks its own intermediate results, catching errors that a single-pass model would propagate
For discovery AI, reasoning models offer a new design dimension. Instead of choosing a larger model for harder problems, we can choose a longer thinking budget. This is particularly valuable for scientific reasoning, where problems vary enormously in difficulty but the types of reasoning steps are relatively consistent.
The theoretical foundations of test-time compute scaling are still being established. Snell et al. (2024) show that optimal compute allocation depends on problem difficulty: easy problems benefit more from parallel sampling (generate multiple answers and vote), while hard problems benefit more from sequential deepening (think longer on a single chain). Brown et al. (2024) demonstrate that verifier models can guide test-time search, effectively turning reasoning into a tree search problem, connecting back to the search frameworks of Chapter 1. More recently, DeepSeek-R1 (Guo et al., 2025) showed that pure RL on reasoning traces, without any supervised fine-tuning on human-written chains, can produce strong reasoning behavior; the model learns to generate long, self-correcting chains of thought entirely from outcome-based reward signals. This result suggests that reasoning may emerge as an optimal strategy under RL pressure rather than requiring explicit imitation of human reasoning patterns, with significant implications for training future discovery-oriented models.
6. Systematic Reasoning Failures
LLM reasoning, however impressive, exhibits systematic failure modes that discovery AI practitioners must understand and design around. These are not random errors; they are predictable consequences of how language models process information.
6.1 Compositional Fragility
LLMs handle individual reasoning steps well but degrade as the number of required steps increases. A model that correctly solves 95% of single-step inferences will solve only \(0.95^{10} \approx 60\%\) of 10-step chains correctly (assuming independent errors). In practice, errors tend to compound worse than independently because early errors can corrupt the context for subsequent steps, though the degree of correlation varies by task and model.
6.2 Sensitivity to Irrelevant Information
Adding irrelevant details to a problem statement can dramatically change model performance. The classic demonstration: "John has 5 apples. He gives 2 to Mary. He then takes a bus to school. How many apples does John have?" Models sometimes incorporate the bus detail into their arithmetic. For discovery AI, this means that noisy or tangential data in the prompt can derail reasoning about the core scientific question.
6.3 Reversal Curse and Directional Failures
Models trained on "A is B" do not automatically know "B is A." Berglund et al. (2023) demonstrated that models trained on "The mother of X is Y" could not answer "Who is Y's child?" This asymmetry matters for scientific reasoning because many relationships are bidirectional (if gene A regulates gene B, then gene B is regulated by gene A), and a model's inability to reverse its training patterns creates blind spots.
Checkpoint
So far: LLM reasoning chains are fragile in three distinct ways: accuracy drops exponentially with step count (compositional fragility), irrelevant context can derail otherwise correct reasoning (sensitivity to noise), and knowledge learned in one direction does not transfer to the reverse direction (reversal curse).
6.4 Faithful vs. Unfaithful Chain-of-Thought
The previous failure modes concern what the model gets wrong; this one concerns what it gets right for the wrong reasons. Perhaps the most dangerous failure mode: the reasoning chain can be wrong while the answer is right (the model "knows" the answer from pattern matching and generates a post-hoc justification, a plausible-sounding explanation constructed after the conclusion rather than before it), or the chain can be right while the answer is wrong (the model follows correct logic but makes an arithmetic or factual error in the final step). Turpin et al. (2023) showed that CoT explanations are frequently unfaithful to the model's actual computation, meaning you cannot trust the reasoning trace as a reliable explanation of the model's conclusion.
def diagnose_reasoning(
question: str,
expected_answer: str,
n_samples: int = 5
) -> dict:
"""Diagnose reasoning reliability by sampling multiple chains.
If the model gives different answers across samples, the
reasoning is fragile. If chains differ but answers agree,
the model may be pattern-matching rather than reasoning.
"""
client = anthropic.Anthropic()
samples = []
for i in range(n_samples):
response = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=2048,
temperature=1.0, # Increase diversity
messages=[{
"role": "user",
"content": f"Think step by step:\n{question}"
}]
)
samples.append(response.content[0].text)
# Extract final answers (last line heuristic)
answers = [s.strip().split("\n")[-1] for s in samples]
unique_answers = set(answers)
diagnosis = {
"question": question,
"n_samples": n_samples,
"unique_answers": len(unique_answers),
"answers": answers,
"consensus": len(unique_answers) == 1,
"agreement_rate": max(
answers.count(a) for a in unique_answers
) / n_samples,
}
# Check if consensus matches expected
if diagnosis["consensus"]:
diagnosis["correct"] = expected_answer.lower() in answers[0].lower()
else:
diagnosis["correct"] = any(
expected_answer.lower() in a.lower() for a in answers
)
return diagnosis
# Example: test a tricky reasoning problem
result = diagnose_reasoning(
question=(
"A researcher measures the boiling point of a liquid at "
"sea level (100.0C) and at 2000m altitude. "
"At altitude, will the boiling point be higher, lower, "
"or the same? Why?"
),
expected_answer="lower",
n_samples=5
)
print(f"Consensus: {result['consensus']}")
print(f"Agreement rate: {result['agreement_rate']:.0%}")
print(f"Correct: {result['correct']}")
The implication for discovery AI is clear: never trust a single LLM reasoning chain in a scientific context. Design systems that (1) sample multiple reasoning paths, (2) verify intermediate steps with symbolic or computational tools, (3) separate the creative/abductive role (where LLMs excel) from the verification/deductive role (where symbolic systems are more reliable), and (4) maintain explicit confidence estimates. The reasoning pipeline in Section 4.4 embodies all four principles.
The "unfaithful chain-of-thought" phenomenon creates an unsettling parallel with human cognition. Psychologists have long known that humans frequently confabulate explanations for their decisions (Nisbett & Wilson, 1977). When asked why they chose a particular product, people generate plausible-sounding reasons that have nothing to do with the actual cause (which might be shelf position or packaging color). LLMs appear to have learned this very human skill of fluent rationalization. Whether this is a feature or a bug depends on whether you are building a reasoning engine or a persuasion engine.
For production reasoning pipelines, several frameworks handle the scaffolding shown above. Claude's extended thinking API provides native test-time compute scaling in two lines of code. LangChain and LlamaIndex offer tool-use abstractions that handle the tool-call loop automatically. The Anthropic Cookbook provides production-tested patterns for structured reasoning with Claude. These frameworks reduce the reasoning loop from ~50 lines to ~5, handling retries, token management, and output parsing internally.
Try It: Measure CoT Reliability on Science Questions
Build a small reasoning reliability benchmark using only Python and an LLM API key. This project takes about 30 minutes and produces a quantitative view of when chain-of-thought helps and when it fails.
- Curate five questions spanning a range of reasoning depths: one single-step factual recall question (e.g., "What is the chemical formula of water?"), one two-step inference, one requiring three or more chained steps (e.g., a stoichiometry problem), one requiring numerical computation, and one requiring an abductive/creative leap. Record the ground-truth answer for each.
- Write a script that sends each question to an LLM twice: once with a direct prompt ("Answer concisely:") and once with a CoT prompt ("Think step by step, then give your final answer:"). Use
temperature=0for reproducibility. Store both responses. - Add multi-sample consistency: for the CoT condition, resend each question five times at
temperature=1.0. Extract the final answer from each sample (take the last line or parse after "ANSWER:"). Compute the agreement rate (fraction of samples giving the same answer). - Score and tabulate: for each question, record (a) whether the direct prompt was correct, (b) whether the CoT prompt was correct, (c) the multi-sample agreement rate, and (d) the number of reasoning steps in the CoT trace. Print a table using Python's built-in
printformatting or thecsvmodule. - Analyze the pattern: plot agreement rate versus reasoning depth (number of steps) using
matplotlib. You should observe that agreement drops as step count rises, confirming the compositional fragility discussed in Section 6.1. Write two sentences summarizing what you found.
Lab: Measuring Compositional Fragility in LLM Reasoning
Goal: Empirically measure how LLM reasoning accuracy degrades as the number of required reasoning steps increases, reproducing the compositional fragility effect from Section 6.1.
Tools needed: Python 3.10+, the anthropic or openai SDK, and matplotlib for plotting.
Setup: Construct a set of arithmetic word problems at five difficulty levels: 1-step (single addition), 2-step (add then multiply), 3-step, 5-step, and 8-step chains. Create four problems per level (20 total), each with a known ground-truth answer. Use problems simple enough that each individual step is trivial (single-digit operations), so that any errors reflect chaining failures, not per-step difficulty.
What to vary: (1) Number of reasoning steps (1 through 8). (2) Prompting strategy: run each problem with direct prompting and with chain-of-thought prompting. (3) Sample count: run each condition 5 times at temperature=1.0 to measure consistency.
What to observe: Plot accuracy (fraction correct) versus step count for both prompting strategies. Compute the agreement rate across the 5 samples at each level. Fit an exponential decay curve \(p^k\) to your direct-prompting results to estimate the model's per-step accuracy \(p\). Compare the empirical curve with the theoretical prediction. Does CoT shift the curve or change its shape?
Exercises
- Conceptual: Explain why chain-of-thought prompting helps more on arithmetic problems than on sentiment analysis. Frame your answer in terms of the number of reasoning steps and the role of working memory.
- Coding: Implement a "self-consistency" scorer: run the same question through a model 10 times with temperature=1.0, extract the final answer from each, and return the majority vote along with a confidence score (fraction of samples agreeing). Test it on three science questions of varying difficulty.
- Analysis: The AlphaGeometry architecture loops between a neural proposer and a symbolic verifier. Design a similar two-system architecture for a different scientific domain (e.g., chemistry reaction prediction, biological pathway analysis). Specify what the neural system proposes, what the symbolic system verifies, and what the loop termination condition is.
What's Next
Language models approximate reasoning with predictable strengths and failure modes. Section 4.3: Causal Reasoning and the Do-Calculus develops the most scientifically important reasoning form in full mathematical detail: causal reasoning. Where LLMs tell us "X and Y tend to appear together," causal reasoning tells us whether changing X will change Y, the question that every scientific experiment is designed to answer.
Bibliography
Foundational Papers
The paper that launched chain-of-thought prompting. Showed that adding "Let's think step by step" or providing few-shot examples with reasoning traces dramatically improves performance on arithmetic, commonsense, and symbolic reasoning benchmarks.
Introduced the scratchpad technique: training models to produce intermediate computation steps in an explicit workspace. Precursor to modern extended thinking approaches.
AlphaGeometry: a neuro-symbolic system that solves olympiad geometry by combining a neural language model (for proposing auxiliary constructions) with a symbolic deduction engine. Achieved near-gold-medalist performance.
Introduced self-consistency decoding: sample multiple reasoning chains and take the majority-vote answer. A simple, effective method for improving reasoning reliability.
Reasoning Failures
Demonstrates a fundamental asymmetry in LLM knowledge: training on directional statements does not yield bidirectional understanding. Important implications for scientific knowledge retrieval.
Shows that chain-of-thought explanations are frequently unfaithful to the model's actual reasoning process. Biasing features in the input can change the answer without changing the explanation.
Analyzes the tradeoff between training-time and test-time compute scaling, showing that optimal allocation depends on problem difficulty. Foundational for reasoning model design.
Tools & References
API reference for Claude's extended thinking feature, including budget allocation, streaming, and integration patterns.
Interleaves reasoning traces with tool-use actions, enabling models to reason about when and how to use external tools. Foundational pattern for tool-augmented reasoning.
Comprehensive survey covering deductive, inductive, abductive, mathematical, and commonsense reasoning in LLMs. Useful reference for the full taxonomy of reasoning capabilities and benchmarks.