Skip to content
19 - Mechanistic Interpretability with Neel Nanda episode artwork

Feb 4, 2023 3 hr 52 min

19 - Mechanistic Interpretability with Neel Nanda

from AXRP - the AI X-risk Research Podcast

How good are we at understanding the internal computation of advanced machine learning models, and do we have a hope at getting better? In this episode, Neel Nanda talks about the sub-field of mechanistic interpretability research, as well as papers he's contributed to that explore the basics of transformer circuits, induction heads, and grokking. Topics we discuss, and timestamps: - 00:01:05 - What is mechanistic interpretability? - 00:24:16 - Types of AI cognition - 00:54:27 - Automating mechanistic interpretability - 01:11:57 - Summarizing the papers - 01:24:43 - 'A Mathematical Framework for Transformer Circuits' - 01:39:31 - How attention works - 01:49:26 - Composing attention heads - 01:59:42 - Induction heads - 02:11:05 - 'In-context Learning and Induction Heads' - 02:12:55 - The multiplicity of induction heads - 02:30:10 - Lines of evidence - 02:38:47 - Evolution in loss-space - 02:46:19 - Mysteries of in-context learning - 02:50:57 - 'Progress measures for grokking via mechanistic interpretability' - 02:50:57 - How neural nets learn modular addition - 03:11:37 - The suddenness of grokking - 03:34:16 - Relation to other research - 03:43:57 - Could mechanistic interpretability possibly work? - 03:49:28 - Following Neel's research The transcript: axrp.net/episode/2023/02/04/episode-19-mechanistic-interpretability-neel-nanda.html Links to Neel's things: - Neel on Twitter: twitter.com/NeelNanda5 - Neel on the Alignment Forum: alignmentforum.org/users/neel-nanda-1 - Neel's mechanistic interpretability blog: neelnanda.io/mechanistic-interpretability - TransformerLens: github.com/neelnanda-io/TransformerLens - Concrete Steps to Get Started in Transformer Mechanistic Interpretability: alignmentforum.org/posts/9ezkEb9oGvEi6WoB3/concrete-steps-to-get-started-in-transformer-mechanistic - Neel on YouTube: youtube.com/@neelnanda2469 - 200 Concrete Open Problems in Mechanistic Interpretability: alignmentforum.org/s/yivyHaCAmMJ3CqSyj - Comprehesive mechanistic interpretability explainer: dynalist.io/d/n2ZWtnoYHrU1s4vnFSAQ519J Writings we discuss: - A Mathematical Framework for Transformer Circuits: transformer-circuits.pub/2021/framework/index.html - In-context Learning and Induction Heads: transformer-circuits.pub/2022/in-context-learning-and-induction-heads/index.html - Progress measures for grokking via mechanistic interpretability: arxiv.org/abs/2301.05217 - Hungry Hungry Hippos: Towards Language Modeling with State Space Models (referred to in this episode as the "S4 paper"): arxiv.org/abs/2212.14052 - interpreting GPT: the logit lens: lesswrong.com/posts/AcKRB8wDpdaN6v6ru/interpreting-gpt-the-logit-lens - Locating and Editing Factual Associations in GPT (aka the ROME paper): arxiv.org/abs/2202.05262 - Human-level play in the game of Diplomacy by combining language models with strategic reasoning: science.org/doi/10.1126/science.ade9097 - Causal Scrubbing: alignmentforum.org/s/h95ayYYwMebGEYN5y/p/JvZhhzycHu2Yd57RN - An Interpretability Illusion for BERT: arxiv.org/abs/2104.07143 - Interpretability in the Wild: a Circuit for Indirect Object Identification in GPT-2 small: arxiv.org/abs/2211.00593 - Grokking: Generalization Beyond Overfitting on Small Algorithmic Datasets: arxiv.org/abs/2201.02177 - The Effects of Reward Misspecification: Mapping and Mitigating Misaligned Models: arxiv.org/abs/2201.03544 - Collaboration & Credit Principles: colah.github.io/posts/2019-05-Collaboration - Transformer Feed-Forward Layers Are Key-Value Memories: arxiv.org/abs/2012.14913 - Multi-Component Learning and S-Curves: alignmentforum.org/posts/RKDQCB6smLWgs2Mhr/multi-component-learning-and-s-curves - The Lottery Ticket Hypothesis: Finding Sparse, Trainable Neural Networks: arxiv.org/abs/1803.03635 - Linear Mode Connectivity and the Lottery Ticket Hypothesis: proceedings.mlr.press/v119/frankle20a

Episode details come from the podcast's RSS feed.

Embed this episode

Ready to play

19 - Mechanistic Interpretability with Neel Nanda

0:00 3:52:47
of matches

Transcript Auto-generated, may contain errors

Hello everybody, in this episode I'll be speaking with Neil Nanda. I'm graduating from Cambridge, near the variety of research internships, including one with me, the board joining and the product where he worked with Chris Ola on the Transformer Circuit's agenda. As we record this, he's pursuing independent research and producing resources to help build the field of mechanistic interpretability, but around when this episode will likely be released, he'll be joining the language model interpretability team at DeepMind. In this episode, we'll be talking about his mechanistic interpretability research, and in particular, the paper is a mathematical framework for a Transformer Circuit's, in context learning and induction heads, and progress measures regarding bi-magnetic interpretability.

Thanks to what we're discussing, you can check the description of this episode, and you can read the transcripts at AFSRB.net. First of all, is it right to say that you understand yourself as a mechanistic interpretability researcher? Yeah, the reactor. So what is this mechanistic interpretability thing?

Sure, so this is an annoyingly fuzzy question. The starting point I go with is with an analogy to reverse engineering a compiled program binary to its source code. General networks are this thing that emerges from weird processes like a SCASIC-RINY descent that's learned a bunch of parameters that let it do a task constantly. We have no idea how it works, and I want to be able to understand what it has actually learned and why it does what it does, but I'm holding myself to the extremely high standard of I want to actually understand what the internal cognition of the system is.

What are the algorithms running such that it takes the inputs, produces a series of intermediate things, and then produces a legible output? Okay, it's not like that was potentially a mix of neural network emerges from training. One thing you could be trying to understand is what algorithms encoded in that final neural network, what's the quote-unquote cognition going on in it? Another thing that you were maybe hinting at was during the training of the neural network, there's maybe some reason that some parts of this final network got emerged as the thing that would go into the network at the end of training.

How much of this is about what's happening in the final network versus what was incentivized during training and how that story all went? To a first order, it's entirely about looking at the final network. To me, the core goal of the field is to be able to look at a final network and be really good at understanding what it does and why. I think that this does pretty naturally lead to being able to look at a thing during training.

My growing work, which I hope you'll each have about, is a pretty good example of this, where I tried really hard on the network at the end of training, and then what happened during training just fell out. I think a bunch of the more ambitious ways to apply mechanistic accountability is by influencing training dynamics. To me, I see the core of the field is can we take a single model checkpoint and understand it, even if this takes a lot of time and a lot of effort. I think that is feedback with training dynamics.

I also think looking at during training might be necessary to explain some things like weird vestigial organs that were useful early in training but are superseded by some later algorithm which are not going to need it but still stick around. Do you actually see that in practice? I'm not aware of a concrete example of seeing that. I would be very surprised if it doesn't happen.

All right, so now that we know what you mean by this mechanistic accountability thing, why you do it? What's the point? So, on a purely personal level, it's just really fun and that actually does carry quite a little bit of me. I also think it's actually very important.

So, at a high level, I think we're living in a world where we're going to get computer programs that are human level intelligent or beyond that are doing things and that it's forcibly going to be pretty hard to tell whether these things are doing things because they're actually aligned or because they're learned to be deceptive or to exploit force of the training process or just actually trying to be aligned with mislearned things. I would really prefer to live in a world where we actually understand these things. I think that mechanistic interpolity is not obviously the only path we get to a point where we can make some claim to understand systems but I think it's a promising path that to me achieves a pretty high level of rigor and reliability and understanding. I also think that your networks are a really complex system and it's really hard to make progress on the complex system without any grounding of something you actually understand that you can build off of.

And I just think that lots of things we're confused about in networks, whether just in ML as a whole, in alignment, anything you might care about, I expect it will get easier the more we can claim that we actually understand what's going on inside these models. Sure. I also think it's kind of scientifically fascinating. Yeah, yeah.

I wonder, like, so there's this kind of definite vision of like, okay, we want to do mechanistic interpolity because at some point we're going to train a model and we're going to want to know a whole bunch of facts about the cognition of that model in order for us to evaluate. Do we think it's good? Do we want to release it? And there's this other broad story of like, well, you know, we don't really know how things work if we like understood the what was happening, this would like help us get better abstractions, we'd help us understand the science of people learning and then we'd just be in a better place generally.

