{"record":{"id":"N-Q-LM-TRANSPLANT","slug":"can-you-transplant-a-relationship-inside-a-transformer","kind":"notebook","title":"Can you transplant a relationship inside a transformer?","dek":"In small four-block models trained on invented facts, a relation component from one person’s question, added to another’s, gives the second person’s fact in half the pairs and never the first’s: after the first block only, and by the plan’s criterion in 4 of 9 Llama models.","abstract":"A third note on Q-LM, a modern experiment. Two small transformers, a custom model and a Llama-shaped one, were trained with three seeds on worlds of invented facts: 24 countries, their capitals and continents, and 48 people with a home city, most of them with a birth city too. Both carry a fact to a phrasing they never saw it in; Llama composes two relations; neither reverses one. Inside them, the first transplants of whole states moved the answer, not the fact: a donor with the same answer through another relation worked as well. Before the answer forms, the custom model holds the entity at its own position, and a few attention heads carry it to the answer position, by the plan’s criterion in 8 of 9 Llama models and 4 of 9 custom ones. In Llama, after block 1, a relation component can be moved on its own. Taken from “P was born in” into “P lives in” for the same person, it makes the birth city win for 70% of held-out people, passing the plan’s criterion in 8 of 9 models. Taken from person B and added to person A’s “A lives in”, it gives A’s birth city in 51% of pairs and B’s in none, passing in 4 of 9. The custom model passes neither in any model. The fact is not looked up at the entity’s position, as an account from larger models has it: that test failed every criterion. It is written at the answer position, where a city vector chosen by an external table makes Llama state an edited capital in 90% of prompts, and 92% on three fresh worlds, with no weight changed.","created":"2026-11-27","version":"1.0","status":"OPEN","publication":"published","authors":["Chris Hay"],"lineage":"INVENTED WORLDS OF FACTS → WHOLE-STATE TRANSPLANTS → THE ENTITY AND ITS HEADS → A RELATION MOVED ALONE → A FACT FROM A TABLE","concepts":["causal-intervention","model-representation","residual-stream","factual-recall","activation-patching","external-memory"],"related":["N-Q-LM","N-Q-LM-SCALE","W-LARQL"],"media":[],"body":[{"kind":"observation","label":"01 / WORLDS OF INVENTED FACTS","text":"Q-LM’s semantic worlds are small and made up: 24 countries on 4 continents, each with one capital, and 48 people, each living in one city, every name an invented word. Most facts can be stated in two phrasings, such as “C has capital K .” and “the capital of C is K .”, and some statements are held out of training. Three worlds give the same names different facts. Two small transformers, the custom model of the earlier notes and a Llama-shaped one, were trained on each world with three seeds: 18 models, of four blocks each. Both carry a fact to the phrasing it was held out of, 98% of the time. Llama composes two relations, a person’s city and that city’s continent, in 65% of tests, passing the plan’s criterion in 7 of 9 runs. Neither reverses a relation: given only “C has capital K”, the custom model never completes “K is located in” with C, and Llama does so for 5 of 12 countries in one run of 9, and never in the other 8. The first version of the worlds scored 87% to 95% there, through an ordering leak found because the result was too good. The grammar learner of the earlier notes fails every one of these tests. In version 3, 44 of the 48 people also have a birth city, never the city they live in.","references":[{"label":"QLM-SEMANTIC-001, docs/results-qlm-semantic-001.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-qlm-semantic-001.md"},{"label":"Its plan, docs/qlm-semantic-001-plan.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/qlm-semantic-001-plan.md"}]},{"kind":"observation","label":"02 / IT MOVED THE ANSWER","text":"The first test, LARQL-QLM-SEM-001 on the version-2 worlds, replaced the last-position state of “the capital of C′ is” with the state of a prompt about C. From the other wording, C’s capital then wins as it does from the same wording. But a donor with the same answer through another relation and another subject, “P lives in” for a resident P of C’s capital, works just as well: in Llama, after block 1, in 98% of pairs. What moved was the answer, already resolved after block 1 or 2 in Llama and by block 3 in the custom model. The plan had been amended before measurement for exactly this. It asked that states of the same fact be at least 0.1 more alike than states of the same answer, where similarity peaks; the excess was 0.04 in Llama and 0.00 in the custom model, a failure. There is weaker evidence of something fact-specific earlier, an excess of 0.26 at block 2 and 0.11 at block 3 in Llama and 0.13 at block 3 in the custom model, but by then the transplants move the answer as well from a same-answer donor. Moving only a relation component from “C is in” into “C has capital” did turn the answer into C’s continent. But with 4 continents and a 4-dimensional subspace, that component could carry the type of the answer and the continent itself, the confound the plan’s second amendment named. Version 3 was made to remove it.","references":[{"label":"LARQL-QLM-SEM-001, version 2, docs/results-larql-qlm-sem-001-v2.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-sem-001-v2.md"},{"label":"Its plan and amendments, docs/larql-qlm-sem-001-plan.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/larql-qlm-sem-001-plan.md"}]},{"kind":"observation","label":"03 / THE ENTITY, CARRIED BY A FEW HEADS","text":"Before the answer forms, there is the entity. In the custom model, replacing the state at the country’s own position after block 1 with another country’s moves the computed capital to that country’s in 96% of pairs. The country is held as itself at its own position, and the later blocks compute its capital; after block 3, the transplant moves nothing. A first draft said this transplant did nothing; that was read from one model, and corrected. In Llama the hand-off happens mostly within block 1: after it, the share is 18%. LARQL-QLM-TRANSPORT-001 traced the hand-off. It is spread over two consecutive attention steps, blocks 2 and 3 in the custom model and 1 and 2 in Llama, so it fails the plan’s criterion that a single block’s attention do it. It is carried by a few heads that attend from the answer position to the country. With the top three heads chosen on half the pairs and judged on the other half, in an addendum after the first results, patching them gives the donor’s capital in 69% of pairs in Llama and 39% in the custom model, and restoring only them recovers the clean answer in 70% and 38%; three other heads do almost nothing. That passes the plan’s criterion in 8 of 9 Llama models and 4 of 9 custom ones; chosen and judged on the same pairs, the shares were 73% and 50%, with the same counts. In the custom model, what the top heads carry already looks partly like the capital. Their effects add there; in Llama, together they move the answer 1.2 to 1.8 times as far as the sum of their separate effects.","references":[{"label":"LARQL-QLM-SEM-001, version 2: the entity transplant","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-sem-001-v2.md"},{"label":"LARQL-QLM-TRANSPORT-001, docs/results-larql-qlm-transport-001.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-transport-001.md"}]},{"kind":"observation","label":"04 / A RELATION, MOVED ON ITS OWN","text":"In version 3 both relations, where a person lives and where they were born, answer with one of the same 24 cities, so a change of answer type cannot explain a switch. Only people whose two facts the model already gives are tested: 44 of the 48 in every model, 33 for fitting and 11 for testing. A relation subspace, the mean difference between “P is a native of” and “P is from” plus the top 3 directions of the per-person differences, was fitted on the 33 in the second wording, and applied to the other 11 in the first. Moving only the relation component of “P was born in” into “P lives in”, for the same person, after block 1, makes the birth city beat the home city for 70% of held-out people in Llama, from 36% to 100% across models. A random subspace, matched in the size of its change, does it for none. That passes the plan’s criterion in 8 of 9 Llama models, all at block 1. After block 2 it falls to 18%, and after block 3 to 5%: by then the answer has formed. The custom model passes in 0 of 9. Its relation may be held elsewhere, or not linearly; that was not tested.","references":[{"label":"LARQL-QLM-SEM-001, version 3, docs/results-larql-qlm-sem-001-v3.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-sem-001-v3.md"}]},{"kind":"observation","label":"05 / A QUESTION NEITHER DONOR ASKED","text":"The sharper test recombines two people, A and B. At the last position of “A lives in”, after block 1, B’s relation difference, “B was born in” minus “B lives in” projected on the relation subspace, is added. B is chosen so that B’s birth city is neither A’s birth city nor A’s home city. If A’s birth city wins, the model has answered a question neither prompt asked. In Llama it does in 51% of pairs, from 29% to 78% across models. B’s birth city wins in 0%, so this is not B’s answer carried over, and the random control in 0%. When it fails, nothing changes: A’s home city stays, in 49%. The criterion, from the plan’s third amendment, made before measurement, asks for A’s birth city in at least half the pairs, with B’s and the random control under a tenth. Llama passes in 4 of 9 models; in the other 5, A’s birth city wins in 29% to 49%. The custom model passes in 0 of 9. After block 2 the composed answer wins in 1% of pairs, and after that in none. The window is block 1 alone.","references":[{"label":"LARQL-QLM-SEM-001, version 3: the recombined query","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-sem-001-v3.md"},{"label":"The plan’s third amendment, docs/larql-qlm-sem-001-plan.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/larql-qlm-sem-001-plan.md"}]},{"kind":"observation","label":"06 / NOT LOOKED UP WHERE THE ENTITY IS","text":"An account reported in large models has the feed-forward layers at the subject’s position enrich it with its facts, and attention then extract the one asked for (Geva et al., 2023). LARQL-QLM-ENRICH-001 tested that here, and it failed every criterion, at every block, in every model. Patching the feed-forward output at the country’s position moves almost no answer, 1% on average at its best block; removing it costs nothing; restoring it repairs nothing; and one patch at a person’s position never changes both of their facts. A follow-up outside the plan patched the feed-forward at the answer position instead. There, in Llama, blocks 3 and 4 move the answer in 77% and 81% of pairs, and in the custom model block 4 in 57%, the last block, read directly by the output head. LARQL-QLM-RESOLVE-001 then found the answer forming in the middle blocks at the answer position: block 2 in Llama, block 3 in the custom model. That the late feed-forward looks the fact up afresh is not established; a first draft said it computes the answer again, and that overstated it. Four blocks may leave no room for a separate enrichment stage.","references":[{"label":"LARQL-QLM-ENRICH-001, docs/results-larql-qlm-enrich-001.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-enrich-001.md"},{"label":"LARQL-QLM-RESOLVE-001, part A, docs/results-larql-qlm-resolve-001.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-resolve-001.md"}]},{"kind":"observation","label":"07 / A FACT FROM A TABLE","text":"If the fact is written at the answer position, can it be written from outside? In RESOLVE-001, each city’s answer vector is the mean feed-forward output at the answer position of “P lives in” for that city’s two residents: another relation and other people, never the capital prompt. A table outside the model names a city for each country, and the feed-forward output of “the capital of C is” at one block is replaced by that city’s vector. With the table edited, a different city for every country, Llama states the edited capital in 90% of prompts when the vector enters at block 3, with block 4 running on it unchanged; a random vector of the same size gives the edited city in 1%. On three fresh worlds, trained after the plan was written, it gives 92%. No weight is changed. In the custom model an edit works only at the last block, in 74%, just under the plan’s 75%, and partly by construction. The table was told the entity and the relation. In LARQL-QLM-EXTERNAL-001, a provider had to read them from the activations alone. In Llama it read the relation in 93% of held-out prompts, but the entity in only 76%; in the custom model, 91% and 40%. with an edited graph, Llama stated the edited answer in 62%, and a birth city it had never learned in 42%, both short of the plan’s thresholds of 75% and three in four. Both results, and both failures, replicated on the fresh worlds.","references":[{"label":"LARQL-QLM-RESOLVE-001, part B and confirmation","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-resolve-001.md"},{"label":"LARQL-QLM-EXTERNAL-001, docs/results-larql-qlm-external-001.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-external-001.md"}]},{"kind":"connection","text":"Each experiment is reported against a plan written before it was measured, with the tables in the repository. The exceptions are labelled: the follow-up outside ENRICH’s plan, TRANSPORT’s held-out head selection and interaction analysis, added after its first results, and RESOLVE’s corrected measures.","links":[{"href":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-sem-001-v3.md","label":"The relation swap and the recombined query"},{"href":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-sem-001-v2.md","label":"Answer states, and the entity at its own position"},{"href":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-transport-001.md","label":"The heads that carry the entity"},{"href":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-enrich-001.md","label":"No enrichment at the entity’s position"},{"href":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-resolve-001.md","label":"Where the answer forms, and a fact edited from a table"},{"href":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-external-001.md","label":"A provider driven by activations alone"},{"href":"https://github.com/chrishayuk/larql","label":"LARQL, the series these experiments are named for"},{"href":"/notebook/from-q-systems-to-q-lm","label":"The first Q-LM note: the learner and the transformers"}]},{"kind":"refusal","title":"WHAT THIS DOES NOT SHOW","lines":["These are small synthetic models, four blocks each, trained on 24 countries and 48 people with invented names and a handful of relations. Whether larger models, more relations or real text behave the same is not shown, and nothing here is a claim about large language models.","The relation transplant is demonstrated in these small synthetic models after block 1 only, and in one of two architectures. The recombined query passes its criterion in 4 of 9 Llama models and in none of the custom ones, with 11 test people a world.","Failed criteria are failures: no fact state apart from the answer state at the block the plan named; no single block’s attention that carries the entity; no enrichment at the entity’s position; and a provider driven by activations that fails all three of its plan’s criteria, its entity decoding, 76% in Llama, the bottleneck.","The plans were written before measurement, and amended before measurement where this note says so. The feed-forward at the answer position was a follow-up outside its plan. Choosing heads on the pairs they were judged on inflated their shares by 0.04 to 0.11; the held-out shares are given. In RESOLVE-001, three measures were corrected before reporting, after one model of each architecture showed them wrong, and its true-table criterion cannot be judged, because the answer is already in the residual stream.","The interventions read PyTorch states. For Llama, LARQL’s per-layer states matched PyTorch’s to 1e-6 in an earlier experiment, GROUP-001, and that check was not repeated on these models. The custom model cannot be loaded by VINDEX3."],"principle":"A transplant that works may only have moved the answer; give it a donor with the same answer and a different question before calling it a relation."},{"kind":"question","text":"Does a deeper model hold a relation apart from its entity for longer?","status":"OPEN","detail":"In four blocks, a relation component can be moved on its own, in Llama, only after the first, and the fact has formed by the second or third. Models with more layers may have room for stages these could not show, such as the enrichment that failed here. Do they keep the relation separable, and for how many layers?"}],"sources":[{"title":"chrishayuk/q-lm, docs/results-qlm-semantic-001.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-qlm-semantic-001.md","note":"The semantic worlds, and what the learners do on them."},{"title":"chrishayuk/q-lm, docs/results-larql-qlm-sem-001-v2.md and docs/results-larql-qlm-sem-001-v3.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-sem-001-v3.md","note":"Answer states, the entity at its own position, the relation swap and the recombined query, against docs/larql-qlm-sem-001-plan.md and its three amendments."},{"title":"chrishayuk/q-lm, docs/results-larql-qlm-transport-001.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-transport-001.md","note":"The attention steps and heads that carry the entity, with heads chosen on held-out pairs."},{"title":"chrishayuk/q-lm, docs/results-larql-qlm-enrich-001.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-enrich-001.md","note":"The enrichment test that failed, and the follow-up at the answer position."},{"title":"chrishayuk/q-lm, docs/results-larql-qlm-resolve-001.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-resolve-001.md","note":"Where the answer forms, and the fact edited from an external table, confirmed on worlds 4 to 6."},{"title":"chrishayuk/q-lm, docs/results-larql-qlm-external-001.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-external-001.md","note":"A provider that reads the entity and relation from activations, against its plan, confirmed on worlds 4 to 6."},{"title":"chrishayuk/larql","url":"https://github.com/chrishayuk/larql","note":"The series these experiments are named for; for Llama, its per-layer states were checked against PyTorch’s in GROUP-001."},{"title":"M. Geva et al., “Dissecting recall of factual associations”, 2023","note":"The subject-enrichment account tested by ENRICH-001, as the repository cites it."}],"published":"2026-11-27"},"hash":"f65141ee3f87505c724c9d6ab0549f25397ea19aef68904cea10ae0eb3ce1d86","algorithm":"sha256","provenance":{"id":"N-Q-LM-TRANSPLANT","version":"1.0","recordHash":"f65141ee3f87505c724c9d6ab0549f25397ea19aef68904cea10ae0eb3ce1d86","revision":{"kind":"initial","summary":"First publication, after an independent fact-check against the repository's results documents and plans"},"sources":[{"title":"chrishayuk/q-lm, docs/results-qlm-semantic-001.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-qlm-semantic-001.md","note":"The semantic worlds, and what the learners do on them."},{"title":"chrishayuk/q-lm, docs/results-larql-qlm-sem-001-v2.md and docs/results-larql-qlm-sem-001-v3.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-sem-001-v3.md","note":"Answer states, the entity at its own position, the relation swap and the recombined query, against docs/larql-qlm-sem-001-plan.md and its three amendments."},{"title":"chrishayuk/q-lm, docs/results-larql-qlm-transport-001.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-transport-001.md","note":"The attention steps and heads that carry the entity, with heads chosen on held-out pairs."},{"title":"chrishayuk/q-lm, docs/results-larql-qlm-enrich-001.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-enrich-001.md","note":"The enrichment test that failed, and the follow-up at the answer position."},{"title":"chrishayuk/q-lm, docs/results-larql-qlm-resolve-001.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-resolve-001.md","note":"Where the answer forms, and the fact edited from an external table, confirmed on worlds 4 to 6."},{"title":"chrishayuk/q-lm, docs/results-larql-qlm-external-001.md","url":"https://github.com/chrishayuk/q-lm/blob/main/docs/results-larql-qlm-external-001.md","note":"A provider that reads the entity and relation from activations, against its plan, confirmed on worlds 4 to 6."},{"title":"chrishayuk/larql","url":"https://github.com/chrishayuk/larql","note":"The series these experiments are named for; for Llama, its per-layer states were checked against PyTorch’s in GROUP-001."},{"title":"M. Geva et al., “Dissecting recall of factual associations”, 2023","note":"The subject-enrichment account tested by ENRICH-001, as the repository cites it."}]}}