TL;DR
When a Large Language Model (LLM) "thinks step-by-step," what is that chain of text, mathematically speaking? Right now, we treat Chain-of-Thought (CoT) traces as unstructured strings, making it hard to unify how we prompt, train, and interpret models. This paper introduces Copper, a tiny probabilistic programming language that compiles messy text thoughts into formal executable code—unlocking exact probability queries, mathematical robustness guarantees, and clever single-call reasoning strategies.
What Problem Does This Paper Address?
Since Chain-of-Thought prompting took over AI, step-by-step traces have ended up everywhere: we use them to boost test-time accuracy, train reasoning models, and peek inside the black box for interpretability. Yet, across all these sub-fields, we lack a shared formal language for what a CoT trace actually denotes.
Because we treat traces in ad-hoc, task-specific ways, an insight gained while studying interpretability doesn't cleanly translate into a better training loss or prompting strategy. The authors ask a foundational question: what if we stopped treating CoTs merely as sequences of tokens, and started modeling them as formal probabilistic programs?
Methods
The authors design Copper, a lightweight, Python-like discrete probabilistic programming language tailored for LLM reasoning. Copper separates generating text from interpreting its logic across two levels:
- The Program Level (Syntax): Individual reasoning steps become Boolean random variables (
Flip, essentially weighted coin flips). Logical dependencies between steps become standardif-thenbranches, reasoning failures raiseValueErrorexceptions, and final answers arereturnvalues. Crucially, Copper is agnostic to where step weights come from—you can plug in token likelihoods from logits, ask the model for its "verbalized confidence" (e.g., 0.8 confident), or use an external reward model. - The Inference Level (Semantics): Computing the probability of an answer reduces to reachability—calculating the odds of navigating the
if-thenbranches to hit a specificreturnstatement. Copper compiles programs into tractable logical circuits and uses Weighted Model Counting (WMC)—a classic computer science technique that sums the probabilities of all valid logical paths—to compute exact, differentiable probabilities.
To overcome the mathematical pitfalls of multiplying many probabilities together, the authors add a differentiable Factor operator, allowing custom aggregation of step scores (like averaging log-odds). Using this, they invent Bayesian multi-answer CoT: a prompting strategy that asks an LLM, in a single forward pass, to state candidate answers with initial prior confidences, and then generate supporting step-by-step evidence for each, selecting the winner via exact Bayesian inference.
Datasets
The authors evaluate GPT-4o, Llama-3.3-70B-Instruct, and Qwen-2.5-7B-Instruct across five existing commonsense and multi-choice reasoning benchmarks (no new datasets are introduced):
- Binary QA: BoolQ and StrategyQA.
- Multiple-Choice (from BIG-Bench Hard): Date Understanding, Geometric Shapes, and Salient Translation Error Detection.
Key Insights and Ideas
- The "Length Confound" at the Program Level: Even if you normalize each step's probability by its token length, standard likelihood scoring multiplies step probabilities together (
P1 and P2 and P3). Because probabilities are $\le 1$, longer, more thorough reasoning chains get mathematically penalized compared to short, shallow ones—even when the longer chain has higher average step quality! Rearranging branches can't fix this; you need non-multiplicative score aggregation (Factor). - Unifying AI Sub-fields as Program Queries: Once a CoT is a Copper program, disparate tasks become simple mathematical queries over the same object: prompting is marginal inference, interpretability is taking gradients with respect to step weights, and robustness is finding the smallest weight perturbation that flips the output.
- Verbal Confidence Beats Raw Logits for Priors: When models assign initial probabilities to candidate answers, reading their stated verbal confidence dramatically outperforms looking at raw token logits, which tend to suffer from severe label bias (stubbornly concentrating on a single answer like "yes" or "no").
- Same Text, Different Explanations: By taking gradients over a fixed CoT trace scored by different models, Copper reveals that GPT-4o, Llama, and Qwen rely on completely different steps as load-bearing evidence to reach the exact same conclusion.
Key Results
- Single-Call Efficiency vs. Accuracy Tradeoff: Bayesian multi-answer CoT beats direct prompting across all models and even outperforms multi-call search-based Tree-of-Thoughts on Qwen-7B (64.62% vs. 39.90%), though forcing models to output strict programmatic formatting incurs a slight accuracy dip (~3–7%) compared to vanilla CoT on larger models.
- Superior Stability & Error Detection: Using first-order gradient estimates, Bayesian CoT shows larger robustness margins (requiring bigger parameter shifts to flip an answer) than likelihood-based programs in 5 out of 6 model-task pairs (e.g., median margin of 0.3131 vs. 0.1083 for Llama-70B on BoolQ). Furthermore, predictions with the top 10% largest margins are consistently more accurate than the bottom 10%.
- Cross-Model Trace Reuse: Treating CoTs as reusable programs works both ways. Scoring GPT-4o's traces with Qwen-7B's weights boosts Qwen's micro-averaged accuracy by +5.7 percentage points (56.86% vs. 51.16%). Conversely, Llama-70B can salvage weak traces generated by Qwen, lifting performance from Qwen's 51.16% up to 65.31%.
Limitations and Future Work
- Simplified Proxies: Copper assumes reasoning steps are conditionally independent coin flips given the program structure—a clean, useful proxy, but clearly a simplification of a transformer's dense, entangled probability distribution.
- Formatting Overhead: Asking smaller or even frontier models to simultaneously reason, number steps, declare dependencies, and output verbal confidences in one shot taxes instruction-following, costing some raw accuracy compared to unconstrained text generation.
- Future Directions: The authors envision using Copper's step-level gradients to filter and weight data for CoT distillation and reinforcement learning. They also propose expanding the language beyond basic
if-thenlogic to include loops (iteration), external tool calls, and richer memory states to capture full agentic workflows.
Summary updated