I'm wondering how much weight do you put on those two stories? Sorry, can you get the question? So there are two stories of why mechanistic interpolity could be useful. One is you want to do it so that you develop these mechanistic interpolity ability tools and the way you want to know whether it's like the good model or bad model in terms of how it's thinking about stuff.

And so use mechanistic interpolity to understand its cognition. Story two is like, look, we just have mechanistic interpolity lying around so that just in general when we do deep learning, we want to know what's going on and we can say, ah, well, because we've done so much mechanistic interpolity in general, you know that there's these like swivels that always happen in neural networks. And like, probably this weird thing about your loss going down is due to swivel formation and you know, you need to like tweak it to drive out the swivels or something. So there's one story where it's like, ah, you know, we need to use it for this thing.

There's another story where you're like, okay, if I want to understand how, like, I don't know what this, what value of swivel is going to be important, but I know that like, we're eventually going to have to do good science of deep learning and vector interpretability is the way to do that. So these are two ways that mechanistic interpolity can be valuable. I'm wondering if you have a sense of like, your head is one of these stories, like way more compelling than the other, or like a little bit more compelling, or do you think like, no, these are like two basically equally good reasons. Yeah, I would say that the taker system and figure out whether it's doing good things or bad things is somewhat more compelling to me.

But it's a somewhat messy question and I want to try to disentangle a couple of things here. The first is, what do I think is actually going to push on reducing x risk, where being able to take a specific system and ask questions around, is this doing good things or bad things feels more, well, quite a bit more important to me than answering general science of deep learning mysteries, because I think it's not obvious to me that getting good at science of deep learning is actually that's good for x risk. Yeah, and I wouldn't surprise me if it's not bad. I also kind of think about theories of change in the way I see a lot of mechanistic interpretability work at the moment is we are just trying to figure out the basic rules of networks and how they work and what kind of things seem to form and just like, what are we even doing?

And I think that it can be a mistake to be too goal directed when trying to do basic science. And I expect that lots of things that get done will turn out to be useful and interesting in lots of unexpected ways for future things people want to do. And I also think that just if we actually get good at interpreting systems, this seems like it should be really useful in loads of different areas in a bunch of ways I can't really put it. The final clarification would be that I generally think about goals of mechanistic interpretability as kind of having a sliding scale of difficulty in terms of at which point we could take a single system and spend two years of time and a ton of researcher and like less skilled worker efforts trying really hard to notice lack of limit in it.

I'm like, that's reasonably useful, not incredibly useful. Like I feel reasonably good about that. Then there's a world we could have the ability to take a system and like a day come up with a reasonable idea of if it's acceptable or not, this seems more useful as well as we could turn these into kind of automated robustness checks that we could give to our limit researchers so they can validate their techniques. There's things where we can actually insert some metrics into training and like you do cleaning updates on those.

There are cultural effects where if we could credibly say to every lab making an HCI, here's a pro to a GI that was made and is clearly deceptive in this really subtle and hard to see way that we can identify with this tool. Maybe you should be careful and take a limit or seriously. And it seems like there's depending on how well we succeed, there's a sliding scale of how useful this all could be. Yeah, that seems reasonable.

I guess it's sort of related to some of that. I think one reaction you could have to some of this mechanistic durability work is like, oh, or suppose you're really worried about extencialers from AI. Like some people I know think like, oh, if we just do more AI research, the standard default way is going, maybe we're just old and die. I think from that perspective, there's some worry of like, hmm, all these mechanistic durability papers that get published and that help the world understand how deep learning is actually working and what's actually going on.

Like, maybe that's kind of helping AI get generically better even more than it's helping any alignment specific stuff. What do you think of that concern and how much maybe like what your threshold, what do you think the threshold should be for like just not publishing mechanistic interpretability work? Yeah. So I think this is a pretty valid concern.

And it is definitely by far my strongest guess for ways my actions could turn out to be negative on the world. And I don't know if I have like a confident and satisfying answer to this question. I definitely think that if the ambitious claims I'm making that we could actually get to point will be understand networks in any meaningful sense are true, then this should clearly be useful for making them better. I think it's very plausible.

We don't get good enough of that to like really matter for improving models, but potentially get good enough at it to like help with auditing a system or help understanding how to learn it. I also think it's perfectly plausible things are the other way around. I partially just have a broad heuristic that it seems just obviously the case that a world where we actually have some insight into these weird black box systems is a world where they will be easier to align and we will be safer. But I don't really know how to form careful principle answers to these questions.

One example that maybe make me feel a bit more a bit more on the concern side is so on the topic we have this induction heads paper that we can talk about a bit later. And there was this recent paper called S4 that tried to introduce a new architecture based somewhat on LSTMs that was better at tracking long range of penises was trying to compete with the transformer. And a thing that was a significant part of the paper was comparing them to induction heads, which are one of the most transformers track long range penises. And it sounded like induction heads and white and slide this architecture.

And I don't know if S4 is actually good or the kind of thing such in a matter, but like ah, it is plausible in a world where there was a important insight that was inspired by some mechanism and accessibility work. And like ah, that'd be great. In terms of my takes on work that I think should versus shouldn't be published, I generally think that anything which is deeply tied to something that could help us make frontier models like palm better. I'm very, very concerned about and like things which are kind of looking directly at this models, noticing things that offer them and trying to fix them.

I'm more relaxed about things that are kind of looking at smaller language models, things that are kind of explaining specific circuits or giving better techniques and frameworks for doing this or things that are more like general insights into deep learning that are specific to like the frontier models where my intuition here is something like actually understanding the systems, actually understanding what the hell is going on in deep learning. Does hell count? I think you're allowed to say hell. Yes.

So my guess is that something that's more about understanding deep learning generally is safer than something that's kind of very focused on debugging large language models because my guess is basically just that understanding what's going on in deep learning seems like it should just be useful in both directions pretty broadly while understanding specific details of things they run in large language models seems much more useful in the frontier of making it better. But I'm just pretty confused by a lot of these questions. Sure. A related question which you might be confused by.

One thing I kind of wonder is like, suppose we do this kind of mechanistic and curability work largely on like a nice model or models where it's slightly easier or models that exist today which are probably somehow qualitatively different from like super from future super crazy models. How scale invariant do you think we should think of the insights as being? Like you could imagine like, you know, there are all these things that are true of like these one layer transformers aren't true of, you know, GPN or like there are things that are true before you figure out like the meaning of life and then once you figure out the meaning of life like all your circuits change. So I'm sure we shocked to hear but I'm also confused about this one.

So in part, I think this is just an empirical question that we don't currently have a time of data on. The main data is the induction heads paper which we'll talk about a bit later. Yeah, but we found this simple circuit in two layer potentially models and then found out that this was a really big deal of those models but also a really big deal and actually occurs in every transformer we've looked at up to about 13 billion parameters and yeah, for context how many parameters are in something like, I know the chat GPT model that people can interact with on their browsers. So we don't actually know if a chat GPT because opening eyes in public about this, but GPT 3 is 175 billion.

Okay. So 13 billion is like about one order of magnitude less than yes, something that's maybe same as the art. Yes. I built council that I think parameters are somewhat over rated as a way of gauging model capability.

The shindebinds tinshell of paper, the main interesting results was that everyone was taking models that were too big and training them on too little data and they made up 70 billion parameters a model that was about as good as Google brains palm which is 600 billion but with notably less compute. Okay. But this might be something has. So really, that actually brings up something I wanted to ask about.

So something that I see as somewhat analogous to mechanistic interpretability is work on scaling laws. So I think the first work, correct me if I'm wrong, but I think the first scaling was work was by Daniel Hernandez and some collaborators at OpenAI. I don't believe Danny was an author on the paper. Oh, he wasn't.

Let me just check. So I'm not not Jared Kaplan, Sam McCandlish. I believe the two lead authors. Oh, I think I'm thinking of another thing.

He was an author on a transfer a scaling laws for transfer learning paper that came out later on. Okay. But so I think that like a lot of the initial scaling was work was buying like perhaps the more line and drag experts for just part of OpenAI. But I kind of see it as like on the one hand of the time to understand like what's going on with the learning, like how's it happening in a sort of similar vein or not the same as interpretability.

I also think that it's ended up as like, you know, primarily used to like help the wider world train models better. So I'm wondering firstly, do you think like that's good analogy? And secondly, do you think it's a concerning analogy? So I'm going to weakly argue that it's a bad analogy.

Okay. I think it's pretty plausible that the scaling laws work has been fairly net negative and has been used a lot by people just trying to push the frontier of capabilities. Though I don't have great insight into these questions. I think that to me, scaling laws don't feel like they get me any closer to a question around is this model aligned or not?

I don't feel like I understand anything about the models in tunnels. I feel like it could I feel like it plausibly helps me forecast things. And I do think that forecasting things is important, but it feels important in a very different way to where I think mechanistic interpretability is important. I guess I will also note that my best story about the scaling law is that it doesn't make the path from here to AGI was a lot smoother and more continuous.

