Search

Search papers and lessons

Discovering Latent Knowledge in Language Models Without Supervision

Collin Burns, Haotian Ye, Dan Klein et al. · 2022

Burns et al. (2022) find a truth direction in a language model's hidden activations with an unsupervised probe, and that probe answers yes-no questions better than the model's own outputs.

On this page

  • Colour = topic mix
  • Probability
  • Calculus
  • Discrete math
  • Neural network basics
  • Linear algebra
  • Architectures
  • ReadReady to readNot yet

TL;DR

A language model can be wrong in what it says while holding a better internal sense of what is true. This paper proposes Contrast-Consistent Search (CCS), a way to find that internal sense from the model's hidden activations alone, with no labels and no model outputs. The method learns a small probe that gives each yes-no answer a probability, and it asks that a statement and its negation get opposite probabilities. Across 6 models and 10 question-answering datasets, the probe beats zero-shot accuracy by 4 points on average.

Builds on: Language Model, Transformer, Logistic Regression, Mean Squared Error · Leads to: Mechanistic Interpretability, Representation Learning

Why it mattered

Language models are trained to imitate text or to score well on human ratings, and both objectives can reward output that is false. The paper gave a concrete method for asking what a model "believes" separately from what it says. Its central claim is that the internal representation of truth is salient enough to be found with a short unsupervised procedure, and that the probe can outperform the model's own answers, which is important when the model is misled. It is an early example of unsupervised knowledge elicitation, a line of work aimed at models that may be harder to check than their evaluators can manage.

The problem

Suppose you want to know whether a model answers "Are cats mammals?" correctly. The obvious approach is to read its output, and that works only when the output is trustworthy. Two situations break it. First, the model may have learned to repeat common misconceptions, because imitation rewards matching human text. Second, human raters may be unable to check a claim, so the training signal rewards text that looks true. In both cases the output and the internal state can disagree.

To study the internal state, the paper needs an input it can use without labels. The feature is ϕ(x)\phi(x), a vector of hidden activations the model produces for an input xx. The goal is a method that answers each question qiq_i using only the unlabeled ϕ(⋅)\phi(\cdot), where the probe is trained without any correct answers.

How it works

Take one yes-no question, "Are cats mammals?", and the tiny case of a single question. The method runs in four steps.

  1. Make two statements. Turn the question into two sentences by answering it "Yes" and "No" with a prompt, giving x+x^{+} ("Are cats mammals? Yes") and x−x^{-} ("Are cats mammals? No"). Exactly one of them is true.
  2. Read the activations. Feed each sentence through the model and keep the hidden vector at the last token of a chosen layer. This gives ϕ(x+)\phi(x^{+}) and ϕ(x−)\phi(x^{-}).
  3. Remove the obvious difference. The two sentences differ in their final word, and that difference is not the question of truth. The method subtracts the mean of all "Yes" vectors from each "Yes" vector and the mean of all "No" vectors from each "No" vector. After this, the two groups no longer sit in separate clusters.
  4. Fit a probe. Learn a linear map θ\theta and bias bb that turns each normalized vector into a probability pp that the statement is true. Train θ\theta and bb so that p(x+)p(x^{+}) and 1−p(x−)1 - p(x^{-}) agree and both values are far from one half.

A two-line check after step 4: if the probe gives p(x+)=0.9p(x^{+}) = 0.9 and p(x−)=0.1p(x^{-}) = 0.1, the statement "Yes" is judged true, the two numbers are consistent, and both are confident, so the answer is "Yes". If the probe gives 0.50.5 for both, it has learned nothing, and the loss should reject it.

flowchart LR
  Q["Question"] --> P["Yes and No statements"]
  P --> H["Hidden activations phi"]
  H --> N["Subtract group means"]
  N --> R["Linear probe then sigmoid"]
  R --> L["Consistency and confidence loss"]
  L -->|"update theta, b"| R

Once the probe is trained, a new question is answered by averaging the two readings, p~\tilde{p}, and checking whether it is above one half.

The math

