My Questions about Transformers
Here are my dictated questions today to GPT-6.2 about Transformers – diagnostic of my current level of understanding. The answers are within the competence of any current foundation model, of course, if you care to ask them. I've highly summarised the answers I received in italics in [square brackets], after each question.
My education comes from here.
---
Q1. In the transformer architecture, we have the concept, do we not, of a transformer stack which essentially allows the impact of successively further back embedding tokens to propagate through to later embedding tokens in the embedding sequence as presented to the transformer system. Is that right? How deep is this transformer stack? I'm thinking it's not very big, maybe 26 layers or something.
[Correct order of magnitude but on the small side. However, successive layers increase the depth of contextual computation, not its geographical reach within the token sequence. With full attention, even the first layer has access to all preceding tokens.]
Q2. So therefore if we had say a hundred thousand tokens in the input window and the hundred thousand and first token arrives from the user, when that hundred thousand and one token arrives and begins to propagate through the transformer levels, it's getting context information as modified by the various weight matrices, key, query, value, from essentially the entirety of the window, the whole hundred thousand prior embedding tokens that constitute the input stream. Is that correct?
[Yes, assuming full causal attention rather than sliding-window or sparse attention.]
Q3. Since the processing that's going on at each level is essentially multiplying the actual embedding vector by weight vectors, sorry, weight matrices which have been developed through the pre-training process, I would have thought that the values of the embedding vectors as they ascend up through the layers of the transformer stack in semantic terms must be utterly opaque. We're producing very, very smart output. But in terms of how all this vector, sorry, all this matrix multiplication and all this summation is actually creating that smartness must presumably be something which is completely mysterious if you actually looked at the numbers taking part in the computations. Is that correct?
[Broadly, yes. But there is an important distinction between semantic opacity and computational opacity.]
Q4. Sure, um, what you're calling the residual space in terms of the dimension of the residual space, is that actually the dimension of the embedding vector itself? That is, the number of coordinates an embedding will have? Or is it something else?
[Yes. In a standard transformer, the dimensionality of the residual space is the same as that of the initial token embedding vector. This is the architectural parameter usually called dmodel.]
Q5. Would it be fair to say that we know why transformers work? Or is all this clever matrix multiplication iterated across levels something which empirically works but we're not entirely sure why? Even conceptually?
[I think we need to distinguish three levels of explanation. We have a reasonably good understanding of the first, a partial understanding of the second, and a remarkably limited understanding of the third.
1. Why the transformer architecture is computationally powerful.
2. Why pre-training produces useful semantic representations.
3. Why the combination produces generalised intelligence, including reasoning, abstraction and conceptual innovation.]
Q6. As I understand it, real transformers have a number of different attention heads. That really means a number of transformers operating in parallel on the entire input token sequence. I heard numbers like 26 or something. I don't know what modern foundation models have.
Is that the number of separate transformer attention heads, if I'm using the language correctly? But my question was this: for each particular attention head, that is a particular transformer, the three weight matrices, the key matrix, the query matrix and the value matrix, they are fixed and not dependent upon the input embedding stream of token embeddings.
Now I know the dimensionality of these matrices is quite high. I think it's the square of the model dimension, which is perhaps a million entries or something. But because they're fixed matrices which were pre-trained through backpropagation on the input corpus, is there a sense in which they have rather frozen the concept of context so that it's like one context model per transformer over all kinds of inputs, whether it be kind of romantic novels or quantum theory?
It seems strange that one set of matrices per transformer or per attention head would have that degree of contextual flexibility in a fixed size of matrix...
[Each transformer layer contains multiple attention heads operating in parallel. These are not independent transformers. Their individual projection matrices are generally rectangular, containing around a million parameters apiece in some large models. Although these matrices are fixed, the contextual representations presented to them are continually evolving. What is fixed is a mechanism for assessing contextual relevance, not a particular model of context.
Why should a fixed repertoire of learned contextual operations, working in a vector space of only a few thousand dimensions, suffice to manipulate the conceptual apparatus of virtually every domain of human intellectual activity?
One possible answer is that human intellectual activity is itself highly compositional. Beneath the enormous diversity of subject matter lies a considerably smaller repertoire of fundamental cognitive operations: association, classification, analogy, reference, abstraction, inference, composition and so forth.
Perhaps pre-training discovers something approaching a reusable algebra of such operations.]

Edit clarification. Should the third last paragraph not be in normal font as it is your question? Hence a closing bracket ] preceding, and an opening bracket [ following?
ReplyDeleteWhoever originated the penultimate paragraph, it seems similar to a brief comment on YT I saw. Basically that there is a lot of redundancy in all these billions of calculations, with a (currently) hidden kernel inside?
The last four paras are all from GPT-6.2.
Delete