So we're better prepared and can do better along the way, rather than someone just eventually realizing, oh wait, turns out that I already had all the computer, I take a big AGI and on that front, I think that is a thing that is useful. Yeah, to me, it's going to almost feel like the kind of statistical physics, what happens when we get lots and lots of parameters and average out lots of tiny interactions into some big smooth power and some mechanistic interpretability feels much more like. Let's zoom in and try to really understand the details of what's going on rather than zooming out so much that a lot of the details have struck the way. Okay, would it be right to understand your position as like scaling laws is like less useful for AI experts, production or AI alignment than mechanistic interpretability might be, but maybe they're like similarly useful for just building AI in general.

Or do you think that scaling was was sort of notably more useful for building AI? I would predict that scaling laws were notably much more useful. Okay, so this is partially hard to really engage with because I'm sitting here knowing the key results of scaling laws and their practical implications. Yeah, not sitting here knowing the key results and mechanistic interpretability.

And if I came back to you tomorrow and was like, Oh, with this one weird trick, you can turn G3 into AGI and I found this by starting it as weights. I'd probably be like, ah, that is worse than scaling laws. Okay. I don't expect this to happen to be clear.

But yeah, I think the difference I would make is that if I'm a company trying to build an AGI and I hear about scaling laws that I'm like, Oh, that's so useful. I was going to say it so useful because I know kind of how to scale and like what my hype and some amount on how big my model should be and how much data I need to collect and how good I can expect it to be for the amount of compute on reflection. I actually think that the most important consequence was just this idea that scaling will continue to work and that we should just try really hard to make models bigger. And it's seeming less and less likely.

There's some magic point where everything breaks and you wasted a billion dollars. And that's kind of very tight. So, I think the two things here are forecasting versus understanding where forecasting seems more important to changing the actions of the people who make the AGI. Understanding seems more important for disentangling what's going on inside of it and how happy we are with that.

Yeah. Okay. So I guess I have a few questions about roughly like where you think mechanism interpretability is a field. One is intuitively I kind of think of there as being some spectrum where the low end of the spectrum is basic.

I don't know. Like I'm detecting edges or I'm noticing that like something is text rather than picture and then maybe a little bit higher level is like I noticed that it's all caps a bit higher level is I noticed that it's written English rather than French. And then like a very high level is something like reasoning where I'm like recalling, you know, how to do, I don't know, modus ponens or like in which situations mathematical induction is and like what a useful like inductive hypothesis might be in this case, you know, where it's something like perception versus reasoning is a spectrum. And if you think that like to the extent that language models can do things that are closer to reasoning as well as like basic, knowing what language their input is being written in, it seems like if we want to understand them, we're going to have to like understand this whole spectrum of cognitive abilities.

I'm wondering, so first, I guess like this, this understanding of there being one kind of spectrum is potentially contestable. So feel free to contest that if you want. But if you don't, I'm wondering like, sorry, spectrum being the kind of spectrum. Kind of sensory to reasoning.

Yeah, the kind of sensory to reasoning or, you know, sensory like cognitive algorithms or sensory bits of cognition to reasoning bits of cognition. Yeah, I'd actually argue there's three bits to the spectrum. There's sensory neurons at the start that take the raw input like pixels or tokens and convert them to the stochomod actually wants reasoning that does much processing. And then motor neurons, which converts the processing to the actual desired outputs.

Ah, yes, of course. I know you get neurons in language models that do fun things like. So what nappies or diapers if you're American is limited to two tokens, but conceptually the model clearly figures out. Oh, nappies is here.

And there's a retopilization neuron, which says, ah, this token is the N in nappies and the nappies feature is there. So I should output appies. Sure. Yeah.

So, so if I think of there as being these three types of abilities, maybe there's, maybe there points on a triangle where you can go around. How, how much of that triangle do you think mechanistic durability is good at? And do you think there are any regions of the triangle where it's going to have to like change tack or do something different? The simplistic answer I want to give is that we are good at the start and end and bad at the middle.

I'm not even sure how true this is in part because we're currently just kind of bad at everything. Okay. And in part because so the way I normally think about reverse engineering and network is you start with a thing that is interpretable and ideally two things that are interpretable and you try to figure out how the model's gone from one to the other. Or at least you just look nearby the one that is interpretable, but what's being done with it and try to move outputs?

Some sort of induction thing. Yeah. And nearly nothing to do with the induction induction and we just like obviously the input to the model is interpretable. The output of the model is interpretable.

You know exactly what these are. Interestingly in language models it's often been easier to understand things at the output than things near the input. So one important thing to bear in mind when thinking about language model and accessibility which is most likely to be talking about is that unlike classic neural networks or convolutional networks where the key thing is you've got layers of neurons, each layer's input is the output of the previous layer essentially and you can kind of think of it as iterative steps of processing. There are two big differences with the transformer.

The first is the idea of the residual stream and the second is the idea of attention heads. So the idea of a residual stream is the input, this is somewhat used as an image models. The idea is that the input to a layer is actually the accumulated output of all previous layers. And the output that layer just adds to this residual stream.

And in standard frameings of things like residual image networks, this is often framed as a skip connection around the layer that's like a random thing you add on but isn't super important. But I think the way transformers seem to work in practice is that every layer is kind of incrementally updating the central residual stream. One demonstration of this is that there's this technique called the logic lens where you just cut off the last several layers of the model and look at how good it does. If you just set those to zero and then convert this bit to tokens and turns out models are like a lot of the time kind of decent at this.

They're very simple models. And my interpretation, so the reason this matters is it means it's harder to think of the model in terms of early, middle and late because processing can just, so I normally think of the thing the model does is kind of having paths through from the inputs, wires and layers through the output. And these paths to tend to end a long time in the residual stream, which makes it harder to reason cleanly about things. So that's the residual stream.

The second messy thing to bear in mind is attention. So transformers are fundamentally sequence modeling networks. Their input is a sequence of tokens, which you can basically think of as words or subwords. And at each step, they're doing the same processing in parallel for every element of sequence.

There's a separate residual stream for each token position. And it's using the same parameters in parallel. And the main thing that so obviously, and you can move information between positions because we don't want it to be a function of only the current token. And the way it does this is with the attention lines that are made up of several attention heads.

And each head, it has some parameters devoted to figuring out which other positions are the sequence that are relevant to the current token. And it's got a separate set of parameters that says, once I figure out which bits are most relevant, what information from that position with the total stream should I move to the current token? And the reason this matters is that it means that a decent chunk of the transformers computation comes down to rooting information between different positions, figuring out what information to root. And this means that in practice, a decent chunk of what we've got out in transformers is understanding this information rooting and how it works.

And some of the things you've understood, it's not obvious to me whether you should even consider this kind of sensory or reasoning stuff. It's just like the model takes the raw input, does some creative thinking where it figures out which tokens are most relevant to the output on a specific token, and then it learns to root information from there to the end. But that wants to figure out which token is relevant to getting the answers kind of easy. For example, it's trying to figure out what the number at the start of a line is, and it learns to look at the number at the start of the previous line, and it's like the previous line began with five.

So this should be six. The hard part of the task is to figure out where the five is, or the fact that it's five. Once you figure that out, it's like, okay, very easy task. Okay.

So it sounds like what you're saying is like, because of the way transformers work, it's not obvious that you can divide cognition into purely sensory, purely reasoning, purely murder, or like, oh, I might not just be the best breakdown. Kind of. I do think that tracks something real about transformers. In part, what I'm saying is just, I think that sensory reasoning in motor is a good description of what the neurons in the model are doing, but it also spends a significant amount of its computation on attention, which is, yeah, I generally break down what a transformer does into these two separate components, one of which is rooting the most relevant information between positions and sequence, and the other one of which is processing the information what's been brought there.

Okay. So the most important information can be rooted around like several times. For example, there was this great work by David Bound Kevin Meng in the Rome paper, looking at how models did factual recall, like in a sentence, like the Eiffel Tower is located in the city of in upwards Paris. They found reasonably suggestive evidence that the model first roots the separate tokens of the phrase the Eiffel Tower to the final token.

It then realizes this is the Eiffel Tower and looks up the fact that it's in Paris, and that gets rooted to the final of token in order to predict the Paris context. Okay. And how does it look up that the Eiffel Tower is located in Paris? So this is a great question to which the answer is my prediction of what's happening is that the model has, so transformed it up, you know, no X in general seem to represent features, that is things they have computed about the input as directions in space, and where they can look up whether a feature is there by projecting onto that direction.

