Skip to main content

Exercises — Contextualized representations

Self-check questions and worked answers

← Back to the lesson: Contextualized representations

Check your understanding

Extended exercises on this topic.

Consider the two occurrences of Romans in “What have the Romans ever done for us?” and “Where did the Romans build their roads?” For this controlled comparison, assume the tokenizer assigns both occurrences the same token ID and that we compare them at the same simplified position.

  1. Does the embedding lookup return the same initial vector for both occurrences?
  2. Must their hidden states after the Transformer layers be identical? Explain what the different surrounding sequences can contribute.
  3. Which parts of the computation can use the surrounding words, and which part—the lookup itself—cannot?

Now consider “They built roads.” Who does they refer to in this exchange? Why does resolving that reference not mean the initial embedding lookup already contained the answer?

You have understood this step if you can distinguish the identity of the initial vector, context-dependent information built by the Transformer, and the interpretation of a reference in the dialogue. The same initial vector does not force identical hidden states; this example also does not prove that one attention head alone resolves reference.

Which change can reach the current state?

In a causal GPT with fixed parameters, consider three sequences of token IDs: [A, X, U], [B, X, U], and [A, X, V]. Inspect the second position, occupied by X, in all three sequences. Position indices match and the forward pass is deterministic.

  1. Which sequences give the same base embedding vector at X?
  2. In which comparison can a block change the hidden state of X? Which operation allows this?
  3. In which comparison must the state of X stay the same at every layer? What enforces that property?
  4. Revisit this after the lessons on logits, distributions, and cross-entropy. For [A, X, U], the distribution at position X after projection and softmax assigns \(1/2\) to U and \(1/4\) to V. On switching to [A, X, V], which distribution do you read at the position of X? For each sequence, which token is the target there, and what is the local loss with a one-hot target?
Show the worked answer
  1. All three. The same ID selects the same row of the embedding table. The position of X is fixed as well.
  2. Between [A, X, U] and [B, X, U], self-attention can pass the effect of changing A to B on to X. A difference is possible and depends on the learned weights.
  3. Between [A, X, U] and [A, X, V], the causal mask prevents X from using the third position. The accessible prefix stays the same at every layer, so the state at X does too, up to numerical tolerance.
  4. The final state at X is the same in the two sequences, so the same final normalization and projection produce the same logit row and therefore the same vocabulary distribution. Shifting the targets changes which column you read: for [A, X, U], the target is U, and the loss is \(-\ln(1/2)=\ln 2\). For [A, X, V], the target is V, and the loss is \(-\ln(1/4)=\ln 4\). The distribution depends on the accessible prefix [A, X], while the local loss also depends on the observed target.

Return to the review plan · From IDs to representations · Understand Transformer computation

Guided investigation — an SAE feature in Neuronpedia

Open the Gemma Scope example · Feature dashboard documentation.

Before reading the label, write down what you expect to find in the activations. Record model, source/release, layer, hook, and index.

  1. Compare the text explanation with the positive activations offered as evidence. Does it describe all examples or only a subset?
  2. Look for at least two counterexamples or ambiguous contexts. State what would make you revise the hypothesis.
  3. Inspect activation density and logits: what additional information do these views provide, and what do they not establish?
  4. If custom-text inference is available, test a positive/negative minimal pair and an adversarial case. Record the exact texts and source.
  5. Write a conclusion limited to the observations, distinguishing correlation, interpretation, and causation.

Success criterion: produce a falsifiable hypothesis, document at least one counterexample, and avoid turning an automatic label into an established fact. Activations describe where a feature responds; logits show associations with outputs; an automatic explanation summarizes a hypothesis. None alone proves that the feature is one unique concept or causes the observed behaviour. Steering requires controls before any causal conclusion.

Language: Français · English