Pretrained Transformers as Universal Computation Engines (Machine Learning Research Paper Explained)
deep learning machine learning arxiv explained neural networks artificial intelligence paper what is deep learning deep learning tutorial introduction to deep learning berkeley google brain facebook ai research pretrained transformers gpt-3 huggingface language model fine-tuning finetuning out of domain generalization universal computation can transformers solve xor transformer mnist transformer cifar10 fine tuning transformer gpt-2 pretrained language model
#universalcomputation #pretrainedtransformers #finetuning

Large-scale pre-training and subsequent fine-tuning is a common recipe for success with transformer models in machine learning. However, most such transfer learning is done when a model is pre-trained on the same or a very similar modality to the final task to be solved. This paper demonstrates that transformers can be fine-tuned to completely different modalities, such as from language to vision. Moreover, they demonstrate that this can be done by freezing all attention layers, tuning less than .1% of all parameters. The paper further claims that language modeling is a superior pre-training task for such cross-domain transfer. The paper goes through various ablation studies to make its point.

OUTLINE:
0:00 - Intro & Overview
2:00 - Frozen Pretrained Transformers
4:50 - Evaluated Tasks
10:05 - The Importance of Training LayerNorm
17:10 - Modality Transfer
25:10 - Network Architecture Ablation
26:10 - Evaluation of the Attention Mask
27:20 - Are FPTs Overfitting or Underfitting?
28:20 - Model Size Ablation
28:50 - Is Initialization All You Need?
31:40 - Full Model Training Overfits
32:15 - Again the Importance of Training LayerNorm
33:10 - Conclusions & Comments

Paper: https://arxiv.org/abs/2103.05247
Code: https://github.com/kzl/universal-computation

Abstract:
We investigate the capability of a transformer pretrained on natural language to generalize to other modalities with minimal finetuning -- in particular, without finetuning of the self-attention and feedforward layers of the residual blocks. We consider such a model, which we call a Frozen Pretrained Transformer (FPT), and study finetuning it on a variety of sequence classification tasks spanning numerical computation, vision, and protein fold prediction. In contrast to prior works which investigate finetuning on the same modality as the pretraining dataset, we show that pretraining on natural language improves performance and compute efficiency on non-language downstream tasks. In particular, we find that such pretraining enables FPT to generalize in zero-shot to these modalities, matching the performance of a transformer fully trained on these tasks.

Authors: Kevin Lu, Aditya Grover, Pieter Abbeel, Igor Mordatch

Links:
TabNine Code Completion (Referral): http://bit.ly/tabnine-yannick
YouTube: https://www.youtube.com/c/yannickilcher
Twitter: https://twitter.com/ykilcher
Discord: https://discord.gg/4H8xxDF
BitChute: https://www.bitchute.com/channel/yannic-kilcher
Minds: https://www.minds.com/ykilcher
Parler: https://parler.com/profile/YannicKilcher
LinkedIn: https://www.linkedin.com/in/yannic-kilcher-488534136/
BiliBili: https://space.bilibili.com/1824646584

If you want to support me, the best thing to do is to share out the content :)