And my prediction is that so Eiffel Tower gets tokenized as capital E, IFF, EL, and Tower. And I predict that the model is taking the model has attention, but moves the Eiffel features of the tower token. And then there are some neurons which say if tokens three back is E, tokens two back as if, token one back as L and current tokens tower, then output Paris feature. And then heads later than at work move the is Paris feature to the city of token, the of token.

Another important thing to know about transformers, which you might not be aware of is the way models like D3 are trained is there just given a great deal of text, just like from the internet sort of books or whatever, and the text is split up into tokens. And these are trained, the model is trained to predict the next token. And the way the attention is set up, information can only move forward in the sequence, not backwards. So for each position of the sequence, the model is trying to predict the token after that.

And it's value of that position sequence can only be a function of that token in earlier terms. Okay. All right. So moving back, sorry, going up a little bit, I guess I kind of want to ask, how do you characterize like the kind of thing or the kinds of cognition that mechanistic interpreter currently has a good grasp of?

And do you see any walls towards like, Oh, if we want to do this kind of cognition, like we're going to have to think differently. So honestly, to me, it feels somewhat more tied to how things are mechanistically represented in the network than it does to exactly what the cognition is. Okay. So a lot of the mental moves that I'm making when I'm trying to reverse into the network are around discovering things that things are localized within the model, that there are some heads or some neurons or at least some directions in space that represent the key feature for this problem.

And that most other things do not matter for this input and can be safely ignored. And the next thing that matters could be computed solely from the heads or neurons that I identified earlier that are important. One thing you need to be able to do here is to break down the model's internal representations of things into kind of independently understandable units, like an attention head or a neuron being the classic thing we want to do here. And if computation is kind of localized in this way, then our life is much, much easier.

And if it is not localized, then we are much less good at this. There's this core problem called superposition, which probably not going to talk about that much later, but in brief, models want to represent features as directions in space. And when they have transformers have these MLP layers where there's a linear map followed by a activation function called a Jell-U, where you take each element in the vector and apply this weird function that's basically a smooth, outrelu to it. And then you have a linear map back to the residual stream.

And so we expect the MLPs are being used to process information, which means being used to compute some features. We expect the features are going to be represented as directions in space. And the space being like the kind of vector space that's spanned by like these neurons, right? Yes.

What we think about it is just the middle bit of the MLP layer is just a list of say 4000 neurons, and each neuron has a scale, has like a value. And you can also think about this as a vector in 4000 dimensional space. And we kind of really hope that the model is using these neurons to represent the features that the directions the features correspond to are aligned with like one feature per neuron. And this often seems to be the case in image models.

And the main reason you might think would be the case is that, so models internally seem to care a lot about computing features of the input, things like this token is a verb, or this is a proper noun that appears in a European capital or things like that. And we expect that models want to reason about these independently. And if you have a feature per neuron, you can reason about this independently, because the relu or the jelly or acts of each neuron independently. But this also forces the model to only have as many features as it has in neurons.

And models do the thing called superposition, which you can essentially think of them, think of as them simulating a much larger and sparse model, where they have many more features than they have neurons and kind of squash them in in a way that has a bunch of interference and messiness, but which lets them represent a bunch of features. And this does seem to happen in transformers of a bunch, it's really annoying. And it's plausible to me that there's just some cognition that happens with aligned with neurons and some that happens that's not aligned with neurons. And there may not be that big a difference in this cognition, but one is currently much harder to interpret than the one without superposition.

The final answer to the question is we're just much better at interpreting the cognition around attention heads that we are about neurons. And again, attention heads are the bit of the model that's to do with rooting information between the different token positions. And in part because this is just much more legible, you can literally look at the attention patterns in the model. And it's very easy, sorry, attention pattern being which previous positions does the head think is most relevant to the current position?

It's very easy to like be misled by these, but it does give you quite a lot of information. Sorry, why is it easy to be misled? So mechanistically, what an attention head is doing? Is it's taking a token, each token position, which I call the destination token, it's looking over all possible previous tokens, including the current token, that's called these source tokens, and identifying some weighted, assigning weights to each of them, such as weights all out to one, though this is naturally an important detail.

And then copying information from each of the residual streams of those token positions to the current thing. And importantly, copying the information at the residual stream after layer, I don't know, after layer 10, can potentially have basically nothing to do with the actual token inputs. So that position at layer zero. But if you know you look at an attention pattern, you'll be like, ah, it's learning about this token with maybe some contextual information.

But it's possible. Yeah, it's possible it's entirely picking up on stuff that was brought in by previous attention heads. Yeah, yeah. And there's some suggestive evidence that models sometimes use kind of really, really easy tokens as spare storage and stuff like that.

Or another thing is attention patterns need to add up to one for boring reasons, and sometimes the head wants to be off, and it will attend to the first token to be off. Anyway, look at this, you're like, ah, I gave it the sentence, the cat set on the mat, and only his head's really care about the token. That was super meaningful. And it's like, no.

Okay. So a few follow up questions before moving on a little bit. Way back, we said that one difference that language models had compared to these image classification networks is that there's a single the logic lens where you could like take the transformation that you were eventually going to do on the residual stream at the end of the network to get out these logits, which are basically probabilities of various options for the next token. And you can kind of apply that like in the middle of the network, and you can see that it was sort of getting this representation of a decent guess at the answer.

It strikes me that you could try doing the same thing in image models, right? Has somebody tried that and found that it doesn't work? So your knowledge? I am not aware of anyone trying this.

One thing I will note is that having the input format to be the same is very important. And the way that I believe image models, even those with a residual stream tends to work, is they take the input image, which is big, and then kind of progressively scale it down with these pooling layers. And then at the end, they just totally flatten out what they've got. And maybe have another couple of fully connected layers before producing an output.

And if the shape of the output is not the same as the thing, if the shape of an intermediate activation is not the same as the thing that is then unembed, but like mapped to the class outputs, this will just, the technique just doesn't even work in principle. Oh, why not? So, oh, sorry. So the native technique of you just delete these layers doesn't work because...

Oh, because the layers are changing the number of dimensions in the residual stream. Yeah, exactly. And in a transformer, the residual stream is this consistent object the entire way through the network that these things incrementally updating. There are a bunch of image models that I think do have something more like a residual stream, in particular vision transformers, all the rage, and there are a bunch of more image architectures.

I'm not aware of anyone doing this. I would predict it would kind of work. A further caveat is that a thing you could try is by training another linear map on the earlier activation with different shape, like class probabilities. And this is the kind of thing I'm sure some of has tried.

Yeah. So, the way it normally works is you have some convolutional layers and then you flatten it out or project down to some vector, something that your NLP multi-layer perceptron layer is connected on. And you can imagine just like deleting some of the convolutional layers, right? So instead of it just being a simple matrix, it's your NLP layers doing the un-embedding or the getting to the class probabilities.

Okay. All right. That's attention. The final follow-up before I go to a second follow-up of the thing I said maybe half an hour ago is, when we were talking about these types of cognition in these language models, right, the place you started off was like, okay, you want to have this sandwich where the pieces of bread are like things you understand, the feeling is things you don't yet understand, but you can kind of infer it from the things outside.

And you mentioned like the very output of these language models was understandable basically. And I'm wondering, so I think this is roughly right in cases where like, I don't know, you're doing something like right, like a typical person would write and that's what the language model is trying to do. You could imagine like language models that are used for playing diplomacy or whatever, like maybe the things that are being output, like it's saying, hey, please invade German, sorry, diplomacy is like this board game where you like make allies and set people in the back and like, you know, fight wars in Europe basically. And in diplomacy you send messages to people like, hey, I'm definitely not going to invade you, do you want to team up on invading Germany instead?

And like the meaning of that might not be so obvious, right? So I'm wondering like, yeah, how understandable do you think these like language model outputs are? Sure. So first off, to clarify, when I say the output is understandable, I literally mean when the model says, hey, that's going to be Germany, it is outputting the words, hey, let's go Germany.

And just like, this is actually like a significant upgrade overlooking the middle of a transformer, where I just, what does this mean, man? Yeah, he's like tens of numbers and you don't know what the 8.7 means. Yes, just you just have nowhere to get started unless you can ground in something that matters. Sure.

And yeah, even if the model was outputting seemingly random Jewish, the fact that I can say things like, hmm, it says, flergal rather than blub, why is the flergal logic higher than the blubble logic? Let's go look at what's happening nearby and see if I can get some traction there. That's like a real thing that we can do. In the particular case over the diplomacy playing agents, I would predict that I would predict that the diplomacy playing agent is outputting things like let's go and make Germany because it has some internal representation of what the person that's talking to you wants, what the agent wants, and how to manipulate the person that's talking to you to achieve this.

Yeah. Sorry about that paper's terrifying. Yeah. Right.

I had a fair audience might not be terrified. What was so scary about that paper? So they trained this model to play diplomacy, this game which is about you have a bunch of players and they form a shifting of lenses and sometimes stab each other in the back. And you need to convince other players to go along with your plans so you can win out if everyone else and the model they trained, despite that we had marked in claims that it was honest and cooperative player.