Definition (CCS probe). For a pair of statements x+x^{+} and x−x^{-}, a CCS probe is a function pθ,bp_{\theta,b} that maps a normalized activation vector to a number in (0,1)(0, 1), here pθ,b(ϕ~)=σ(θTϕ~+b)p_{\theta,b}(\tilde{\phi}) = \sigma(\theta^{T}\tilde{\phi} + b), where σ\sigma is the sigmoid. The probe is fitted without labels, using only the consistency and confidence losses below.

Step 3 in symbols: normalization

The two groups of activations are centred separately. Let μ+\mu^{+} be the mean of {ϕ(xi+)}i=1n\{\phi(x_i^{+})\}_{i=1}^{n} and μ−\mu^{-} the mean of {ϕ(xi−)}i=1n\{\phi(x_i^{-})\}_{i=1}^{n}. Then

ϕ~(xi+)=ϕ(xi+)−μ+,ϕ~(xi−)=ϕ(xi−)−μ−\tilde{\phi}(x_i^{+}) = \phi(x_i^{+}) - \mu^{+}, \qquad \tilde{\phi}(x_i^{-}) = \phi(x_i^{-}) - \mu^{-}

Centring removes the shared "ends with Yes" or "ends with No" offset, which is the feature the method does not want.

Step 4 in symbols: the two losses

Consistency asks that a statement and its negation have probabilities that sum to one:

Lconsistency(θ,b;qi)=[pθ,b(xi+)−(1−pθ,b(xi−))]2L_{\text{consistency}}(\theta, b; q_i) = \left[ p_{\theta,b}(x_i^{+}) - \bigl(1 - p_{\theta,b}(x_i^{-})\bigr) \right]^2

Consistency alone has a trivial solution, where every statement gets probability one half. Confidence rules that out by penalizing the smaller of the two probabilities:

Lconfidence(θ,b;qi)=min⁡{pθ,b(xi+),pθ,b(xi−)}2L_{\text{confidence}}(\theta, b; q_i) = \min\{ p_{\theta,b}(x_i^{+}), p_{\theta,b}(x_i^{-}) \}^2

The paper notes that the confidence loss by itself also has a degenerate solution, so both losses are needed. The total loss averages both over the nn questions:

LCCS(θ,b)=1n∑i=1n(Lconsistency(θ,b;qi)+Lconfidence(θ,b;qi))L_{\text{CCS}}(\theta, b) = \frac{1}{n} \sum_{i=1}^{n} \Bigl( L_{\text{consistency}}(\theta, b; q_i) + L_{\text{confidence}}(\theta, b; q_i) \Bigr)

Worked by hand: with p(x+)=0.9p(x^{+}) = 0.9 and p(x−)=0.1p(x^{-}) = 0.1, the consistency term is (0.9−0.9)2=0(0.9 - 0.9)^2 = 0 and the confidence term is min⁡{0.9,0.1}2=0.01\min\{0.9, 0.1\}^2 = 0.01. With both at 0.50.5, the consistency term is (0.5−0.5)2=0(0.5 - 0.5)^2 = 0, but the confidence term is 0.250.25, so the loss prefers the first probe.

Prediction in symbols

The two readings of a question are averaged:

p~(qi)=12(p(xi+)+(1−p(xi−)))\tilde{p}(q_i) = \frac{1}{2} \Bigl( p(x_i^{+}) + \bigl(1 - p(x_i^{-})\bigr) \Bigr)

The answer is "Yes" when p~(qi)\tilde{p}(q_i) is greater than 0.50.5. The loss does not say which cluster means "Yes", so the paper takes the better of the two labelings on a test set, which is a choice made in evaluation. The appendix sketches how the clusters can be named without labels, by using conjunctions of statements, if the model can handle them.

Results

Setup. The paper tests six models: T5, UnifiedQA and T0 (encoder-decoder), GPT-J (autoregressive), and RoBERTa and DeBERTa (encoder-only). The ten datasets cover sentiment, topic, natural language inference, story completion, question answering and common-sense reasoning. Each dataset is subsampled to 1000 examples (COPA has only 500), split 60 percent for unsupervised training and 40 percent for testing, and tested with about nine prompts each.