If you want to support me financially (completely optional and voluntary, but a lot of people have asked for this):
SubscribeStar: https://www.subscribestar.com/yannickilcher
Patreon: https://www.patreon.com/yannickilcher
Bitcoin (BTC): bc1q49lsw3q325tr58ygf8sudx2dqfguclvngvy2cq
Ethereum (ETH): 0x7ad3513E3B8f66799f507Aa7874b1B0eBC7F85e2
Litecoin (LTC): LQW2TRyKYetVC8WjFkhpPhtpbDM4Vw7r9m
Monero (XMR): 4ACL8AGrEo5hAir8A9CeVrW8pEauWvnp1WnSDZxW7tziCDLhZAGsgzhRQABDnFy8yuM9fWJDviJPHKRjV4FWt19CJZN9D4n
 Hi there! Today we're looking at pre-trained transformers as universal computation engines by Kevin Liu, Adita Grover, Pieter Abbeel and Igor Mordac. On a high level this paper argues that pre-trained transformers, specifically transformers pre-trained on language modeling, are doing something called universal computation. And the way they prove it is by transfer learning these transformers to completely new domains, so not language modeling. They do things like XOR tasks or C410, so computer vision. They transfer learn these transformers to these completely new domains and they don't just do it in a regular transfer learning way. They freeze almost all of the parameters of that transformers. Specifically they freeze all of the attention and all of the feet forward layers in the transformer. Therefore they only fine-tune about 0.01% or so or 0.1% of the parameters of the model. And they show that on these specific tasks these frozen pre-trained transformers, as you can see right here, are competitive if not outperforming a transformer that is fully trained from scratch on these tasks. And it also mostly outperforms LSTMs that are fully trained from scratch on these tasks. So this is pretty interesting and it gives rise to a number of sort of questions about what happens in these transformers. So we're going to look at what the claims are and what the evidence brought forth by this paper is about why language pre-trained transformers are universal computation engines. And yeah I'll have some comments on my own. As always if you do like content like this share it out, leave a like and tell me what you think is going on here in the comments. So the abstract reads we investigate the capability of transformer pre-trained on natural language to generalize to other modalities with minimal fine-tuning. And they say in particular without fine-tuning of the self-attention and feed-forward layers of the residual blocks. So as you know or as you might know a transformer is built approximately like this. So what you have is you have input so you have the positional embeddings and you have the input embeddings. Now if it is a language model that is simply one vector for every word or word piece, if it is an image model like in the vision transformer in the VIT, it is you simply take the image and you make it into these patches and then each patch you simply unroll the patch into one long vector. So you simply unroll the pixels and that is a patch and that in the sequence of such patches is your input. Now what follows is these self-attention blocks and this is the majority of the transformer is L times the self-attention blocks. You always have a attention layer and if you don't know what an attention layer is I'm sure you'll find some video on YouTube that explains it. This is followed by layer norm, this is followed by a element-wise feed-forward layer and it is again followed by a layer norm. You also have the residual connections as you can see right here. And then all of this is followed by an output layer and the output layer is very task-specific. In language modeling it's obviously classifying into the vocabulary so into one of whatever the 30,000 possible continuations. In computer vision it might be classifying into the classes of the data set. So for example in ImageNet you'd have a thousand classes or 21,000 depending on which version you use. So what they're saying is they are not fine-tuning, they are freezing the multi-head attention and they're also freezing the feed-forward layers. Now these make up like 99 some percent of the transformer. So what they get is they get a frozen pre-trained transformers and frozen specifically refers to these parts I marked in blue. In fact they just keep the attention and they keep the feed-forward layers as they come out of the language pre-training. And then they train the things on different tasks. So these tasks are as follows. There's bit memory. They consider a bit memory task where the model is shown five bit strings each of length 1000. Afterwards the model is shown a masked version of one of the bit strings where each bit is masked with probability 0.5 and a model is tasked with reproducing the original bit strings. So you give it five bit strings in sequence and then you give it a sixth one that is kind of corrupted and the model must figure out which one of these five it is and then it must successfully reproduce that bit string. So if it figures out it's probably numbered. So the model has to look at the overlap between the strings and then where there's the most overlap it needs to copy over that string or the non overlapping parts. So this is a fairly complicated task for a model like this that is just trained with backprop. There is bitxor where you have two bit strings of length five and you need to compute the element wise XOR. This is a long-standing difficult task for neural networks. We know that. There is list ops where you get a sequence like this and you must compute the result. So it's acting a little bit like a calculator. So now it turns actually out that if you think of the bit memory that's already pretty similar to language. Bitxor may be not. List ops we're gonna see that these models perform fairly poorly on the list ops task. And then the last one is computer vision. So MNIST and C410 is the classic like vision transformer domain. But still they take the transformer that's pre trained on language and simply fine-tune the positional embeddings, the input embeddings, the output layer and the layer norm parameters. That's all they do. And the last one is C410 from the long-range arena where instead of forming patches like this in the long-range arena task you simply take every single pixel into as its own kind of... So you don't do patches anymore. You do your own pixel by pixel. That is significantly longer vector for the model to compute over. So it's gonna make the task a bit more difficult because you completely lose all localization information. And the last one is this remote homology detection. It's a task from protein folding. Okay so how do these things do? You've already seen this here in the overview. Namely if you train these things on these bit tasks, so bit memory or bitxor, you can see that if the frozen transformer here reaches a hundred percent, so does the full transformer. So what that shows you it's not necessarily which one's better, it's just that both are able to completely solve this task. Well for example an LSTM is not. Though we have no idea here what the size of the LSTM is. I don't think they stated anywhere. So the comparison with an LSTM it is cool to see that the LSTM doesn't get this relatively simple task but it also might just be a function of how large the LSTM is and how much rigor goes into training one. Nevertheless the LSTM can't solve it and that's because the LSTM takes in a sequence as just one at a time and it needs to sort of remember in its hidden state what the individual elements are and it can't go back. The transformer can always look back. The LSTM needs to remember everything and I think that makes it much harder to do these kind of sequence tasks. I already told you list ops, they all perform badly but interestingly they perform equally badly. So the full transformer here is no better than the frozen transformer which is very interesting. If you look at MNIST and CIFAR-10, actually all of the other tasks you'll see that the frozen transformer is not worse than the full transformer. In fact it's sometimes better and that is going to be an interesting thing also to look at. So the whole paper is actually just ablation studies into this phenomenon like why does this happen and it's very cool and the result is going to be, so the authors claim that there is something special about language pre-training that already primes the transformer to be receptive to these new tasks. Now there are two different possibilities if you think what's happening here. Actually let's first go to the ablations and do the discussion at the end because once you see what is happening you'll be able to form your own opinion. What I would like to remind you though of is that they do train these layer norm parameters. So when I saw this and they said well we only train the input embeddings because of course it's a different modality so adjusting the input embeddings makes sense and the positional embeddings maybe too and the output layer because we have a different task that makes sense too and the rest we freeze but we also adjust the layer norm parameters but we don't adjust the attention. My immediate thought was they probably tried doing it without the layer norm parameters at the beginning. They probably tried just adjusting input and output embeddings and that probably didn't work too well and in the ablations you're actually going to see this. I think this hinges on the fact and we've seen this with transformers before I think they're called adapter layers so if you have your kind of transformer layers one after another what you can do is you can build in these adapter layers that have very few parameters that are kind of compressing and uncompressing the data and that's a way you can fine-tune the transformer so this kind of goes in and out again in dimensionality. That is a way you can adapt and we know that these things are very possible with transformers that you can sort of have the transformer ready and then only adjust very few parameters to transfer learn and I think the same is going on here. Now what the authors sort of hint at is that in the schematically if you have the transformer you have the attention part which is sort of the cross information routing part right and then after that you have the feed-forward part which is element-wise like this and then you sort of have a layer norm part and the layer norm part what it essentially is in terms of learnable parameter is that you take one element here or even one channel or one layer and this depends on the exact type of norm but you in the input signal you have two parameters that you learn so your output of the layer norm is going to be a normalized X so this is a normalization and you do it either over the batch or over the layer or something like this in layer norm you do it over the layer and you have two parameters that you can learn one is a scaling and one is an offset and I think you know by learning these you can adapt and this is this is I think these two things have a lot of relation to each other even though the authors say we don't learn any of the attention I can by influencing this a and this B right here and this Y then goes into the next layer of attention I can very much influence how the attention works right if the Y is then in the next layer from the Y I construct the W sorry I construct the the keys queries and values keep of this particular element and that decides what information gets routed where and so on so I have very much an influence over the over the attention in the next layer by adjusting this a I might not have a direct influence like I can only if of course if I want to change something in an element in the key an effect of this because I have to change the Y as a whole is going to be there also change something in here but certainly back prop will figure out some way I can make this happen okay so I I think this this whole notion of we don't influence the attention at all it's not as clear-cut it's true they don't change the attention parameters however they are very they are able to influence how information is routed by changing the signal itself in these layer norm parameters also they here they call it zero shot they say improves performance and compute efficiency on non language downstream tasks in particular we find that such pre training enables the frozen pre-transformers to generalize in zero shot to these modalities zero shot I think that's a bit of an it's a bit of an over claim like I get it you you pre-train whatever how many few percent like only fine-tuning 0.1% of the total number of parameters of the transformer model and none of the self attention parameters I don't think it's entirely fair to call this zero shot unless I completely have overseen and misread the paper which of course is possible because I'm just one person reading a paper okay so again we fine tune the output layer the input layer the layer norm parameters and the positional embeddings I'm my claim is this here does most of the work like we know we already know that for example for CNN's we can do we can take a randomly initialized CNN and by just adjusting the batch norm parameters we can already gain a non-trivial result and I think the layer norm here is doing a lot of the work of course the input and output layer as well we also know that we can take like a randomly initialized neural network and simply training an output layer can already also give us a good performance this is all stuff they do in this paper however I think the layer norm does a lot of the a lot of the crucial work here too but there are still some interesting things that come out of these experiments because it's not just that okay so as I said the paper is a big piece of ablation studies oh yeah that's what I forgot the interesting thing of course is that the fully trained transformer isn't better right that's the interesting thing like if you fully train a transformer on the same tasks and this is due I think and I think the paper agrees due to the fact that we are in sort of the low data regime at least for the things here that are like the natural data sets like MNIST or CIFAR 10 we don't have too many we don't have too many data points so training a big transformer with all the parameters could even be counterproductive because we're just going to overfit or shoot ourselves in the foot alright let's go through these experiments can pre-trained language models transfer to different modalities and the answer here is going to be yes absolutely so their base thing is like a GPT-2 model that is trained on language and it's so interesting right that if you transfer it to these tasks and you can see right here you compare it the so these are the results from figure one this is just what you saw in the bar diagram again it's pretty interesting that these fully the frozen pre-trained transformers match the performance of the full and outperform the LSTM's on these tasks they're pretty cool so in some tasks you can see right here in the homology they even outperform the fully trained transformers the second one what is the importance of the pre-training modality so here they're going to compare what if we just randomly initialize a transformer and then keep just keep we freeze the same layers but they're not trained a randomly initialized or we pre-train it on this bit memory tasks it's just this one task or we pre-train it on image net image net 21 K in fact we so we pre-train instead of on language on images or we pre-train on languages this is this FPT is pre-trained on languages which one is going to be the best so this is to counter people they're making the claim that language modeling has a specific specific property that language is sort of a good task to pre-train these transformers better than other modalities so you can't just pre-train the transformer on any old task that's what they're saying here that language is somehow special or the best out of these ones so in order to demonstrate that you can see right here the this is the language one the randomly initialized one already kind of under performs throughout here so actually not that much in these things here but you can see on MNIST or on C410 it it does not perform too well all across the bit memory one obviously performs well in the bit memory task that's what he was pre-trained on but also it kind of sucks on the rest of these tasks it's okay in MNIST it's the performance is kind of shaky and the vision transformer is better but it still lags behind except on C410 because you know being pre-trained as a vision model might you know it seems like it's okay that it performs well on image modeling the whole point here though is to generalize two domains out of your pre-training thing and on these domains the language one is better than all the other ones now the question there is a multiple questions here I think it is a bit too early from just this paper to say that language modeling has this special property right what I think might also be an explanation is for example how difficult is your pre-training task now when you look at language modeling you can look at simply how many classes does it have so the number of classes is in language modeling something like 30k like these vocabularies are fairly large random it's absolutely nothing these bit memory tasks is so you have two classes and in the vision transformer you have 21k classes but you only need to applied once per sequence right you only have to have one output whereas in language modeling you need to output every single so every single token is a classification so in fact the this is not necessarily more classes but it is let's say more training examples per training data point that you get because every token is a training example essentially so it might not be a language thing it might just be how how hard the task is in terms of number of classes and how much training data you have available I think there are a lot of variables that they haven't necessarily controlled for here and it might be a bit too early to say language modeling is the task though what I'm completely prepared to accept is to say language modeling is a good task in fact it's the best task out of these ones but I think the it could be a cool it could be cool to research more in this direction and say okay can we find a better task can we find a task that is even more complex and that depends on what is really going on here so I see two possibilities possibility one why this even works is to say that somehow natural signals are all somehow equal so pre training on language somehow makes the transformer the attention layers just adjust themselves to the sort of natural signals that we see around us so when we feed in an image recognition task or any other task that humans care about in the natural world the transformer is already sort of prepared about what that could entail like about the types of computation and then second of all and this this is different this is simply with enough complexity you see there is simply what I'm going to say computational computational utility computational utility what I mean by that is that there are simple when when you pre train on a task certain types of computation are going to be important for that task and the more complex and the bigger your model the more sort of print computational primitives you can encode into the attention layers now when you encode these computational primitives it's not necessarily of course it has something to do with the type of signal but I think what's up what could be happening is that these transformers they simply they prepare a lot of good features that are just useful to compute different stuff like XOR like remembering things and so on I think this could definitely be the case that in these attention layers there are these just computational primitives encoded and if you pre train on a task and the harder the task is the more of these primitives need to be encoded and what you do when you adjust the layers in between is simply that you recombine these primitives in a better way but sort of all of the computational primitives are already there I think I think the two are not necessarily even exclusive and I think the paper hints at both might be playing a role right here I don't think they say exactly the same thing but this would also give sort of meaning to this word of computation or universal computation engine there of that that these transformers and we might even extend that to probably any machine learning model if we could scale it up and train it correctly probably evolves or trains to have these computational primitives inside of it and that's why we can adjust it with just a little bit now they're going to claim there is something about language pre training later so first of all they say how important is the transformer architecture and here they simply say if we take a randomly initialized transformer and compare it with a randomly initialized LSTM we freeze we freeze the attention layers and then we just do our frozen training then the transformer performs a lot better than the LSTM here in most actually all of the tasks however this is a very shaky comparison of course because how do you fairly compare a transformer architectures within LSTM architectures do you control number of parameters number of computation speed I don't know okay so I don't know what's fair next does language pre training improve efficiency over random initialization the answer is yes it converges much faster if you pre train with language and do the frozen attention layers attend to modality specific tokens so here they're just going to look at the first attention layer and they see that the attention matrix for example in this bit sore task attends so here are the two here are the two this is string number one this is string number two and in the output from here you need to compute the the X or you can see that the attention first is it's on the on the first one and then it's also on the second one right in the output it always looks at the corresponding position so here you can see clearly that the attention matrix already attends to the correct things for the task which is cool because we've never trained the attention right but it's I think that goes into my claim that look we are still able to influence the attention matrix even though we don't train the attention weights we are able to influence it by training these in between parameters the same goes for these bit memory tasks you can see the attention matrices are very much attuned to the task right here next one this freezing the transformer prevent overfitting or under fitting and here they they train this frozen transformer and they compare it to training a transformer that just has three layers so they say our general finding is that in contrast to their fully trained counterparts FPT models underfit the data which lends them to further improvements by increasing model capacity so if you compare it to a three layer transformer the three layer transformer does outperform the 12 layer frozen transformer however it does so by reaching a much higher training accuracy so overfitting is much more of a problem if you fully train the transformer however if you use this frozen transformer you're probably under fitting as you can see right here so you could technically scale up and gain more power with this frozen fine-tuning thus performance scale with model size yes so you can see as you increase from small to medium to large as you increase the number of layers the performance increases however the performance also increases for a randomly initialized one so it just seems to be like the more parameters the better it's the same and here is something I find interesting can performance be attributed simply to better statistics for initializations here they're going to let's say make the point that there is something about language model pre training that actually makes the transformer conducive to all these tasks and you can't just reach that by better initialization which is more point one from here than point two because point two you could just reach by initializing in a better way like this we could we could characterize these computational primitives and we could build them in from the start whereas natural signals we can't characterize them otherwise we wouldn't need machine learning so what they're going to do is they're simply going to take a fully trained transformer which they call an oracle and then they they're going to compute the mean and the standard deviation so that the Gaussian from those and then they're going to initialize this new transformer so they're going to take the pre trained which they have they're going to do default which is the randomly initialized one we've already seen those one as well and then they're going to take a randomly initialized one but not randomly with a default randomization but randomly with the statistics they got from the oracle so this transformer is going to be randomly initialized but it has the same statistics as the as the full transformer or as a trained transformer so the statistics are correct and that does not seem it seems to help a little bit as you can see but it does not seem to help in fact here it even it even hurts however I think that's a bit of a weak experiment and I think there is still a possibility that we could initialize these transformers much better if we could if we could correctly capture the essence of these computational primitives that are there in that are learned by gradient descent I think if we can capture those in a theoretically sound way we might be able to initialize or if we could just yeah if we could find like a not a natural language but if we could find a synthetic pre training task that is just so hard but it completely initializes all of these computational primitives that might still be better and that's going to be the ultimate experiment that differentiates between option one natural language pre training is somehow important because of grammar and natural signals or option two what we're doing is just inputting computational primitives into these layers does fine-tuning self attention and feed forward layers further improve performance and the answer is actually no it degrades you can see right here this is worse than this and that's because probably of overfitting if you fine-tune the whole transformer you're going to fall down and now here is where it really comes in that you know these tasks they are in the low data regime I know if you go back five years that sounds ridiculous but right now they are these things will overfit if you train everything and here it comes which parameters of the model are important to fine-tune and you can go look at the you can go look at the look at the table it's in the appendix but they say in particular we find orthogonal initialization wait we run ablations da da da da da da da here we generally find the layer norm parameters to be most important the layer norm parameters right and that sort of gives it gives a gives credence to the fact this is not so the I think what what they're doing yeah these layer norms they carry a lot of the weight of these things right here it's still pretty cool because there are very few parameters that you need to fine-tune and okay now they do a bunch of more ablations like only training the output layer which gives non-trivial performance but not a good enough performance so and yeah for some reason I have another set of the paper right here but this was essentially the paper it's very cool and the paper is super I think it's well written and it's easy to read because it's like hey here is a phenomenon we've discovered and now we're just going to investigate all kinds of things that explain this phenomenon we're going to rule out some stuff some hypotheses and we're going to arrive at some kind of conclusion in here and yeah that was my two cents to this paper I hope you enjoyed it it's a bit of a shorter video and bye bye
 Hi there! Today we're looking at pre-trained transformers as universal
 computation engines by Kevin Liu, Adita Grover, Pieter Abbeel and Igor Mordac.
 On a high level this paper argues that pre-trained transformers, specifically
 transformers pre-trained on language modeling, are doing something called
 universal computation. And the way they prove it is by transfer learning these
 transformers to completely new domains, so not language modeling. They do things
 like XOR tasks or C410, so computer vision. They transfer learn these
 transformers to these completely new domains and they don't just do it in a
 regular transfer learning way. They freeze almost all of the parameters of
 that transformers. Specifically they freeze all of the attention and all of
 the feet forward layers in the transformer. Therefore they only fine-tune
 about 0.01% or so or 0.1% of the parameters of the model. And they show
 that on these specific tasks these frozen pre-trained transformers, as you
 can see right here, are competitive if not outperforming a transformer that is
 fully trained from scratch on these tasks. And it also mostly outperforms LSTMs
 that are fully trained from scratch on these tasks. So this is pretty
 interesting and it gives rise to a number of sort of questions about what
 happens in these transformers. So we're going to look at what the claims are and
 what the evidence brought forth by this paper is about why language
 pre-trained transformers are universal computation engines. And yeah I'll have
 some comments on my own. As always if you do like content like this share it out,
 leave a like and tell me what you think is going on here in the comments.
 So the abstract reads we investigate the capability of transformer pre-trained
 on natural language to generalize to other modalities with minimal fine-tuning.
 And they say in particular without fine-tuning of the self-attention and
 feed-forward layers of the residual blocks. So as you know or as you might
 know a transformer is built approximately like this. So what you have
 is you have input so you have the positional embeddings and you have the
 input embeddings. Now if it is a language model that is simply one vector for
 every word or word piece, if it is an image model like in the vision
 transformer in the VIT, it is you simply take the image and you make it into
 these patches and then each patch you simply unroll the patch into one
 long vector. So you simply unroll the pixels and that is a patch and that in
 the sequence of such patches is your input. Now what follows is these
 self-attention blocks and this is the majority of the transformer is L times
 the self-attention blocks. You always have a attention layer and if you
 don't know what an attention layer is I'm sure you'll find some video on
 YouTube that explains it. This is followed by layer norm, this is followed
 by a element-wise feed-forward layer and it is again followed by a layer norm. You
 also have the residual connections as you can see right here. And then all of
 this is followed by an output layer and the output layer is very task-specific.
 In language modeling it's obviously classifying into the vocabulary so into
 one of whatever the 30,000 possible continuations. In computer vision it
 might be classifying into the classes of the data set. So for example in ImageNet
 you'd have a thousand classes or 21,000 depending on which version you use.
 So what they're saying is they are not fine-tuning, they are freezing the
 multi-head attention and they're also freezing the feed-forward layers. Now
 these make up like 99 some percent of the transformer. So what they get is they
 get a frozen pre-trained transformers and frozen specifically refers to these
 parts I marked in blue. In fact they just keep the attention and they keep the
 feed-forward layers as they come out of the language pre-training. And then
 they train the things on different tasks. So these tasks are as follows. There's
 bit memory. They consider a bit memory task where the model is shown five bit
 strings each of length 1000. Afterwards the model is shown a masked version of
 one of the bit strings where each bit is masked with probability 0.5 and a
 model is tasked with reproducing the original bit strings. So you give it
 five bit strings in sequence and then you give it a sixth one that is kind of
 corrupted and the model must figure out which one of these five it is and then
 it must successfully reproduce that bit string. So if it figures out it's
 probably numbered. So the model has to look at the overlap between the strings
 and then where there's the most overlap it needs to copy over that string or the
 non overlapping parts. So this is a fairly complicated task for a model like
 this that is just trained with backprop. There is bitxor where you have
 two bit strings of length five and you need to compute the element wise XOR.
 This is a long-standing difficult task for neural networks. We know that. There
 is list ops where you get a sequence like this and you must compute the
 result. So it's acting a little bit like a calculator. So now it turns actually
 out that if you think of the bit memory that's already pretty similar to
 language. Bitxor may be not. List ops we're gonna see that these
 models perform fairly poorly on the list ops task. And then the last one is
 computer vision. So MNIST and C410 is the classic like vision transformer
 domain. But still they take the transformer that's pre trained on
 language and simply fine-tune the positional embeddings, the input embeddings,
 the output layer and the layer norm parameters. That's all they do. And the
 last one is C410 from the long-range arena where instead of forming patches
 like this in the long-range arena task you simply take every single pixel into
 as its own kind of... So you don't do patches anymore. You do your own
 pixel by pixel. That is significantly longer vector for the model to
 compute over. So it's gonna make the task a bit more difficult because you
 completely lose all localization information. And the last one is this
 remote homology detection. It's a task from protein folding. Okay so how do
 these things do? You've already seen this here in the overview. Namely
 if you train these things on these bit tasks, so bit memory or bitxor, you can
 see that if the frozen transformer here reaches a hundred percent, so does
 the full transformer. So what that shows you it's not necessarily which one's
 better, it's just that both are able to completely solve this task. Well
 for example an LSTM is not. Though we have no idea here what the size of the
 LSTM is. I don't think they stated anywhere. So the comparison with an LSTM
 it is cool to see that the LSTM doesn't get this relatively simple task but it
 also might just be a function of how large the LSTM is and how much rigor
 goes into training one. Nevertheless the LSTM can't solve it and that's because
 the LSTM takes in a sequence as just one at a time and it needs to sort of
 remember in its hidden state what the individual elements are and it can't go
 back. The transformer can always look back. The LSTM needs to remember
 everything and I think that makes it much harder to do these kind of sequence
 tasks. I already told you list ops, they all perform badly but interestingly
 they perform equally badly. So the full transformer here is no better than the
 frozen transformer which is very interesting. If you look at MNIST and
 CIFAR-10, actually all of the other tasks you'll see that the frozen
 transformer is not worse than the full transformer. In fact it's sometimes
 better and that is going to be an interesting thing also to look at.
 So the whole paper is actually just ablation studies into this phenomenon
 like why does this happen and it's very cool and the result is going to be, so
 the authors claim that there is something special about language
 pre-training that already primes the transformer to be receptive to these
 new tasks. Now there are two different possibilities if you think
 what's happening here. Actually let's first go to the ablations and do the
 discussion at the end because once you see what is happening you'll be
 able to form your own opinion. What I would like to remind you though of is
 that they do train these layer norm
 parameters. So when I saw this and they said well we only
 train the input embeddings because of course it's a different modality so
 adjusting the input embeddings makes sense and the positional embeddings
 maybe too and the output layer because we have a different task that makes
 sense too and the rest we freeze but we also adjust the layer norm parameters
 but we don't adjust the attention. My immediate thought was they
 probably tried doing it without the layer norm parameters at the beginning.
 They probably tried just adjusting input and output embeddings and that probably
 didn't work too well and in the ablations you're actually going to see
 this. I think this hinges on the fact and we've seen this with
 transformers before I think they're called adapter layers so if you have
 your kind of transformer layers one after another what you can do is you
 can build in these adapter layers that have very few parameters that are kind
 of compressing and uncompressing the data and that's a way you can fine-tune
 the transformer so this kind of goes in and out again in dimensionality. That is
 a way you can adapt and we know that these things are very possible with
 transformers that you can sort of have the transformer ready and then only
 adjust very few parameters to transfer learn and I think the same is going on
 here. Now what the authors sort of hint at is that in the schematically if
 you have the transformer you have the attention part which is sort of the
 cross information routing part right and then after that you have the
 feed-forward part which is element-wise like this and then you sort of have a
 layer norm part and the layer norm part what it essentially is in terms of
 learnable parameter is that you take one element here or even one channel or one
 layer and this depends on the exact type of norm but you in the input signal you
 have two parameters that you learn so your output of the layer norm is going
 to be a normalized X so this is a normalization and you do it either over
 the batch or over the layer or something like this in layer norm you do it over
 the layer and you have two parameters that you can learn one is a scaling and
 one is an offset and I think you know by learning these you can adapt and this is
 this is I think these two things have a lot of relation to each other even though
 the authors say we don't learn any of the attention I can by influencing this
 a and this B right here and this Y then goes into the next layer of attention I
 can very much influence how the attention works right if the Y is then in
 the next layer from the Y I construct the W sorry I construct the the keys
 queries and values keep of this particular element and that decides what
 information gets routed where and so on so I have very much an influence over
 the over the attention in the next layer by adjusting this a I might not have a
 direct influence like I can only if of course if I want to change something in
 an element in the key an effect of this because I have to change the Y as a
 whole is going to be there also change something in here but certainly back
 prop will figure out some way I can make this happen okay so I I think this this
 whole notion of we don't influence the attention at all it's not as clear-cut
 it's true they don't change the attention parameters however they are
 very they are able to influence how information is routed by changing the
 signal itself in these layer norm parameters also they here they call it
 zero shot they say improves performance and compute efficiency on non language
 downstream tasks in particular we find that such pre training enables the
 frozen pre-transformers to generalize in zero shot to these modalities zero
 shot I think that's a bit of an it's a bit of an over claim like I get it you
 you pre-train whatever how many few percent like only fine-tuning 0.1% of
 the total number of parameters of the transformer model and none of the self
 attention parameters I don't think it's entirely fair to call this zero shot
 unless I completely have overseen and misread the paper which of course is
 possible because I'm just one person reading a paper okay so again we fine
 tune the output layer the input layer the layer norm parameters and the
 positional embeddings I'm my claim is this here does most of the work like we
 know we already know that for example for CNN's we can do we can take a
 randomly initialized CNN and by just adjusting the batch norm parameters we
 can already gain a non-trivial result and I think the layer norm here is doing
 a lot of the work of course the input and output layer as well we also know
 that we can take like a randomly initialized neural network and simply
 training an output layer can already also give us a good performance this is
 all stuff they do in this paper however I think the layer norm does a lot of the
 a lot of the crucial work here too but there are still some interesting things
 that come out of these experiments because it's not just that okay so as I
 said the paper is a big piece of ablation studies oh yeah that's what I
 forgot the interesting thing of course is that the fully trained transformer
 isn't better right that's the interesting thing like if you fully
 train a transformer on the same tasks and this is due I think and I think the
 paper agrees due to the fact that we are in sort of the low data regime at least
 for the things here that are like the natural data sets like MNIST or CIFAR 10
 we don't have too many we don't have too many data points so training a big
 transformer with all the parameters could even be counterproductive because
 we're just going to overfit or shoot ourselves in the foot alright let's go
 through these experiments can pre-trained language models transfer to
 different modalities and the answer here is going to be yes absolutely so their
 base thing is like a GPT-2 model that is trained on language and it's so
 interesting right that if you transfer it to these tasks and you can see right
 here you compare it the so these are the results from figure one this is just
 what you saw in the bar diagram again it's pretty interesting that these fully
 the frozen pre-trained transformers match the performance of the full and
 outperform the LSTM's on these tasks they're pretty cool so in some tasks you
 can see right here in the homology they even outperform the fully trained
 transformers the second one what is the importance of the pre-training modality
 so here they're going to compare what if we just randomly initialize a
 transformer and then keep just keep we freeze the same layers but they're not
 trained a randomly initialized or we pre-train it on this bit memory tasks
 it's just this one task or we pre-train it on image net image net 21 K in fact
 we so we pre-train instead of on language on images or we pre-train on
 languages this is this FPT is pre-trained on languages which one is
 going to be the best so this is to counter people they're making the claim
 that language modeling has a specific specific property that language is sort
 of a good task to pre-train these transformers better than other modalities
 so you can't just pre-train the transformer on any old task that's what
 they're saying here that language is somehow special or the best out of these
 ones so in order to demonstrate that you can see right here the this is the
 language one the randomly initialized one already kind of under performs
 throughout here so actually not that much in these things here but you can
 see on MNIST or on C410 it it does not perform too well all across the bit
 memory one obviously performs well in the bit memory task that's what he was
 pre-trained on but also it kind of sucks on the rest of these tasks it's okay in
 MNIST it's the performance is kind of shaky and the vision transformer is
 better but it still lags behind except on C410 because you know being
 pre-trained as a vision model might you know it seems like it's okay that it
 performs well on image modeling the whole point here though is to generalize
 two domains out of your pre-training thing and on these domains the language
 one is better than all the other ones now the question there is a multiple
 questions here I think it is a bit too early from just this paper to say that
 language modeling has this special property right what I think might also
 be an explanation is for example how difficult is your pre-training task now
 when you look at language modeling you can look at simply how many classes does
 it have so the number of classes is in language modeling something like 30k
 like these vocabularies are fairly large random it's absolutely nothing these bit
 memory tasks is so you have two classes and in the vision transformer you have
 21k classes but you only need to applied once per sequence right you only have to
 have one output whereas in language modeling you need to output every
 single so every single token is a classification so in fact the this is
 not necessarily more classes but it is let's say more training examples per
 training data point that you get because every token is a training example
 essentially so it might not be a language thing it might just be how how
 hard the task is in terms of number of classes and how much training data you
 have available I think there are a lot of variables that they haven't
 necessarily controlled for here and it might be a bit too early to say language
 modeling is the task though what I'm completely prepared to accept is to say
 language modeling is a good task in fact it's the best task out of these ones but
 I think the it could be a cool it could be cool to research more in this
 direction and say okay can we find a better task can we find a task that is
 even more complex and that depends on what is really going on here so I see
 two possibilities possibility one why this even works is to say that somehow
 natural signals are all somehow equal so pre training on language somehow makes
 the transformer the attention layers just adjust themselves to the sort of
 natural signals that we see around us so when we feed in an image recognition
 task or any other task that humans care about in the natural world the
 transformer is already sort of prepared about what that could entail like about
 the types of computation and then second of all and this this is different this is
 simply with enough complexity you see there is simply what I'm going to say
 computational computational utility computational utility what I mean by
 that is that there are simple when when you pre train on a task certain types of
 computation are going to be important for that task and the more complex and
 the bigger your model the more sort of print computational primitives you can
 encode into the attention layers now when you encode these computational
 primitives it's not necessarily of course it has something to do with the
 type of signal but I think what's up what could be happening is that these
 transformers they simply they prepare a lot of good features that are just
 useful to compute different stuff like XOR like remembering things and so on I
 think this could definitely be the case that in these attention layers there
 are these just computational primitives encoded and if you pre train on a task
 and the harder the task is the more of these primitives need to be encoded and
 what you do when you adjust the layers in between is simply that you recombine
 these primitives in a better way but sort of all of the computational
 primitives are already there I think I think the two are not necessarily even
 exclusive and I think the paper hints at both might be playing a role right here
 I don't think they say exactly the same thing but this would also give sort of
 meaning to this word of computation or universal computation engine there of
 that that these transformers and we might even extend that to probably any
 machine learning model if we could scale it up and train it correctly probably
 evolves or trains to have these computational primitives inside of it
 and that's why we can adjust it with just a little bit now they're going to
 claim there is something about language pre training later so first of all they
 say how important is the transformer architecture and here they simply say
 if we take a randomly initialized transformer and compare it with a
 randomly initialized LSTM we freeze we freeze the attention layers and then we
 just do our frozen training then the transformer performs a lot better than
 the LSTM here in most actually all of the tasks however this is a very shaky
 comparison of course because how do you fairly compare a transformer architectures
 within LSTM architectures do you control number of parameters number of
 computation speed I don't know okay so I don't know what's fair next does
 language pre training improve efficiency over random initialization the answer is
 yes it converges much faster if you pre train with language and do the frozen
 attention layers attend to modality specific tokens so here they're just
 going to look at the first attention layer and they see that the attention
 matrix for example in this bit sore task attends so here are the two here are the
 two this is string number one this is string number two and in the output from
 here you need to compute the the X or you can see that the attention first is
 it's on the on the first one and then it's also on the second one right in the
 output it always looks at the corresponding position so here you can
 see clearly that the attention matrix already attends to the correct things
 for the task which is cool because we've never trained the attention right but
 it's I think that goes into my claim that look we are still able to influence
 the attention matrix even though we don't train the attention weights we are
 able to influence it by training these in between parameters the same goes for
 these bit memory tasks you can see the attention matrices are very much attuned
 to the task right here next one this freezing the transformer prevent
 overfitting or under fitting and here they they train this frozen transformer
 and they compare it to training a transformer that just has three layers
 so they say our general finding is that in contrast to their fully trained
 counterparts FPT models underfit the data which lends them to further
 improvements by increasing model capacity so if you compare it to a three
 layer transformer the three layer transformer does outperform the 12 layer
 frozen transformer however it does so by reaching a much higher training
 accuracy so overfitting is much more of a problem if you fully train the
 transformer however if you use this frozen transformer you're probably
 under fitting as you can see right here so you could technically scale up and
 gain more power with this frozen fine-tuning thus performance scale with
 model size yes so you can see as you increase from small to medium to large as
 you increase the number of layers the performance increases however the
 performance also increases for a randomly initialized one so it just
 seems to be like the more parameters the better it's the same and here is
 something I find interesting can performance be attributed simply to
 better statistics for initializations here they're going to let's say make the
 point that there is something about language model pre training that
 actually makes the transformer conducive to all these tasks and you can't just
 reach that by better initialization which is more point one from here than
 point two because point two you could just reach by initializing in a better
 way like this we could we could characterize these computational
 primitives and we could build them in from the start whereas natural signals
 we can't characterize them otherwise we wouldn't need machine learning so what
 they're going to do is they're simply going to take a fully trained
 transformer which they call an oracle and then they they're going to compute
 the mean and the standard deviation so that the Gaussian from those and then
 they're going to initialize this new transformer so they're going to take the
 pre trained which they have they're going to do default which is the
 randomly initialized one we've already seen those one as well and then they're
 going to take a randomly initialized one but not randomly with a default
 randomization but randomly with the statistics they got from the oracle so
 this transformer is going to be randomly initialized but it has the same
 statistics as the as the full transformer or as a trained transformer so
 the statistics are correct and that does not seem it seems to help a little bit
 as you can see but it does not seem to help in fact here it even it even hurts
 however I think that's a bit of a weak experiment and I think there is still a
 possibility that we could initialize these transformers much better if we
 could if we could correctly capture the essence of these computational
 primitives that are there in that are learned by gradient descent I think if
 we can capture those in a theoretically sound way we might be able to initialize
 or if we could just yeah if we could find like a not a natural language but
 if we could find a synthetic pre training task that is just so hard but
 it completely initializes all of these computational primitives that might
 still be better and that's going to be the ultimate experiment that
 differentiates between option one natural language pre training is somehow
 important because of grammar and natural signals or option two what we're doing
 is just inputting computational primitives into these layers does
 fine-tuning self attention and feed forward layers further improve
 performance and the answer is actually no it degrades you can see right here
 this is worse than this and that's because probably of overfitting if you
 fine-tune the whole transformer you're going to fall down and now here is where
 it really comes in that you know these tasks they are in the low data regime I
 know if you go back five years that sounds ridiculous but right now they are
 these things will overfit if you train everything and here it comes which
 parameters of the model are important to fine-tune and you can go look at the you
 can go look at the look at the table it's in the appendix but they say in
 particular we find orthogonal initialization wait we run ablations
 da da da da da da da here we generally find the layer norm parameters to be
 most important the layer norm parameters right and that sort of gives it gives a
 gives credence to the fact this is not so the I think what what they're doing
 yeah these layer norms they carry a lot of the weight of these things right here
 it's still pretty cool because there are very few parameters that you need to
 fine-tune and okay now they do a bunch of more ablations like only training
 the output layer which gives non-trivial performance but not a good enough
 performance so and yeah for some reason I have another set of the paper right
 here but this was essentially the paper it's very cool and the paper is super I
 think it's well written and it's easy to read because it's like hey here is a
 phenomenon we've discovered and now we're just going to investigate all
 kinds of things that explain this phenomenon we're going to rule out some
 stuff some hypotheses and we're going to arrive at some kind of conclusion in
 here and yeah that was my two cents to this paper I hope you enjoyed it it's a
 bit of a shorter video and bye bye