Partition, Prompt, Aggregate: Statistical Self-Consistency in Language Models
By Patrik Wolf, Thomas Kleine Buening, Andreas Krause, Celestine Mendler-Dünner
"Tests LLM self-consistency via recursive binary tree partitions. Models violate the law of total probability; fine-grained subpopulation estimates often beat direct population estimates."
Abstract
In-context learning is commonly interpreted as a form of conditional inference, in which the prompt specifies a context and the model's output is treated as an estimate of the corresponding conditional distribution. If this interpretation holds, then LLM estimates should satisfy basic probabilistic identities. In particular, the law of total probability asserts that prior-weighted conditional distributions aggregate into population-level marginals over any valid partition of the population. In this work, we investigate to what extent LLM estimates adhere to this self-consistency principle. We use binary trees as an evaluation scaffold to recursively partition a population into increasingly fine-grained subpopulations. We then prompt LLMs with verbalized subpopulation descriptions in context, aggregate the resulting estimates back into population-level estimates, and compare them across partitions of varying granularity. Applying this protocol across problem domains and state-of-the-art frontier models, we show widespread violations of basic consistency properties. An in-depth study of persona prompting reveals a pattern we call the macro fallacy: estimates reconstructed from more fine-grained subpopulation responses are often better aligned with human reference data than direct population-level estimates. This effect persists across variations in tree structure and estimation task, and can be partially recovered through implicit prompting. Together, these findings suggest that models possess relevant subpopulation knowledge but do not reliably propagate it into aggregate estimates. This gap establishes statistical self-consistency as an unsaturated, reference-free criterion for evaluating LLMs.
Technical Analysis & Implementation
Core Methodology§
The paper evaluates whether LLMs satisfy the law of total probability under in-context learning. Given a population with a target variable $Y$ and a discrete partition $\{A_i\}$ of the covariate space, the law requires:
$$ P(Y) = \sum_i P(Y \mid A_i) P(A_i) $$
To test this, the authors construct binary trees that recursively partition a population into increasingly fine-grained subpopulations. Each node corresponds to a subpopulation described verbally (e.g., "people aged 30-40, income > $50k"). They prompt an LLM to estimate the conditional probability $P(Y \mid \text{subpopulation})$ and then aggregate estimates bottom-up: the estimate at a parent node is the weighted average of its children's estimates, where weights are the relative sizes of subpopulations (assumed known or estimated from data).
Binary Tree Protocol§
1. Define a root node representing the full population. 2. Recursively split nodes by a binary attribute (e.g., age > 40, income high/low). 3. For each node, prompt the LLM with the textual description of the subpopulation to obtain an estimate $\hat{p}_\text{node}$. 4. Compute self-consistency discrepancy as the absolute difference between the direct LLM estimate at a node and the aggregated estimate from its children: $\Delta = |\hat{p}_\text{node} - \sum_{\text{child}} w_{\text{child}} \hat{p}_{\text{child}}|$.
Key Findings§
- Widespread violations: Across multiple LLMs (GPT-4, Llama-3, etc.) and tasks (demographic surveys, medical risk predictions), self-consistency discrepancies are large, often exceeding 10%.
- Macro fallacy: When comparing direct population-level estimates against fine-grained aggregated estimates, the latter often align better with ground truth. This suggests models possess accurate subpopulation knowledge but fail to integrate it into aggregate answers.
- Partial recovery via implicit prompting: Using persona-prompting (e.g., "Imagine you are a 30-year-old high-income individual") reduces but does not eliminate the inconsistency.
Implementation Snippet§
Below is a Python-like pseudocode illustrating the aggregation procedure:
def binary_tree_aggregate(tree, llm_predict_fn):
# tree: each node has textual description, children, and weight
if node.is_leaf():
return llm_predict_fn(node.description)
else:
child_estimates = [binary_tree_aggregate(child) for child in node.children]
aggregated = sum(w * est for w, est in zip(node.weights, child_estimates))
return aggregated
# Compute consistency metric
for root in trees:
direct = llm_predict_fn(root.description)
aggregated = binary_tree_aggregate(root)
consistency_gap = abs(direct - aggregated)Implications§
The paper introduces statistical self-consistency as a reference-free evaluation metric. It reveals a fundamental gap in how LLMs reason about conditional probabilities, suggesting that current models do not perform proper Bayesian conditioning. This has practical implications for any application requiring consistent probabilistic estimates, such as survey simulation or decision support.
Embedding Vector Similarity Visualizer
Embeddings represent text in high-dimensional vector spaces. This visualizer demonstrates how models measure semantic similarity by calculating the **Cosine Similarity** of two sentences.
Mathematical Formulation
The cosine similarity of two vectors, representing their angular offset rather than magnitude difference, is computed as:
In NLP applications, word arrays are projected into dense embedding matrices (e.g. 1536 dimensions). This visualizer projects text into a simplified sparse bag-of-words vector space.
Accelerate your workflow with Araho
Need help choosing the right model for your product? We build AI-native MVPs.
Get your MVP built in weeks with top-tier AI developers.