Main result (Table 1). Averaged over models with T0 excluded, CCS reaches 71.2 percent accuracy, against 67.2 percent for calibrated zero-shot and 62.8 percent for plain zero-shot. Its accuracy also varies less across prompts: the average standard deviation is 3.2, against 6.9 for plain zero-shot. Logistic regression, which uses labels, reaches 83.7 percent and is the ceiling. CCS beats calibrated zero-shot on every model except RoBERTa, where it is 2 points worse. T0 was trained on nine of the ten datasets, so its zero-shot number is inflated, and it is excluded from the mean.

Misleading prompts. When a prefix of wrong answers is added to the prompt, calibrated zero-shot on UnifiedQA drops from 80.4 to 70.9 percent, a fall of 9.5 points. CCS moves from 82.1 to 83.8 percent on the same prompts. The paper notes that the prefix may be out of distribution, so this is evidence and not proof.

Limits. The authors state that CCS needs a direction that separates true from false inputs, and that it is not clear when a model both can evaluate truth and actively does so. They did not test deceptive models, because they knew of no evaluation setup for active lying. CCS also remains below the logistic regression ceiling, and the paper lists the gap as open.

Reading guide

  • Section 1, Introduction. Read after Language Model and Self-Supervised Learning. It explains the motivation: imitation and rating-based training can reward false text.
  • Section 2.1 and 2.2, Problem and Method. Needs Transformer for the idea of a hidden state at a token, and Logistic Regression for the sigmoid probe. Work through the four steps above before reading the equations.
  • Section 3.1, Setup. Needs Zero-Shot Learning for the baselines and calibration, and Language Model for log-probabilities. The prompt design is in the appendix.
  • Section 3.2, Evaluation. Needs the averages and standard deviations in Table 1. Read it alongside the loss definitions, to see that the probe is judged only against held-out labels.
  • Section 3.3, Analysis. Needs Principal Component Analysis for the top-component method in Table 2 and Residual Stream for why middle layers can be better than the last.
  • Section 5, Discussion. Reads most clearly after Mechanistic Interpretability, since the open questions concern what the probe actually finds.

Check yourself

QuestionIn one sentence, what does CCS learn from, and what does it not use?Show answer
It learns from the model's hidden activations on pairs of "Yes" and "No" statements, with no labels and no model outputs.
QuestionA probe gives p(x plus) = 0.8 and p(x minus) = 0.2 for one question. Compute the consistency loss, the confidence loss, and the averaged answer p-tilde, and say which answer is predicted.Show answer
Consistency: 0.8 minus (1 minus 0.2) is 0.8 minus 0.8, which is 0, so the loss is 0. Confidence: the minimum of 0.8 and 0.2 is 0.2, and 0.2 squared is 0.04. Averaged answer: one half of (0.8 plus (1 minus 0.2)) is one half of 1.6, which is 0.8. Since 0.8 is greater than 0.5, the predicted answer is "Yes".
QuestionWhy does the method need the confidence loss as well as the consistency loss?Show answer
Consistency alone is satisfied by setting every probability to one half, which is a trivial solution that carries no information. The confidence loss pushes the smaller of the two probabilities toward zero, so the probe must commit to an answer.
QuestionSuppose you apply plain zero-shot to a model and find its accuracy falls by 9.5 points when a wrong-answer prefix is added, but CCS barely changes. What does this suggest, and what does it not prove?Show answer
It suggests the probe reads something in the activations that is not moved by the misleading prefix, so CCS is not simply copying the model's output. It does not prove that the probe finds truth in general, because the paper notes the prefix may itself be out of distribution and CCS could be using a different feature.
QuestionA dataset has 1000 examples. The paper splits it 60 percent for unsupervised training. How many examples are used for training, and how many for testing?Show answer
Training uses 60 percent of 1000, which is 600 examples. Testing uses the remaining 40 percent, which is 400 examples.

Sources

Read the full paper

Collin Burns, Haotian Ye, Dan Klein et al., 2022. arXiv:2212.03827