Yeah. It recently lies and manipulates to people successfully in a way that gets them to do what it wants and help it with the game. And I'm like, no, this is the thing I'm most scared about. Hey, I learning how to do.

Yeah. I think they're defense. They're using a definition of lie where as I found side felt it's not a lie if you believe it temporarily, even if you can make sure that you won't believe it later. Yeah.

It's a good thing. We don't have world champions if the point I'm seeing really, really relevant to how AI turns out. That might be mean. But I think something that is worth, there's something like worth emphasizing here, which is that if the model says let's go and be Germany, man, it's like, if you were just doing some black box analysis, it might be really hard to get any traction here because the model is lying.

It's saying things that seem perfectly reasonable, but are not striking what it believes. But if you are aiming for the very ambitious goal of actually understanding its cognition behind what it said, then it's like a very different question. And if you want to be able to credibly claim to have understood it, then you kind of must have been able to notice why it did and what the hidden things behind this were. Such that I think saying it's output is not interpretable is kind of a category error in some sense.

Even like its output, even its category error in the sense that, look, its output is understandable somehow and you could understand why I did what I did. Yeah, I'm just kind of unconvinced. There is such a thing as an uninterval output because that should always be a reason the model output is. But you could say the same thing about any activation or anything happening inside an network, right?

There's some reason that it's that way. That's a fair point. I think the thing that I'm pointing out here is something closer to what optimization pressure is placed upon the model where it's never optimized to have any specific activation, any specific thing that it is optimized to have the logic corresponding to the Daniel token be actually related to the Daniel token. Yeah, yeah.

So you somehow know that it's at least being graded on the output. So somehow the outputs are going to be related to it getting high grades in the cases where it was tested. Yes. Yeah, that seems fair.

Okay. I guess my ultimate question about mechanistic interpretability generally is the very start you alluded to this idea that one thing you could do is like, okay, we have a lot of tools such that if you have some neural network, a bunch of humans can spend two years trying to understand what's going on and succeed. But there's this different possibility you mentioned of like, can we somehow automate this? Like, can we get like, you know, progress measures or can we get like, you know, analysis tools that can just like take our take our neural nets and like, tell us what we would have concluded if we thought about it really hard.

I'm wondering, yeah, how one thing to add to that is I think there's a broad spectrum of automation from like, have it metric, have like a tool that's kind of doing what we would have done anyway, to actually being able to have an AI system to give them more and more of the actual cognitive work and judgment calls and future machines. And a lot of my optimism for a while that we might be able to actually have fully reverse engineered and then so what's going on in a frontier model like GPT five is, I expect it's most likely to happen if we have systems that are more capable than the language model we have today, but maybe not quite a human level that can do a lot of the work for us, just because something being really labor intensive is much less of an issue when all jobs are automated, including arts. But that's very much an ambitious goal of the field. Another thing we need to take.

So how close do you think we are to automation at any level of the spectrum and like what do you see any promising avenues? So I actually recently wrote a post on open problems in mechanistic interpretability. I'm running a sequence on open problems, mechanistic interpretability. And I recently wrote the post on techniques and tooling.

So I actually have usually chrysalis on this. Where, yeah, so a couple of axes that I break down kind of techniques and approaches on, there's general versus specific. So general techniques are a broad toolkit that should work for many circuits, including ones we haven't identified yet. It's probably actually defined circuits.

So when I say circuit, what I mean is some sub part of a model's parameters and cognition that is doing some specific task, for example, I don't know, the Eiffel tower example, the bit of the model which takes the raw tokens, EFL tower, and which produces the this is an EFL tower feature would be an example of the circuit for induction heads as we'll discuss later. And yeah, so general techniques, broad toolkit that should work for many circuits. The logic lens I mentioned earlier is one example of this that in principle should work for every sequence. And then there's specific techniques which are focused on identifying a single type of circuit or a single circuit family.

One really done example is models often form previous token heads, which attend to the previous token. And surprise, it's really easy to identify these because you just get a bunch of inputs and you look at the average attention page, the previous token, and some heads are really, really high on this and they're obviously previous token heads. And this is an example of a technique that is trivial to automate. And you could just run on every head in any model.

I think I would actually love someone to do is just to write all of these dumb metrics for basic kinds of heads that make a wiki for like every hairs and a bunch of open source models. Just wouldn't be that hard, it would be a cool project. Yeah, the next axis is exploratory versus confirmatory. So exploratory techniques are like, I'm confused.

This model is doing something. What is going on? I want to get more data, I want to form hypotheses, I want to get some evidence for against my hypotheses, I just want to iterate a bunch. And this tends to be pretty subjective and involve a bunch of human judgments and can involve things like visualize a bunch of data and try to look for patterns in it, do some kind of dimensionality reduction, just generating a bunch of ad hoc ideas on the fly or just kind of quick and dirty tools with fast feedback loops that may rely heavily on human interpretation.

And then confirmatory techniques are things that let you take a circuit and say, I think this circuit is what's going on behind this behavior. I now want to go and rigorously test and verify or falsify this belief. Redwood research have this awesome new algorithm called causal scrubbing, which I think is an excellent, fairly automated confirmatory technique. Though, this is all a spectrum and they claim to me that causal scrubbing can also work because of exploratory technique because you just keep forming hypotheses and trying to verify them and sometimes see and sometimes tell you which way is they broke.

The final axis is rigorous versus suggestive where there's like techniques that I think really tell you something real and reliable about a network. One example I like a lot here is activation patching. So the idea behind activation patching is you have two inputs to a model which give two different analysis like the Eiffel towers in Paris and the Colosseums in Rome. You feed in the Colosseum input, but you save all of the activations from the Eiffel tower input and you pick one activation in the model and you edit it and replace it with the relevant activation from the Eiffel tower.

For example, you replace the residual stream on the final token at the first layer or something. And you do this for just every activation you think is interesting and you look for ones where this patch is enough to flip the answer from a room to Paris. And it turns out when you do this that most things don't matter, something's matter a ton and that just patching in a single activation can often be enough to significantly flip things. And so my answer is just like extremely good evidence of that thing I copy over is something real and it just contains the core information that differentiated the Eiffel tower from the Colosseum.

And a cool thing you find if you do this is it turns out that if you patch the activations on the arm of the token of the Colosseum then early on the final token of the Colosseum. If you patch in the thing from the Eiffel tower run early on the values on the final token of Colosseum, the ones that matter, everything else doesn't matter. And then there's a band of layers where it slowly moves to the final token and then the Colosseum stops matter at all and it's the final token of the sentence that matters. And this is not taking surprise.

It's very tricky. And then there's a bunch of techniques that are much more suggestive where it gives some evidence. I think it should be part of a talk it you use with heavy caution. One example of this is a really dumb technique, figuring out what a neuron does is you look at its max activating data set examples.

You just run it on a bunch of data and you look at the data that most excites the neuron. And sometimes when you do this, you just look at the text and you're like, okay, these top 10 texts are all about they're all recipes. And it activates really strongly on the word knife in carving knife. This is a carving knife in your arm.

Sure, sure. And there are like a bunch of ways this can be misleading. There's this great paper called the interpretability illusion that found that if you take butt and a neuron and butt and you give it a bunch of Wikipedia text, it looks like it's about dates and facts. If you get a bunch of other kinds of texts, it's about song lyrics and random stuff like that.

And the technique is much of limitations, but I think it's something real about the neuron. Okay. And the final access is how much things are kind of automatable and scalable versus super labor intensive and painstakingly staring at neurons and looking at weights. And that's like roughly how I break down the field of like how to think about techniques and tools.

Okay. So the main areas where I'm excited to see progress are I want us to get a lot better at finding circuits. This involves a lot of things, having good infrastructure. So you can just find the common things you do a bunch and do them really fast.

One of my side projects at the moment has been making this library called transformer lens that tries to be decent infrastructure for doing all of the things I want to do when I'm trying to reverse it into GPT to like cash, all in turn, like to patients, edit whatever activations I want, things like that. And there's understanding the tools we already have. Where do they break? What are the ways you might apply them and then actually shoot us off of the foot?

There was this really great paper from Redwood on indirect object edification where they found a circuit in GPT too small to solve this simple grammatical task of indirect object edification. A one wild thing they found is that there were these heads that mattered a lot. But if they are deleted to the head, just like deleted it, deleted it, set it to zero, then another head in the next layer took over and did that head's task for us. So the head was really important for this backup head meant that if you delete it to the head, it would look kind of unimportant.

Interesting. My personal guess. Sorry, how did they know that the head was important if like when you deleted it, a backup head took over. So the techniques they were using there, one of them was activation patching.

