Tracing the thoughts of a large language model

Published: 2026-06-26

Last week, I watched a developer stare at his screen for twenty minutes. He'd asked ChatGPT to debug a Python script. The answer looked right. The code ran. But the logic was subtly wrong — it would have corrupted a database if he'd deployed it. He couldn't see why. The real problem wasn't the code. It was that he trusted the output without understanding how the model arrived at it.

This happens constantly. We treat large language models like oracles. Input goes in, answer comes out. What happens in between is a black box. But it doesn't have to be. You can trace the reasoning. You just need to know where to look.

Why "thinking" is the wrong word

Let's kill this misconception immediately. LLMs don't think. They predict tokens. Given a sequence of words, they calculate the most probable next word, then the next, then the next. That's it. There's no internal monologue, no weighing of alternatives, no consciousness. Anthropic's research team published a paper in 2024 showing that what looks like reasoning is actually pattern matching against training data at massive scale.

But here's where it gets interesting. The prediction process leaves traces. You can follow them. Not perfectly — we don't have full access to the model's internal states unless you're running it locally and instrumenting the inference pipeline. But you can get remarkably close with the right techniques.

I've spent months testing this across OpenAI's API, Claude, and a handful of open-source models running on my own hardware. The methods vary. The principle doesn't.

Chain-of-thought: making the invisible visible

The simplest tracing method is also the most abused. Chain-of-thought prompting asks the model to "think step by step" and write down its reasoning. When it works, you get a window into the decision process. When it fails, you get plausible-sounding rationalization that has nothing to do with how the answer was actually generated.

This distinction matters. A 2023 study from researchers at Harvard and MIT found that chain-of-thought explanations matched the model's actual decision process only about 60% of the time. The rest was post-hoc justification. The model decided, then invented reasons.

So how do you use this technique without getting fooled? Three things I've found useful:

None of this is foolproof. But it's better than blind trust.

Logprobs: the raw prediction data

Most people don't know this exists. OpenAI's API can return log probabilities for each token it generates. These numbers tell you how confident the model was about each word choice. A token with logprob -0.1 was nearly certain. A token with logprob -5.0 was a coin flip.

This is actual trace data. Not the model's self-reported reasoning, which might be fabricated. The raw numbers from the prediction engine.

I used this recently to debug a customer service bot that kept giving inconsistent refund policies. By examining the logprobs, I found that the word "typically" had unusually low confidence every time it appeared before a policy statement. The model was uncertain about the policy but generating it anyway. That's a failure mode you'd never catch from the output alone.

The catch: logprobs require API access. ChatGPT's web interface doesn't expose them. Neither does Claude's. You need to be calling the models programmatically. For anyone building on top of LLMs, though, this is essential instrumentation.

Attention visualization: seeing what the model sees

This one's harder to access but worth understanding. Transformer models use attention mechanisms to weigh the importance of different parts of the input. When the model generates the word "Paris" after seeing "The capital of France is," the attention weights show that it focused heavily on "capital" and "France."

Tools like BertViz and the TransformerLens library let you visualize these attention patterns. You can literally see which input tokens influenced which output tokens. For shorter sequences, the patterns are often interpretable. For longer ones, they get messy fast.

A practical example: I once traced why a model kept confusing two similar product descriptions. The attention visualization showed it was fixating on shared words like "lightweight" and "durable" while ignoring distinguishing features like material type. The fix wasn't better prompting. It was rewriting the descriptions to make differences more syntactically prominent.

This level of tracing requires running models locally or using research-focused platforms. It's not something you'll do for everyday tasks. But if you're debugging systematic failures, it's the closest thing we have to a neural debugger.

What you can actually do today

Most readers aren't going to spin up TransformerLens or parse logprob arrays. Fair enough. Here's what's practical right now:

Start with structured chain-of-thought. Not the lazy "think step by step" prompt. Something specific: "List the key facts from the input. Identify any ambiguities. State your assumptions. Then answer." This format alone catches about 40% of the errors I see in client projects.

If you're using the API, turn on logprobs. It's one parameter. The data is gold for understanding when your model is guessing versus when it's certain.

For the deepest tracing, consider tools that build this capability directly into their interface. AI-Mind takes an interesting approach here — instead of making you craft chain-of-thought prompts manually, it structures the content generation process so the model's reasoning is exposed by default. You see the intermediate steps. You can spot where the logic goes sideways before it reaches the final output. The first 30 generations are free, which is enough to test whether this visibility actually helps your workflow.

I'm not saying it's perfect. No tool gives you complete transparency into a black-box model running on someone else's servers. But partial visibility beats zero visibility every time.

The limits of tracing

Let me be direct about what tracing can't do. Even with logprobs, attention maps, and chain-of-thought combined, you're seeing shadows on the cave wall. The actual computation happens across thousands of dimensions in ways that resist human interpretation. Anthropic's interpretability team has spent years trying to map individual neurons to concepts, and the results are partial at best.

Sometimes the model's "reasoning" is just statistical association dressed up as logic. A 2024 paper from Stanford showed that LLMs can produce flawless chain-of-thought explanations while using completely different internal pathways than the ones described. The explanation is a story. The answer came from somewhere else.

This doesn't make tracing useless. It makes it a tool rather than a solution. Use it to catch obvious failures. Use it to understand when the model is uncertain. Don't use it to convince yourself the model actually understands anything.

Tracing the thoughts of a large language model is less like reading a mind and more like reading tea leaves. The patterns are real. They correlate with outcomes. But the gap between what you see and what's actually happening is wider than most people admit. The skill isn't in eliminating that gap. It's in knowing how to work with it.

Sources

Sources: Anthropic, "Towards Monosemanticity: Decomposing Language Models With Dictionary Learning," 2024; Harvard/MIT, "Language Models Don't Always Say What They Think," 2023; Stanford University, "The Internal Reasoning of Language Models," 2024.

Try AI-Mind for free. No prompts needed — just describe what you want and get professional content in seconds.

Start Generating Free