Turn an LM head into a classifier with label words
Why it matters Initialising a classifier from label-word embeddings gives a strong zero-shot starting point and speeds up few-shot fine-tuning.
A pretrained LM already scores every vocabulary word. For a classification task with label words like "yes" and "no", you can reuse those rows of the output embedding as the classifier, before or instead of training a new head.
Write verbalizer_probs(h, E, label_ids). h is (n, d) final hidden states, E is the (V, d) output embedding, label_ids is a list of C token ids. Build W = E[label_ids] (C, d), logits = h @ W.T (n, C), and return (W, probs) where probs is a stable softmax over the C label logits only (renormalised among the labels).
def verbalizer_probs(h, E, label_ids)Example
h = [[1, 0]], E = [[1, 0], [0, 1], [2, 0]], label_ids = [2, 1] gives W = [[2, 0], [0, 1]] and probs = [[0.8808, 0.1192]].
Understand the idea
A language model's last layer already knows what "yes" and "no" mean: each word has a row in the output embedding, and the score for a word is the dot product of the hidden state with that row. For a yes/no task you can simply keep those two rows as a tiny classifier, like hiring someone who already knows the job.
Example: hidden h = [1, 0]. The row for label word A is [2, 0] and for B is [0, 1]. Scores are 2 and 0. Softmax over just these two gives e^2 / (e^2 + 1) = 0.881 and 0.119.
Rule: W = E[label_ids]; logits = h W^T; probs = softmax(logits) over the C labels.
Renormalising over the labels removes probability mass the LM gives to all other words. This verbaliser idea comes from prompt-based few-shot learning, and the same rows make a good initial weight when you add and train a real classification head.
Shapes and data flow
h (n, d), E (V, d) -> W = E[label_ids] (C, d) -> logits (n, C) -> probs (n, C)