You like copy the head over and run on a different input. There's not a flip things. The other technique is because this head was at the end of the network, you can use this variant of the logit lens called direct to logit attribution, where the idea is that so the way you compute the logits from the network, the kind of essentially the log probabilities over the next tokens is you apply a linear map to the final residual stream. And this, the residual stream is the sum of the output of every layer of the network.

And you can break the output of a layer down into the sum of different components, like different heads. And so you can look at a head's impact on the logits by just applying this linear map to that head's output. And if you do this on the indirect identification task, you're like, oh, heads nine and layer nine massively boosts the correct token relative to the incorrect token. I guess this head masses.

And you delete it. And it's like, ah, the model's about as good. But if we look at these other heads, then one head, which used to be suppressing the correct output now does nothing. And there's not a head that wasn't doing much is now like way more insignificant.

And I don't expect this. That's a really useful insight. Yeah. Yeah.

Just kind of having a better talk. We both understand things, but also we have more techniques. Then having good gold standards of evidence. What does it?

This both looks like conceptual understanding of what does it even mean to a found a circuit, but it also looks like good tooling and infrastructure to like really verify that your hypothesis is correct. And like one of the most important skills you need if you want to do good to make it up research is just the ability to aggressively red team your results and look at all of the many flaws in them and just try really hard to break them. And one thing that's pretty hard, especially on a grow field is having it be the case that other researchers can produce results that you think and compare and just having success on the field and what does it even mean to identify the circuit? What are the standard tool that I should use to be really sure what I'm doing is correct.

Redwood's causal scrubbing work is the best I've seen here by far. That has like limitations and shortcomings and ways that multiple hypotheses could seem kind of the same, but not be. I think they're having a gauge with that hard knocks that could be completely wrong. Apologies are redwood in advance.

And yeah, then the final thing is just automation. Taking all of these things that we know how to do where I know what I would do if I wanted to spend a thousand hours or first century to do small and passing over as much as possible to code and trading at research time for GPU time. And at the moment we're like not even at the point where there's a lot of productive things like just get a Python code program to do, let alone stuff that I think I could reasonably hand off to something like DPT free. But this seems like a thing that is very important to try to make happen at some point and a thing that I just expect to actually become easier as to build my tools and we do more things.

Okay, cool. So I think this is this sort of overview of mechanistic interpretability as a whole or we see a view of it. If people are interested in like, like before we go to your work specifically, if people are interested in getting into the field, do you have any advice or resources for them? So actually one of my big side projects at the moment has been trying to make it easier to get into the field.

Because I was annoyed at how many things I had to learn for myself. And I recently written this post called Congrat Steps to Get Started in Mechanistic Interptibility that tries to just be a definitive point to get into the field and learn about things and tries to guide you through the prerequisite skills, how to learn more and how to get yourself to the point we're actually working on an open problem. Some accompanying things. I have this comprehensive mechanistic interpretability explainer where I decided I wanted to write down every concept I put people to know about mechanistic interpretability with a bunch of examples and contexts and intuitions and surrounding things around transformers and machine learning that I thought underrated.

I got carried away and it's 33,000 words. But people tell me that it's very insightful words to read. And it might be useful just to reference to look things up as we're talking in this interview. I also have the sequence that I mentioned called 200 Conquerefant Problems in Mechanism where I try to map out what I think are the big areas of open problems in the field, like how I think about them, why they matter, how I'd approach doing research there, and then list a bunch of problems attempting to rank them by difficulty and trying to aim for a thing that someone is excited about the field and is not going to be able to scale up, could pick one and maybe get some traction.

Okay, cool. Yeah, and we should have links to those in the description or if you're reading the transcripts, you just click on the words he said. All right, so before we dive into your, so we're going to talk about three papers you've helped write before we dive into those. I'm wondering if you can give an overview of like, perhaps as opposed to mechanistic interpretability as a whole, do you have a vision of like your particular line of research in it, on a somewhat higher level than just talking about the individual?

Like what did I contribute to the paper? Oh, no, like, like why does the paper exist? Yeah, what, like, if there were some field of mechanistic interpretability that these papers like comprise like, what does that some field? What's it trying to do?

Sure. Okay, so the three papers we want to discuss are mathematical framework for transformer circuits, which was this excellent work I was part of when I was working in anthropic and in context learning and induction heads, another paper I was involved in but I was not a topic and progress measures for rocking by mechanistic interpretability, which is this active independent research I did after leaving. I should give the general caveat that I was extremely involved in the rocking work and did quite a lot of the mainline research on my own and I feel well placed to authoritatively speak about this and claim much of the credit. I was somewhat involved in mathematical framework, but the my collaborators, Chris O'Lernell and Elharge and Catherine Olson did far more of the work I did, so I decided to write a large amount of the credit and I was even less involved in in contact learning and induction heads and Catherine Nelson, Chris and the rest of anthropic deserve a lot of credit there and I can say things about these papers that these are very much my takes.

Okay, and also I should thank the co-authors of my cracking work, Delorence Chan, Jess Smith, Tom Librand, Jacob Steinhott, who contributed much. General Epistemic, caveats and credit sharing out of the way. So mathematical framework is in my opinion, as far away the coolest paper I've ever been involved in. Okay, so the reason this paper exists fundamentally is that if you are trying to reverse engineer a network, you need to understand what the network is as a mechanistic object, like mathematically, what is it as a function?

In terms of code, what code would you write to make it? And conceptually, what are the kind of moving parts inside of it? And what ways is it principle to break it down into some components? You can refer to a circuit made up of several bits, and the mathematical framework basically just tries to do this for a transporters.

And in my opinion, has dramatically clarified my personal intuitions on how to think about all this in a way that's just pretty fundamental for reverse engineering a transformriddle. The paper particularly focuses on attention, because as noted, that's one of the biggest differences between transformers and image models where the earlier work happens. Sorry, it's one of the biggest differences between the image model architectures on which the earlier work happens, a bunch of image models use attention arrays. There are all system results in the paper where we reverse engineered 0, 1 and 2 layer models of interesting circuits, notably induction heads.

But to me, this is secondary to just the framework of being able to get traction at all in a way that's grounded and principled, and looking at some of the fundamental bits of the model. In context, learning in induction heads is a very different style of paper. To me, the core things of the paper are around universality, which is the idea that the same circuits and cognition happen in models of different scales and different data. Training dynamics will be looked at a model during training and emergence or phase transitions where we found some changes in the model during training.

So the headline results in the paper are, so we found this circuit called induction heads. The thing an induction head does is it detects and continues repeat a text, and we found this in these toy two-layer detection models. It turns out that induction heads seem to be a big part of the reason that models can do in context learning, which is jargon for use text very far back in the prompt to predict the next token. It's surprising that models can do this at all.

We're talking like, you've got a 10-page words document, and it learns to use some text on page two to usefully predict what happens after page 10. You can show transformers are good at this by looking at their performance per token by token position, and show them it's not better on later tokens. In a way, that's because it's using the earlier tokens, not because later tokens are inherently different. It turns out that this capability seems to significantly rely on these induction heads.

These induction heads occur in all models we looked at up to 13 billion printers, and the models and the induction heads all appear at around the same time in what we call a phase transition during training, where there's a fairly short period where you go from no induction heads to induction heads, and exactly coincides with the period where it gets incurred in context learning. There's a bunch more evidence in the paper about exactly why you believe this, but that's the headline claim, which are, and to me, the family is just using the mechanistic insights we found to understand a real fundamental property of networks that they can do this in context learning. The third category, my Grokking work, I put somewhere in the science of deep learning cap, where I'm trying to understand some underlying principles of deep learning models and how they work with some focus on phase transitions and emergence. Grokking is this mystery in deep learning famously found in this opening paper from the start of last year, where they found that if they train a small model, a transformer, in that case, on a simple algorithmic task, such as modular addition or composition of a permutation group or modular multiplication, that if they gave it, say, a third of the data to train on and two thirds of the held up test sets and kept training it on that third of the data for a really, really long time, it would initially memorize the training data.

But then if you trained it for long enough, it would suddenly generalize and what they called Grokked and go from being really, really bad on the unseen data to you, very good on the unseen data. And in particular, this is strange because it's not, during this transition, it's not getting that much better at the task that it's actually being trained on. Yeah. It's like messy and nuanced in the way we can get into it later, but it's not getting that much better is a reasonable thing to say.

It's achieved perfect accuracy on that task, is a thing we can confidently say, perfect accuracy on the training data. And so what I did is I trained a smaller model to Grok modular addition, a somewhat simplified one layer transformer, and replicated Grokking and it cleared Grokked and then did some painstaking and high efforts reverse engineering, where I discovered it learned this wild algorithm that involved trig identities and discrete Fourier transforms to do the modular addition. And that I could just, with pretty high confidence, describe how that was implemented in the model with a bunch of caveats and holes as we make it into later, and then could look at it during training using this, using this understanding and designed what we call progress measures based on this mechanistic understanding. And looking at it during training, I saw that the sudden Grokking actually broke down into three phases of training that I call memorization, where model to memorize the training data, circuit formation, where it slowly transitions from the memorized solution to the trick based generalizing solution, preserving train performance the entire time, and then cleanup, where it suddenly got so good at training, it's right, it suddenly got so good at generalization that it's no longer worth keeping around the memorization parameters.

