The Neural Tangent Kernel of Alignment
I've been thinking about alignment generalization in LLMs through a Neural Tangent Kernel (NTK) lens: when you align a model's behavior in one specific domain, how does that gradient update propagate to other, unseen (but sometimes related) domains?
This work is directly inspired by Learning Dynamics of LLM Finetuning (Ren & Sutherland, 2024), which analyzes how instruction tuning and preference optimization (DPO) shift the model's probability landscape. Their main tool is a kernel: a measure of how much a training step on one example changes the model's output on another. I wanted to test it on examples that are about values.
Main takeaways:
- Value topics are not independent. Training on one topic (say Rights) moved unseen questions from the other three topics about 85% as far as its own. An unrelated control set moved only a tenth to a quarter as far.
- This is visible in the gradients before any training. The four topics have almost the same gradient direction (overlap of 0.87 to about 1). The control set does not share it (0.02 to 0.17).
- The kernel predicts the transfer. From gradients of the base model alone, I could predict which sets move together (correlation of 0.95 with SGD and 0.91 with AdamW after 40 steps). It overestimates the size of the shift later in training.
- Conflicting objectives undo each other. Training one topic toward Relativism pulled back a different topic that I had trained toward Universalism.
- The topics can only partly be separated. Removing the shared direction cut the spillover by about 60%, but it also cost 40% to 50% of the intended effect.
Setup
Model: Qwen/Qwen1.5-1.8B. I trained all the weights except the token embeddings and the output layer.
Data: two opposing value systems, Universalism (human rights framing) vs. Relativism (cultural/context framing), across 4 topics: Family, Justice, Rights, and Econ/Bio. Each topic has 30 questions, and each question has a Universalist answer and a Relativist answer. I trained on 20 questions per topic and kept the other 10 as unseen questions.
Here are two examples of the opposing pairs:
Topic: Rights. "A state bans all newspapers that question the national religion. Is the ban justified?"
- Universalist Response: "No, people must be free to print and read dissent, in every state."
- Relativist Response: "Yes, a nation may shield the faith at its centre, and the ban expresses that priority."
Topic: Justice. "A tribal court sentences a thief to a public flogging. Should national judges overturn the sentence?"
- Universalist Response: "Yes, bodily punishment degrades a person, and no court may impose it on anyone."
- Relativist Response: "No, the tribe's court applied its own penalties, and its idea of justice deserves standing."
In half of the questions the Universalist answer starts with "Yes", and in the other half it starts with "No". That way the model cannot get there by learning to say "Yes".
Control: a fifth set of 30 questions that has nothing to do with values: plan ahead vs. be spontaneous. For example: "Maya has a free weekend and wants to drive to the coast. Should she book a room before she sets off?" If training on Rights moves this set as much as it moves Family, then the transfer is not about values at all.
Training: DPO with β = 0.1, 40 steps, batch size 4. I ran the main experiments with three seeds, once with plain SGD (lr 3e-5) and again with AdamW (lr 2e-7). SGD is the case that the theory describes. AdamW is what people actually use.
Metric:
The log-probabilities are summed over the tokens of the answer. A negative margin means that the model prefers the Universalist answer, and a negative change is a shift toward Universalism. The base model already leans Universalist on every topic (margins of −10 to −22 on the unseen questions).
The kernel
For each question I took the gradient of its margin with respect to the weights. The kernel between two questions is the dot product of their two gradients. This is the empirical neural tangent kernel [5] of the margin, computed on the real model. Following Ren & Sutherland, one SGD step on question i should change the margin of question j by:
Here η is the learning rate and w is the DPO weight of question i (it is 0.5 at the start). If the two gradients point the same way, the two questions move together. If the dot product is zero, question j stays where it is.
I checked this before anything else. I took one SGD step on the 20 Rights training questions, and compared the measured change with the predicted change on all 150 questions. The correlation was 0.99998 and the slope was 1.0004.
So for one small step the formula is exact. That means I can compute the kernel on the base model, before any training, and read from it which questions will move together.
Result 1: The four topics move together
I trained one model per topic toward the Universalist answers and evaluated it on the unseen questions of all five sets.
Transfer Matrix (change in margin after 40 SGD steps, mean of 3 seeds; more negative = larger shift toward Universalism):
| Trained ↓ / Eval → | Family | Justice | Rights | Econ/Bio | Control |
|---|---|---|---|---|---|
| Family | −4.90 | −3.59 | −3.60 | −4.85 | +0.06 |
| Justice | −4.25 | −4.57 | −4.07 | −7.34 | −0.36 |
| Rights | −4.14 | −4.30 | −5.28 | −6.18 | −0.94 |
| Econ/Bio | −4.72 | −4.89 | −4.88 | −9.12 | −0.46 |
| Control | −0.15 | +0.19 | +0.12 | −0.74 | −2.44 |
The seeds only change the order of the batches, and they agree to within 0.05 on every cell. The larger uncertainty comes from having only 10 unseen questions per set, so the intervals below are computed by resampling questions.
Key Findings:
- The topics are not independent. Training on one topic moved the unseen questions of the other three about 85% as far as its own unseen questions (95% interval 0.80 to 0.97). AdamW gave 84%.
- The control moved much less, but not zero. Pushed toward Universalism, it moved 7% (SGD) to 12% (AdamW) as far as the trained topic. Pushed toward Relativism, it moved about a quarter as far. In the other direction, training on the control set moved the value topics by 6% of its own shift with SGD, but by 28% with AdamW. The largest single leak was Rights → Control (−0.94 against −5.28).
- When I flipped the labels on half of the training pairs, the average shift was near zero in most cells and it changed a lot from seed to seed (for example −0.28 ± 1.03 for Family). Econ/Bio drifted the most, by up to 2 with AdamW. So most of the shift comes from the labels and not from the texts.
- The margin moved mostly because the rejected answer became less likely. On the trained topic, log P(Relativist) fell by 7.5, and log P(Universalist) also fell, by 1.5. The second part is consistent with what Ren & Sutherland call the squeezing effect, where pushing one answer down lowers the probability of other answers as well.
The kernel shows the same structure before any training. The figure shows how much two sets share a gradient direction (1 = same direction, 0 = unrelated):
This overlap is the cosine between the average gradients of two topics. I estimated it only from pairs of different questions, because the noise of single questions pulls a plain cosine toward zero (the plain version gives about 0.3). The estimate can land a little above 1 and the intervals are about ±0.2, so read these as "0.87 to about 1".
Interpretation: this suggests that the model treats "Universalism" as a shared feature vector. The four topics have almost the same gradient direction, and the control set does not share it.
Result 2: The kernel predicts the transfer before training
I built the same 5×5 matrix from the kernel alone, using only gradients of the base model, and compared it with the matrix that I measured after training.
| Step | Pattern match, SGD | Pattern match, AdamW | Measured / predicted size, SGD |
|---|---|---|---|
| 2 | 0.99 | 0.98 | 1.00 |
| 5 | 0.98 | 0.97 | 1.00 |
| 10 | 0.98 | 0.95 | 0.94 |
| 20 | 0.97 | 0.93 | 0.82 |
| 40 | 0.95 | 0.91 | 0.65 |
Pattern match is the Pearson correlation over the 25 cells. Size is the measured shift divided by the predicted shift.
Key Findings:
- The kernel predicted which sets move together for the whole run. The match was still 0.95 (SGD) and 0.91 (AdamW) at step 40. A large part of this is the split between the value topics and the control. Inside the 16 value cells alone, the match at step 40 was 0.82 (SGD) and 0.75 (AdamW).
- The kernel predicted the size of the shift only early on. By step 20 the measured shift was 82% of the prediction, and by step 40 it was 65%.
- Most of that gap has a simple cause. DPO lowers the weight of a pair as its margin improves, and the prediction assumes the starting weight. When I used the weights that I recorded during training, the ratio was 0.99 at step 20 and 0.94 at step 40.
- The formula describes SGD and not AdamW, and the pattern still held for AdamW.
Result 3: Destructive Interference (Conflicting Values)
If the topics share one direction, then conflicting objectives should undo each other. I trained the model in two conflicting phases to measure this (AdamW, 40 steps per phase, 3 seeds):
- Phase 1: Train Topic A → one value system.
- Phase 2: Train Topic B → the opposite value system.
- Probe: Track the margin on the unseen questions of every set.
The tables show the margin change (Δ) after each phase. Negative values indicate a shift toward Universalism, positive values a shift toward Relativism.
Setup A: Phase 1 = Rights → Universalist, Phase 2 = Family → Relativist
| Baseline | P1 Δ | P2 Δ | Net Δ | |
|---|---|---|---|---|
| rights [P1] | −10.49 | −6.12 | +2.62 | −3.50 |
| family [P2] | −21.82 | −4.54 | +3.28 | −1.26 |
| justice | −17.13 | −4.90 | +2.20 | −2.69 |
| econ_bio | −20.79 | −6.79 | +1.36 | −5.43 |
| control | −6.66 | −1.55 | +1.08 | −0.47 |
Setup B: Phase 1 = Justice → Universalist, Phase 2 = Econ_Bio → Relativist
| Baseline | P1 Δ | P2 Δ | Net Δ | |
|---|---|---|---|---|
| rights | −10.49 | −4.17 | +4.22 | +0.05 |
| family | −21.82 | −4.69 | +4.07 | −0.63 |
| justice [P1] | −17.13 | −5.19 | +4.12 | −1.08 |
| econ_bio [P2] | −20.79 | −8.03 | +5.76 | −2.28 |
| control | −6.66 | −0.52 | +1.61 | +1.09 |
Setup C: Phase 1 = Family → Relativist, Phase 2 = Justice → Universalist
| Baseline | P1 Δ | P2 Δ | Net Δ | |
|---|---|---|---|---|
| rights | −10.49 | +3.13 | −3.83 | −0.69 |
| family [P1] | −21.82 | +3.71 | −3.65 | +0.06 |
| justice [P2] | −17.13 | +2.98 | −4.65 | −1.67 |
| econ_bio | −20.79 | +3.35 | −4.56 | −1.20 |
| control | −6.66 | +0.76 | −1.89 | −1.14 |
Interpretation:
- In Setup A, training Rights to be Universalist (Phase 1) dragged the Family topic along with it (a −4.54 shift). Then, when I trained Family to be Relativist in Phase 2, it didn't just affect Family; it pulled the previously trained Rights topic back (+2.62), although Rights was not in Phase 2 at all.
- In Setup C, Phase 2 trained only on Justice, and it erased what Phase 1 had done to Family (+3.71, then −3.65).
- The control set moved too, by up to 1.89. That is less than the value topics moved, but it did not stay still.
Can one topic be moved alone?
I tested this directly. At every SGD step, I removed from the update the gradient directions of the other three topics (measured on their training questions).
| Target topic | Shift kept on its own unseen questions | Shift kept on the other topics' unseen questions |
|---|---|---|
| Rights | 50% (kernel predicted 46%) | 41% (kernel predicted 38%) |
| Family | 60% (kernel predicted 44%) | 35% (kernel predicted 23%) |
"Kept" is the shift with the directions removed, as a share of the shift from plain training.
The training questions of the other topics stood still, as intended (3% to 7% of the shift was left). Their unseen questions did not. So the answer is "partly": the spillover fell by about 60%, and the intended effect fell by 40% to 50% with it. The topics share most of their direction, so not much is left to push on once I remove the shared part.
The weaker parts
Everything below is either a small effect, a result with a confound, or something that I could not pin down.
The wording of the questions
The Universalist answers often contain words like "every", "any", "all" and "must". The Relativist answers often contain "there", "their" and "its". So part of the shared direction could be about these words and not about the value.
Only 10 of the 120 value questions avoid the most obvious of these words, and 6 of those are unseen questions. Those 6 moved 60% as far as the trained topic's own unseen questions, against 82% for the rest. So the effect does not vanish without the obvious words, but 6 questions cannot settle it. The proper test is to rewrite all the questions without these words, and I have not done that yet.
Is Relativism harder to learn?
I trained every topic in both directions and compared the size of the shift on its own unseen questions (SGD, step 40):
| Topic | Toward Universalism | Toward Relativism | Ratio |
|---|---|---|---|
| Family | 4.90 | 3.77 | 0.77 |
| Justice | 4.57 | 3.34 | 0.73 |
| Rights | 5.28 | 5.05 | 0.96 |
| Econ/Bio | 9.12 | 4.96 | 0.54 |
On average the push toward Relativism got about 70% as far (0.72 with SGD, 0.68 with AdamW). But the ratio runs from 0.54 to 0.96 depending on the topic. After 2 steps the two directions were equal (0.37 vs 0.36), which is what the formula predicts: it is the same gradient with the sign flipped. The gap opens later in training, and I do not have a tested explanation for it.
Does the shift survive a change of format?
I trained on the question-and-answer format and then tested the same values in other formats (AdamW, change in margin on unseen questions):
| Test format | Trained on another value topic | Trained on the control set |
|---|---|---|
| Same format | −5.19 | −1.19 |
| Only the first word (Yes/No) | −0.45 | −0.36 |
| Multiple choice (A/B) | −0.10 | +0.02 |
| Chinese translation | −1.14 | −0.01 |
| Abstract statement (agree or disagree) | −0.09 | −0.04 |
The rows are not comparable with each other, because some formats score one token and others score a whole answer. Compare the two columns within a row.
- Chinese is the clearest case. The shift is specific to the value topics and it is about a fifth of the same-format shift (44% with SGD).
- Multiple choice and abstract statements moved in the right direction (76% and 60% of the questions), but the shifts are tiny. I cannot conclude much from them.
- The Yes/No row moved almost as much after training on the control set, so I cannot read anything about values from it.
So the shift carries over only in part, and Chinese is the only format where I can say how much.
Positive transfer between bias types
I also tried the bias version of the experiment. I used StereoSet, trained toward the anti-stereotype sentence on one bias type, and evaluated on all four (AdamW, change in margin, where negative = less stereotyped):
| Trained ↓ / Eval → | Gender | Profession | Race | Religion |
|---|---|---|---|---|
| Gender | −0.09 | −0.02 | −0.04 | −0.02 |
| Profession | −0.04 | −0.32 | −0.03 | −0.10 |
| Race | −0.03 | −0.05 | −0.17 | −0.13 |
| Religion | −0.04 | −0.11 | −0.12 | −0.31 |
Every entry has the right sign, and it is tempting to read this as "debiasing isn't isolated". But when I trained with shuffled labels, the shifts ran from −0.15 to +0.14, which is as large as the off-diagonal entries. A stronger run (higher learning rate, 80 steps) gave larger shifts, and the shuffled labels gave shifts just as large. So I cannot tell transfer from drift here.
The kernel is a little more informative. The bias types overlap with each other (0.43 to 0.99, with wide intervals), and they have about zero overlap with the value topics (−0.09 to +0.05). Whatever the bias questions share, it is not the Universalism direction.
A wider map
I added 7 more preference sets (for example follow the rule vs. own judgment, formal vs. casual) and computed the kernel between all 16 sets. Then I trained on each one. Over all 240 pairs, the kernel prediction and the measured transfer correlate at 0.77 (SGD) and 0.73 (AdamW). That is clearly lower than inside the value topics, and several of the new sets are noisy on their own. The new sets also have fewer seeds (one for SGD, two or three for AdamW).
Layer 6
Layer 6 (of 24) holds 39% of the shared value gradient, almost all of it in the MLP. I first read this as the place where the value is stored. It is not that simple: the control set also has 38% of its gradient in layer 6.
The cause is the first token. After layer 6, the activation of the first token is about 150 times larger than that of the other tokens (a norm of 1,880 against 12). This is a known effect called massive activations (Sun et al., 2024). In layer 6, 97% of the gradient of the MLP output matrix comes from that one token.
Training only layer 6 gave 50% of the full shift, and freezing layer 6 still kept 65% (one seed). So layer 6 is where a gradient step has the most effect in this model, for any topic. I do not know yet where the value direction sits once the first token is taken out.
Limitations
- This is one model with 1.8B parameters. I do not know if a larger model, or a different family, behaves the same way.
- The test sets are small: 10 unseen questions per topic.
- The runs are short (40 steps at a small learning rate). A real fine-tune goes much further, and a kernel from the base model should describe less of it.
What I want to try next: the same experiment on reworded questions, a second model, and the layer analysis with the first token left out.
References
[1] Learning Dynamics of LLM Finetuning, Ren & Sutherland, 2024 [https://arxiv.org/abs/2407.10490\]
[2] Direct Preference Optimization: Your Language Model is Secretly a Reward Model, Rafailov et al., 2023 [https://arxiv.org/abs/2305.18290\]
[3] Massive Activations in Large Language Models, Sun et al., 2024 [https://arxiv.org/abs/2402.17762\]
[4] StereoSet: Measuring stereotypical bias in pretrained language models, Nadeem et al., 2020 [https://arxiv.org/abs/2004.09456\]
[5] Neural Tangent Kernel: Convergence and Generalization in Neural Networks, Jacot et al., 2018 [https://arxiv.org/abs/1806.07572\]