Importantly, these models train the weight decay, but incentivize them to be simple. So it decides to get rid of it. And this is what results in the kind of sudden Grokking, because when the model is partially memorized and partially generalized, the generalizing bit is really good on the test data, the memorizing bit is like even more bad, such that it on net is just bad before. And the kind of high level principles from this are, I think it's a good proof of concept that a promising way to do sites that deep learning and understand these models is by building a model organism, like a kind of specific model to study that exhibits a mysterious phenomena, clearly understanding it, and then using this understanding to ground an exploration of the teacher principles.

And the second reason I think is exciting is that emergence or phase transitions are this thing that just seems to recur in a bunch of models on a bunch of model scales, and across a bunch of different dimensions, like DT3, can do addition in a way that sort of what's a model or how induction heads suddenly form during training. And we can totally imagine that some very relevant things might suddenly emerge. There's this fascinating people from Alexander Pan about how reward hacking can emerge if you scale a model up. Where reward hacking is like getting higher reward in a way that you didn't think it would roughly.

Yes, like to take an extremely modern example, a student getting a good mark on the essay because chat TPT read for them because they actually learned the concept. And so the, so one hopeful solution here is to do progress measures, which are some metrics, you can run on the model which chat progress towards the eventual emergent phenomenon, and the workers are proof of concept for if you really understand some example of the behavior you care about, you can design mechanistic, interruptibility inspired procedures. And I think the work has many limitations, including as models of these, both of these two things, but I also think it was like a very cool and fun project that has some useful insights to teach. Cool.

So now we've had a quick summary of each paper. How about we dive into each one individually? So the first paper is mathematical framework for transformer circuits. It's got a lot of authors.

I guess the first few are Nelson Elhodge. Is that how it's meant to think so? Nelson Elhodge, Neil Nanda, Catherine Olson, Tom Hennigan, Nicholas Drassif, Ben Mann, sorry if I missed anyone's names, and then the course several people down for a bit, and then Chris Ola being the corresponding author. And this is basically about- Yeah, with a contribution statement at the end of people on a decipher, the long, impenetrable list.

Yeah, actually really, one thing I actually like about an anthropic is, yeah, I found these these other contribution statements to be like, yeah, good reading, I don't know if it's just something inside of what this means. Yeah, I think it's nice. Yeah, Chris has an amazing blog post about credit and how he thinks about the importance of sharing credit generously and fairly with academic work. Sure.

He puts a lot of thought into contribution statements. I respect him a lot for that. Yeah. So, so it's kind of taking these versions of transformers that don't have the multilayer perceptron parts that are just attention heads of two layers and kind of building a mathematical framework for them.

And yeah, talking about the circuits. So one thing that struck me about this paper is like, it kind of emphasizes this idea that like, you've got these like different attention heads, which are called, but you can also have parts between attention heads and kind of like puts the emphasis on the parts rather than like the individual heads. Importantly, you can have parts through attention heads as well. So what do you mean by that distinction?

So for example, let's say you've got a head which just says, I'm going to predict that the previous token is going to come next. Then this head would attend to the previous token and it would have this, it would then take the thing it attends to apply linear map and that gets contributed to the residual stream of destination and there's maps called the OV circuit. And then you have a path from the previous token input through the OV circuit of the head to the current token output. Yep.

And I would say that that entire path is the correct thing to try to interpret. Yeah. So one thing that kind of scares me here is like, if you have some collection of things, there's going to be a lot more paths through the various things and there are like individual things to think through. And presumably the paths, there's some commonality between all the paths that run through a particular location, namely that location.

So I'm wondering like, ultimately, is this path analysis going to be like too unwieldy to be useful? Sure. So, yeah. So I definitely should say that a bunch of the things in the paper, I think we're either just fairly early techniques that haven't necessarily turned out to be incredibly useful or like that's scalable or what kind of proofs of concept for how to think about things.

And specifically, there's a bunch of equations where we fully expand out every path of the network and this god-awful combinatorial explosion of things. And I completely agree that no, that is not a reasonable thing to turn into a separate. So, so to get some framing, the way I think about what is going on inside of your network is you have these, you have bits of the network that are interpretable, not necessarily kind of like by definition interpretable, but like we can put some meaning on to them. And the network cares about them having a certain meaning.

And there are bits of the network that are kind of hard or messy or in the particular case of a transformer are things we expect to be highly compressed and highly under superposition. So, as a concrete example of this, let's say we've got a zero layer transformer, this is the dumbest possible transformer that just embeds the input tokens as vectors in space, does nothing to them. And then immediately applies a linear map to convert them to output tokens, or output logis. And importantly, this can't be of information between positions because there's no attention.

So, it is essentially just mapping the current token to guess for the next token. So, it's just a big memorized table of by-ground statistics. And if we just go through the data, we can just generate a big table of by-ground statistics. It's not really hot.

But the way the model has been forced to implement it is that it's had to map the 50,000 input tokens to this tiny, say 500-dimensional, bubble-mix space and then back up to 50,000. And it's presumably learned to compress this enormous table of stuff into something that can be done by this pretty narrow linear map. And one of the claims in the paper is the correct way to interpret some circuit, some circuit like this is that we don't try to interpret what the things in the 500-dimensional bottleneck mean. We try to interpret the start of the end and we assume that the stuff in the middle is like some heavily compressed nonsense.

Yeah, yeah. So, to my ways, a lot of this stuff about paths is saying, cool, we want to focus on things that start at end at things that have a meaning, where the things that have a meaning are input tokens, attention patterns, MLP activations and output, output logits. And we want to mostly focus on paths between these. Yeah.

So the goal is not to study every path. The goal is to find things that we want to understand and look for the paths leading to those that matter. Yeah. So this actually gets to another kind of worry I had about this paper.

So take the zero layer transform case, right, where you have this embedding matrix that's like 50,000 inputs to 50 outputs or something like that. And then an unembedding matrix which is 50 inputs to 50,000 outputs. And you're sort of just like, it's sort of the paper basically says, okay, we're just going to multiply them and think of this like 50,000 inputs, 50,000 output function and just think about that function. And it seems like this is going to kind of forget the fact that it's this very special type of 50,000 input to 50,000 output function, namely the type that's called low rank and mathematics type that can be imposed this way.

And so this like intermediate 50 component representation. How like how scary is it that we're forgetting this like really, this like key right structure in these matrices? Good question. The honest answer is I don't really know, but my guess is it's not that big a deal.

So the reason I guess it's not that big a deal is so one of the things you need to do if you're trying to get anywhere in reverse engineering and network is distinguishing between the things that matter and the things that it's trying to do in some sense from the things that kind of don't matter or just noise or small errors should really affect the underlying condition. And to me, a lot of the losses that happen when you smoosh things through bottleneck, more of the flavor, noise or things that aren't really important to the underlying computation than they are things that are kind of like key to it. And obviously this is kind of dangerous reasoning, especially if you're worried about a system that is adversarially trying to defeat our tools, and which might think through things like people are going to look at all of my multiplied out matrices, but by carefully choosing which bits I leave out in the low rank decomposition, I can smuggle in the cell of floors. And it's like, yes, there's a very little tailiness that, but my prediction is just that that isn't a thing that matters that much, at least for the kinds of network problems we're dealing with in a minute.

The second point would be one important caveat to the background case is that the model is not learning a by-ground table. It's not learning the matrix that is the by-ground table. It's learning a matrix that once fed through a softmax will be a good approximation to a by-ground table. Where if we haven't said this already, by-gram means like probability of the next thing and the current thing.

Yes, like how NANDA is more likely to follow a meal than a floor is to follow a meal. Sure. So it's a matrix that when you add a softmax, it's a by-gram table. Yes.

And this adds a ton more degrees of freedom, especially when you appreciate that there's just lots of tokens where the model is just like, it's just like, they occur, the model just doesn't really care. And one way to think about it is the model is trying to compress in information about each of the 50,000 tokens with a bottleneck and then decompress this and there's going to be a bunch of noise. And the model needs to do something non-linear to clean up the noise. And a softmax is just a really powerful way of cleaning up a bunch of noise if you know what you're doing.

All right. Cool. Yeah. So getting into the mathematical framework, yeah, actually, first question is, yeah, it means that it only, it really tries to understand the attention heads and just like basically ignores the multi-layer perceptron layers for now.

So there's a paper that I read once. His title was Transformer Feed Forward Layers are key value memories. They're basically argued that, look, we know what the MLP layers are doing. They're just like, basically you take some like certain representation match to various keys you have stored and then like say, ah, for this key, here's this value vector that I'm doing to produce.

And basically implying that like this was done in a way that like was relatively human understandable. And like, that was the answer. I'm curious, like, to what extent do you think that's true? And if it's true, do you think that it like, in that case, why delete it from this paper?

Sure. So first, just to de-confuse a annoying notation clash, when that paper says key and value, there's nothing to do with keys and values and attention heads. Yes. And instead in the computer science sense of like, you've got a dictionary, you look up an entry in the dictionary and you return whatever is stored in that entry.

Yeah. Yeah. So is this true? So I haven't engaged deeply with the results of that paper.

I've anecdotally heard some claims that some of the results replicate and some things need to replicate very well. But obviously, this is like an optically reliable data. My personal intuition would be that this is part of the story, but a pretty limited part. And where it's very easy to get some for this to be like a small part of what a neuron is doing and for this to seem like the whole part of what it is doing.

One thing to emphasize is just that a lot of this is just stuff that can be done with a lookup table, like in some sense, if you want to do an if statement, like if this vector is present in the residual stream, puts this other vector in the residual stream, then like when you have the first vector there, why don't you just put in the second vector there at the same time? Yeah. It like needs to be using the non-linearity in some interesting way or possibly some other dumb inside baseball thing will also care about like the residual stream gets bigger over time and there's this thing called a layer norm that scales it down to a uniform size. So this is everything to case over time.

And so maybe you want signal boosting neurons that boost important things or something. But like other than kind of which stuff like that that very plausibly is a contraction of what transform in your hands do. Yeah. I expect quite a lot of what transformers are doing.

Transforming neurons are doing is kind of internal processing that doesn't really capture. Within the framework we had earlier of the way you would reverse engineer a thing is you find interpretable things at the start and at the end. But you find interpretable things and you like use that as the standard which to grab the middle. This is specifically saying the inputs to the model and the outputs to the model and the kind of interesting interpretable things and everything else is only interesting as it connects one to the other.

And I'm like this is probably true of some neurons. I don't think it's true of most neurons. Okay. So let's say back to what was in the paper.

Yes. I should. Yeah. I do kind of want to just re-emphasize that these are my off the clock takes about this paper.

I think the actual reason we did not discuss that paper much is just like that was at the point of mathematical framework. The goal is to like understand attention plausibly this paper has some insights about MLPs but like the focus of paper was not understanding MLPs. Okay. Fair enough.

But also MLPs are really hard. Yeah. So speaking of understanding attention. One thing that is in this paper is the idea of there being three kinds of composition of attention heads where they can like Q compose, K compose and V compose, right?

To be honest with the explanation of the paper it left me a little bit mis-ified. So can you tell us like what are QK and V composition? Sure. Yes.

I'm very sad that was misleading because this is one of the bits of the paper I feel like I can claim some credit for giving this. Okay. All right. So what's going on here.

So I'm going to just actually explain how attention it works. All right. So the way to think about attention is so the models for the potential layers, each layer consists of several attention heads, each with their own parameters acting in parallel and kind of independently and in parallel and the upper of the layer is just the sum of the upper of each head. And so the way things work is that the model is doing two tasks.

One of the tasks is you've got this destination token which is the current position is figuring out which sources to pull information from and figuring out once it's figured out where to move things from, it's trying to figure out what information to move from those to the current position. And the where to move things from and to is determined by these two parts by these two sets of what each of these is called query weights, WQ and the key weights, WK, WK. And what happens is the model maps the destination was a dual stream to a query for this linear map. Okay.

The model maps every source was a dual stream to a key with the second linear map and it takes the dot product of every pair of source key and destination query. And then it wants the positions where the key aligns most with the query to have high attention pattern, but it also wants the attention pattern to all the positive reels that up to one. So does the each destination, it does a softmax over the previous things to get an attention pattern. Okay.

The key thing to take away from all this is that in contrast to simpler sequence modeling architectures like convolutional networks, where the model needs to solve this fundamental problem of which sequence positions are most relevant to the current position. In convolutional networks, they just hard code, nearby things relevant, far away things not relevant. In image convulate, it's kind of a 2D thing that's a thing principle. In RNs, recurrent neural networks, the thing that gets baked in is the like, it's kind of recursively going through the sequence.

So nearby stuff is obviously more relevant. The way transformers work is we let them spend some parameters figuring out which information is most relevant and heads tend to specialize in looking for different kinds of previous tokens. There are previous token heads, there are attempts at most recent full stop heads, there's a tend to the subject of the sentence heads, there's just a bunch of heads that do a bunch of different things. Transforms are about the 12th of their parameters doing this where to move information from computation.

One intuition of thinking about queries and keys is a query is like, what am I looking for? Within the context of this head, a key is like, what do I have to offer? And then these are both directions in this internal space. If they're aligned, it attends from the destination to that source.

The right way to think about neural networks, as always, is it has parameters that let it do a thing, it figures out a reasonable way to make that happen, it does not need to conform to my expectations of how this is reasonable. Sure. And all things I'm saying are just two stories. Okay.

So once it's figured out this attention pattern, it then needs to figure out what information to move. And what it does this is it's got another set of parameters, wv, that map the source of digital stream to this value vector. This is a small internal head dimension. It then averages all of the values using the attention pattern to get a kind of mixed value.

So values have gone from having a source position axis to having a destination position axis. And then we apply a final set of weights w to get the output of the head. And we add up every head's output and add it to the position. Okay.

So important things to note about this decomposition, like this thing I just outlined, also you should really go to stare at somebody algebra in the paper because this is not good audio content. Sorry. So you can see the the first is that most operations here are linear. The only things that are not linear are the softmax where we took the query key dots and conducted them to a distribution.

In particular, you can think of the if you think of the keys as a big tensor with the source position axis and the queries as a big tensor with a destination position axis. The dot product is actually just a matrix multiplied by these two tensors. And it turns out that you can think of this as taking the source residual stream, multiplying it by the matrix wk transpose wq and then multiplying and then dotting that with the destination residual stream. Okay.

Or equivalently thinking this is a bilinear form that takes in these two residual streams. And the key takeaway from this is that the matrix wk transpose wq is the main thing that matters. And we could apply, we could double wk and half wq and it wouldn't make a difference. Or we could apply some really weird transformation to the internal space, but make it to the product that you was saying.

You could like rotate one and de-rotate the other, for instance. Yeah, exactly. And so one of the takeaways for me from this work is that the way we think about attention is just as there is a parameter, there's a parameter matrix that determines how attention works for this head. And keys and queries are not like intrinsically on their own important things.

The next thing to draw out is that the value, so the value steps are interesting. So what's going on is you could start with a tensor with a source residual stream dimension and a demodal dimension, which is just like the actual content of the residual stream. Then wv acts on the content of the residual stream dimension. The attention pattern acts on the position dimension.

And then wo acts on the residual stream content dimension. And matrix multiplies on different axes of a tensor. It doesn't matter which order they go. So the two continents of this, the first is we've got another low rank factorised matrix, wv wo, which we call wov.

A really annoying thing is that a mat matrices are not one of the left in code, they're not one of the right, they always get confused about which is the right convention to use when talking about it. I apologise in advance. And so this means that values are not intrinsically meaningful because we could rotate wv and de-rotate wo and it would be exactly the same. The second important thing is that because these are different axes, it doesn't matter which detonation positions are getting this information.

Every detonation position gets the exact same information from a source position. It can only choose how much to wait it. And finally, this just reinforces the idea that attention is about rooting information because we're multiplying by the attention pattern on the source dimension axis. And one thing that's helpful to sometimes do is to imagine just freezing the attention patterns.

So you just like save and cache them and no longer compute them and then think about editing the network or changing the inputs. And you can think of the attention patterns as this dynamic wiring that gets set up with how to move information around. And if you freeze it, then every attention is actually just linear. And it lets information flow through the network.

Okay. And long tensions on how to think about attention heads. So QK and V composition. So there are kind of three things the model is doing.

There's where should I move information from? Where should I move it to? From is key. And Q is query.

And there's what information should I move from the source once I figure out where the source is, which is value. And these correspond to QK and V composition. Okay. Where so and Q comes from the destination residual stream K and V come from the source residual stream.

Frequently asked questions

How long is this episode of AXRP - the AI X-risk Research Podcast?

This episode is 3 hours and 52 minutes long.

When was this AXRP - the AI X-risk Research Podcast episode published?

This episode was published on February 4, 2023.

Is there a transcript available for this episode?

Yes, a full transcript is available for this episode. You can read the complete transcript on the episode page.

Can I download this AXRP - the AI X-risk Research Podcast episode?

Yes. Use the download control on the episode player to save the publisher-provided media file.