# An exploration of GPT-2's embedding weights

*I wrote this doc in December 2021, while working at Redwood Research. It summarizes a handful of observations about GPT-2-small's weights -- mostly the embedding matrix, but also the LayerNorm gain parameters -- that I found while doing some open-ended investigation of the model. I wanted to see how much I could learn by studying just those parameters, without looking at the attention layers, MLP layers, or activations.*

*This is still mostly unedited. Feedback and questions are very welcome.*

Embedding matrix glossary
=========================

*   Latent space – 768-channel-dim space that activations between blocks (and in skip connections) live in.
*   Token space – 50,257-token-dim space of one-hot token vectors
*   \[Token\] embedding matrix – W of shape \[768, 50257\] (this is the transpose of \`model.lm_head.weight\`)
*   Embedding vector – Any 768-dimensional column of W
*   Embedding space – Latent space

Preferred channel basis from LayerNorm
======================================

This section involves more math than the rest; you can skip it without missing much. "Preferred basis" means the same thing as "privileged basis" as defined by Anthropic [here](https://transformer-circuits.pub/2021/framework/index.html#def-privileged-basis).

Most of GPT-2’s architecture – the attention layers, fully-connected layers and residual connections – don’t impose a preferred basis on the latent space.

(The skip connections give a canonical map between the latent spaces in different layers, so that it makes sense to talk about “the” latent space globally.)

The LayerNorm layers actually *do* privilege a basis, though, for two reasons.

LayerNorm(x) is defined as follows, where w and b are learned parameters:

*   $y_i = \sum_j(\text{Id}_{ij}-1_i 1_j) x_j$(subtract mean; 1 is an all-ones vector)
*   $z_i = y_i / \sqrt{\sum_jy_jy_j}$ (normalize variance)
*   $\text{LayerNorm}(x)_i = w_iz_i-b_i$ (apply bias and gain parameters)

The first line picks out part of a preferred basis – a preferred vector (and the subspace orthogonal to it), namely the all-ones vector 1.

The second line doesn’t pick out a basis, because the stdev of the components of y is just its L2 norm and normalizing a vector is independent of (orthonormal) basis. (It *does* impose a preferred inner product, but we had that already: GPT-2’s unembedding matrix is the transpose of the embedding matrix, and W^T W is a matrix of inner products.)

The third line is the interesting one. The gain vector w is multiplied *elementwise* with z, which breaks basis-independence. (You could also write this as D\_ij z\_j where D is a diagonal matrix, D\_ii = w\_i.) This makes the standard basis a preferred basis, in a pretty straightforward way: the network can dial up or down the size of different standard-basis components independently (and can’t do this for the components with respect to any other basis).

This provides some justification for breaking things out by latent-space dimension in most of this post.

Token/Position embedding rivalry
================================

Here’s an interesting phenomenon I don’t have a complete explanation for.

This is a chunk of the token embedding matrix:  
![](https://lh6.googleusercontent.com/VtRsLr2qV_uLPtESChe7vJoMtlWg1yCyqCYQq9Q3RkJ1mOlaci_vITt0aZnjts2mULYhNNHsxOu1xX73KD49uu8-keon5oKU3UyD2KDvnhWKAMcGDwJ_XqFkZ-M4xg0mAVnCFR5Cg1MEdvYNLQYYC_caFK5nJZXZg0xYd0QTS3lW0niTu9wosmk4Y7DA)

(X: token dims, Y: channel dims)

The horizontal stripes are dimensions of the latent space where the token embeddings are systematically larger or smaller than average. This gets normalized away inside residual blocks, but is preserved by skip connections.

We can also make histograms from this matrix, by taking either a row or a column and plotting a histogram of the numbers in it. We can overlay a few of these histograms, in different colors, to show a few columns or a few rows at the same time.

Overlaid histograms of the first 30 columns (tokens, left) and the first 30 rows (channel dims, right):

![](https://lh3.googleusercontent.com/IjEfm6x-gNsTXFQcWQVgrSLz3ewbgeYPwGsYFw_O6xwEAicNbhkZlUaXlbpNIOD4WVgolIOBhOXxfUuOnwk3MhZUyZjMWqpCYsYV19rKv89wpynk-u58tSWfUpKKxdk8wILkUSenIvXUf_iEEB07zUhkkGXW6m2do-Q36tkMZStK0y7Z8pLRuW8a0Bzm)![](https://lh5.googleusercontent.com/KHOlpx-JCke0sHbKOWpV9jwkOcNZTg1AhBnnsNp9_FVg9exLe4XFuGyEbOIhrh-sy0dpc_2ABQOPaUXW5hCjb6vuiKBD6w87N1NGRkI_hMSjRqauGiLnupAb75atEMgmvgPJQ0jGvV1748gq8XM5SDqht4FkXeum4R5hFZCTI1iJ3PiOkeNymn-H9CRn)

Note that many of the channel dims follow roughly the same distribution, while a few have smaller variance and larger means.

This shows up as a heavy left-tail of the distribution of stdevs, and heavy tails in both directions for the means:

![](https://lh4.googleusercontent.com/i8Boz73WPDgFzQ28tAxTRB-LUbgxHrfc_DNNid2GhWEqnQnBeaWyFsg24z9gOhor02AD2URZZ2TltqH_X5PXJs7K-Kjy4xcVQnAW3slheQ86j1-GTN3lWHZ6-XJ0V2NKrgjWYhjYPbp3loSrljoN57x9JI5xflVLlTY9fZ2sToTM714wuK_GF918agLG)![](https://lh6.googleusercontent.com/bMbmh4UVVIh3p2_H2P9kTRnGAZFNvhHpMyXFFZf93cWAGltpKNrR28mYEt7f3N9zETUEFqHjCGnaq6gMItGrJLcAzJVNDFr1mh758fosEpy9ANELSLusIzFlCscCoPUN4ogdQko15qaW7a3gxUJpgU-WLUM8K2qTYif3HVPIKh3H1xxXnVU5zvxNO3Bj)  
  
(In these plots, I’m taking the stdev/mean across the 50,257 token dims, then showing a histogram of these 768 values for the 768 channel dims.)

Seraphina Nix guessed that these weird high-mean, low-variance dims might be where the *position* embeddings are most active. As it turns out, there is a very distinct cluster of channel dims where the position embeddings are doing something, with the rest of the dims being near-zero:

![](https://lh5.googleusercontent.com/eNhu-Avb653dVsTfCi6r88RhP1gdKQwfVoaotqsWrVXj9AiLQu6GRoSt_weTXQ7Py5iD9CmTA23FgUlBkpVEIiOpWgcEoAiF_NIa1bHaB4z2Qz74oTWWWEaYtvm0Dx8NWW8PKq74xmk7tRdsmP61SzodrVKemOIyCqR2EMkQSQk1aYoF-1bvtb2vVexf)

(Log scale for readability. This time, we're taking stdev across the sequence positions for each channel dim, then plotting a histogram of the 768 values obtained that way.)

I’ve made a big plot of means and stdevs of token and position embeddings, across the token/position dimension, for each channel dimension (next page).

![](https://lh6.googleusercontent.com/uoMWs7BEk0RLbnDGb8UEBCRInAVDiSvk6eH2Lf9sSy44yAB1DU8A-IQEgbwDMcOkRnd8KIkrei8N6xozVNh1ftkpcoOMp13UhTbDxLsa_KI4vKhRDBbVlIABCZ2TLoh9WP4Ye8--QzzHvYgCNF6CRIBefm3a3r9__hwUfAW2f1JwWDyzO9ypdszHugQS)  
I chose std(position embedding) as the x-axis, so the left and right clusters are "not much position-embedding activity" and "lots of it" respectively.

Some things you can read off the plot:

*   The low-std (green) and high-mean (blue) token embeddings are mostly in the cluster of channel dims with high-std / high-mean position embeddings
*   Position embeddings are consistently centered near zero, i.e. their means are a bit smaller than their stds (red < orange). The “normal” token embeddings are centered near zero (blue << green) but the “weird” ones aren’t (blue > green)

Here are some scatterplots of token (black) and position embeddings (red) for randomly-chosen pairs of channels dims. There are 1024 points in each red scatterplot, one for each position, and 50,257 in each black scatterplot, one for each token.

![](https://lh6.googleusercontent.com/RmLGs4Jfd8QN70gHL6IkvVW4iffMAnWpAMEoPQ2O7EYZA92jdOtM2j6ISycA8KLpNDQrxGemsbLWuOoQRtVjT9uOlZTlC9hWRJKd3L0e6_U8_qUfU9o3mKJ9oZ-togE4dTFNtfajuscU7b1lOB2Gs0_iKjhMTNMomZoT4ljzeYj96AxNigXfoi8Z3_1W)![](https://lh6.googleusercontent.com/pDqUYsKYbV7WUo29tjz8hCfHEAtztnV2cmQRxAwfl6jKqFSbDk9Id7cfzPpXrkkk3c1Y_imDlDwqegizRxMalV5IXoPDepog33w7uwIKpHnbIOwX_S1u5BXGXbIt-NPARtjp828Vd2_9fhcaRRj6IBZJVGA9j-Cz-J28_DmcIOWHlDPi4jA-TQpFXwmp)![](https://lh3.googleusercontent.com/X67_LhNvX772Zjy3oGHmAfSsf0w0eci1ecZA7YMm3j6OMsjm2RUQ0Ba1Umjkxz0hwcnae-RpGeX2YXXHtg534PXvm3SiaOg2Fha1wbf6LoSTIj6vmd8MG44QNUBlwIU0LTAIuK3LQjHWJtqj8JBZBUWY1U8EnK2SzOMWi9KhqNKWCm8gK3X578vhik1z)

Left: both channel dims are “weird” (high position-embedding variance)

Right: both channels dims are “normal” (low position-embedding variance)

Middle: one of each kind of channel dim

I don't quite get what's happening here. The token embeddings do seem to be avoiding the channel dimensions used by the position embeddings, by putting less variance into those dimensions, but not as much as they could. I don't understand what role the nonzero mean on those dimensions plays. As we'll see later, the direction of latent space parallel to the mean token embedding seems to be pretty important to the model, so it is interesting and confusing that the position embeddings overlap on many dimensions with the token mean!

In other news, note that the position embeddings look a little like Lissajous figures.

Position embeddings themselves look like this (as a function of sequence position):

![](https://lh5.googleusercontent.com/vlyqOUJOm9G4Fn-VQcGBGMKKEKh4FUdi0S9JJLiiKGWMLRtazK5cWyYUdBVSUmaro_iqeP6fxH4FkISz8V-89s3e_niZyeJvAfJ0BJW5nBPQhmWZKhulEb9zgDGYiBn5xbgDJ2YYrH-jR8Yqwhi67PUHEDxYL9sUQI0f1iJkYityTr45cDIR017fV_pM)![](https://lh6.googleusercontent.com/7mvvIBNtO3BX-wtnlv9H4uPXZVBYwyrG1JSOUTmbM8CqOHDHarCwQHYXJKBmy7d7VtsTingcBLRXdRVuZ6JVNqzGSuQN6_4-m_v80Lkvy0UZynfgX0tm4efs1KUrC47IqAla5_IlGMGNPDmcN3RBB2C-CHacvLtct2XxpJLQutDQ5RTLmtkWr2FGRHST)

A few low-variance ones are shown separately on the right, with a finer y-axis scale, since they’re piled up at y=0 on the main plot.

It looks like the position embeddings have mostly learned something vaguely sinusoidal, or maybe a bit more triangle-wave-like than that. This makes a lot of sense in terms of producing a smooth but precise representation of position. (See also: grid cells, etc.) 

It’s not obvious whether the fuzzy “noise” in the position embeddings is in fact noise; a fun experiment would be to smooth it away and see if the network performs any better/worse. It would also be interesting to see if the low-signal-amplitude position embeddings are necessary for good performance, or if they're disposable.

Gain parameters in LayerNorm
============================

In all these plots, the x-axes are log10(std(position embeddings)) and the y-axes are log10(|gain|). As above, we have one point in the scatterplot for each of the 768 latent-space dimensions. There is one gain parameter "w_i" per LayerNorm for each of those dimensions.

There are two LayerNorms in each layer: LN1 and LN2.

“LN1”, before the self-attention layer:

![](https://lh6.googleusercontent.com/m6LOo0-Ahat8KU2E9XQMw8iogVw4O1xmbmlSU-gFb7M-1fOPnyhr_bBt80CW-yTsHFN0LW5mxT7-Rh4leyeDJ0cUlp5VfLyPirvGFML4LyaERupGy1kdNqDlu6n0qJvMI3Se6J7kJoHLm6wGV9HK3KArIe5ulFiYe98dTsYJ2rmzmjc8nL-IT1fc7rnr)

“LN2”, before fully-connected layer: (not log-transformed on Y for some reason, sorry.)

![](https://lh5.googleusercontent.com/UDW5GTuYJryLWvbdSkc5_UNtkv0YZPEJWESU9BgdKrgHt1XOMCuu-L6guSiR5ZfjUi50N6Y3AgrMgPJbM-OXLM0Qzypep44sa6dnTrT4aTc0kv0fDreiVcjbjM8N0w-fSXGIcLlmfX8ZrlsQ5QCBx70VOZ7XywyTlPJfIXVhnKA_9JzQc0jKhfYtgj3D)

Note that the layer-0 gains dial down the position-heavy channel dims (the cluster on the right) but then the later layers mostly just mess with a few outlier points.

Dimension 138, the unigram neuron?
==================================

Here’s a few LayerNorm (LN2) layers colored arbitrarily by channel dim:

![](https://lh6.googleusercontent.com/UX6KSjSWD6plsi8K1_39T9JlaqeDi72MJ0lW_2eXwBWAJpmS5C9MEVeJPxC5SlQoFWTK2Rc45-G-VTYSlLg4ZUyxjOd7cQYNvfFNy1pCg2CLgyZqePLfILHpq0icCKC8n1VBQjD4v4N9NcVezR70ja70JSTtEzDelEytoCyyV_zY5Lu3wrqc3DonGCLR)

(The plot titles should say “LN2”, not “LN1”.)

What’s that pale green dot way up there on the left? It’s dim 138. It looks like GPT-2 wants its fully-connected layers to pay attention to that dimension.

Dim 138 is higher for tokens with short embedding vectors. This scatterplot has a point for each token:

![](https://lh6.googleusercontent.com/c_ZwAiifekUJnCfuGRNNn3dTH3C2sHElKf75-xJn4fue1b7-gnRJnWYvWVlWxdyWbp9_3fZfYMte7Awh4iFtWYMPTWTYgfPh6DLucjBD3A7NBuyiIkbZsQ35fXWhARkIravaCcG-bDTIUKqVMjmskk-aMVYM60dwg5KSu4XKJ5418bEULGmcL_rgdoCh)

(See that bright green dot on the island at bottom left? We’ll come back to that.)

By the way, most channel dims don’t have a correlation like this, e.g. dim 137:

![](https://lh6.googleusercontent.com/_0kgOWpuYeFtGmCVjpnKLNs-rEc4RuEpSFKBEdWclA2liO6zHsjHFUb47TO-l26AGATAqTSrVXtSCzS4ESVKHfDm1JvBL1ut3rdIM8yKDQ2BaJ8w7bST0dfigBP3iklUl2hnhvajsruKj-8Cie_34N-TL0ZBEUIC_pWUtp4L78LmI0IML9it-uMTbJY8)

Also, dim 138 is higher on earlier tokens in the BPE vocab list:

![](https://lh5.googleusercontent.com/JZYi2nSFlEWwfLf1_tNcDM6Z49UyLU2uz8eyMi13LWr0CpAAIGettzrQ1pgEqi6IpAsIle3J8PbNqyqB7sjYUH41XByy8vahujGS7lsJMubCuSRG_ZIOaL5s9XdAPcxLngzkBRlkfpziaYqL4LwdWrAEZdj1R0FfDURHycwqA1rGaf1H1OQWtAFMY5id)

These are both probably proxies for frequency in the corpus. (This is obvious for the token index, since BPE will add more common tokens first, but less obvious for embedding-vector length.)

This is OpenWebText data because it’s publicly available, but GPT-2 was trained on WebText which is a little different. Thanks to Noa Nabeshima for getting these token frequencies:

![](https://lh5.googleusercontent.com/Kswj3bOaMeENxluyZj3hZnFO9RH0Xso9HfhgJk3Fyt-PJpLEHbsI3ztBL9tFD4bA4wEpYPvypHrRPryYX-T4LdlrivUYvHtCAyP4Enk41hlcDsrDeFfILr4obLxbaHgVO9-CRC51Rtd3Ray-ooWd0ZcJeml1WFEr7-rHapfpP34R6zvOhnIDHVkTg7eM)

(What are those few outliers that buck the trend? The loose cluster of five to bottom-right are (UTF-8 fragments of) smart quotes, and the column of dots at top-left are…. Chinese or Japanese names of dragons in the popular mobile game Puzzle & Dragons. I’m tempted to put this down to differences between the contents of WebText and OpenWebText, and/or how they were processed. I figured out the Puzzle & Dragons thing by querying GPT-2 with the mystery tokens, but in the future it would be very cool to figure this sort of thing out directly from the weights without running any inference passes.)

So what does this tell us? Probably dim 138 has some special purpose in life, since it gets cranked up by the gain parameters in many layers. One guess is that the model makes predictions by adjusting a “zeroth-order” guess for each token, which is just the frequency in its training data, and 138 is where this guess lives. But this would be a great thing to look at within attention and MLP blocks to see what the model actually does with dim 138.

Another thing about 138: it has very little position-embedding presence, but the token embeddings are still very “off-center” (mean far from zero), which you can even see visually in the scatterplots. Also, it’s especially high-variance even for a “normal” channel dim. In the complicated "summary stats" plot of token and position embeddings, the upperleftmost blue and green dots are for dim 138. I think the nonzero mean here is related to the asymmetric distribution of log(frequency) for tokens: dim138 = 0 is near the middle of the scatterplot, but the lower half has far more tokens in it.

Also, it's worth noting that more common tokens have shorter embedding vectors on average. Noa suggests that longer vectors are more salient because they’re rarer and more information-rich. This is plausible, but kind of conflicts with the similar theory for dim 138, because 138 and vector length are only somewhat correlated. So we have two candidates for a "unigram frequency feature" in latent space, and soon we'll meet a third (SVD0).

One detail to keep in mind is that the overall magnitude of channel dims is only directly relevant in the identity path, and gets layernormalized away inside residual blocks.

SVD combinations of channel dims
================================

The embedding matrix has entries W_ij = \[channel dim i of the embedding of token j\].

We can decompose this with SVD into $W_{ij} = U_{ik} S_{kn} V_{nj}$, where S is a diagonal matrix of singular values and U, V are orthogonal matrices.

The first few rows V_nj for n = 0, 1, 2 are essentially projections of the embedding vectors of tokens onto the directions in the embedding space with the highest variance. (This is equivalent to running PCA on the channel dims.) These turn out to have useful properties!

SVD dim 0 is almost exactly the direction through the mean of the token embeddings. (This is because the mean vector is much larger than you'd expect for normally-distributed data.) Since the channel dims with nonzero mean seem to be the ones that are competing with position embeddings, it's possible that this SVD dim separates tokens that overlap a lot with position embeddings from those that don’t; I don’t know what that would imply semantically about those tokens. 

The way I computed it, SVD0 is negative for all tokens; this doesn't mean anything.

The longest/shortest embedding vectors tend to also be extreme on SVD dim 0, which makes sense, since larger (more negative) SVD0 directly contributes to the vector norm. I haven't checked whether the effect is stronger than you'd expect from that.

Channel dim 138 also contributes a lot to SVD dim 0, so we now have *three* plausible candidates for the "frequency feature", which correlate with each other by varying amounts:

*   Dim 138
*   Embedding vector norm
*   SVD0 (≃ token mean direction)

(Note from 2022: Ideally I'd have more numbers about the correlations here, but I'm prioritizing publishing this over getting my ancient code running again.)

SVD dims 1 and 2 show a clear bimodal distribution of tokens. These two clusters turn out to be the tokens with or without initial spaces!

![](https://lh5.googleusercontent.com/fUNM7OKcS5x0gMW-zU4L4jt0XsJAX3UUJZLfBJgh8wUPAnd5FA6BEkvRZ9ptb1dx7rAxmVGwdgOPtDALHtP9Lar_ktCDh8Yi3Q6AswmdMnX8YmgtpAc1PMlUokE4oj8NSrDxFH_cbo0UqlK03MfYDURVdVHe94-oWi6oL2_FxJgFRRpYSC0XYEij1jyA)![](https://lh6.googleusercontent.com/RCK0-4Npe9BGP4h8a5nxMs6Aq0ECpGXdBoDiYEnyDhnLG6RMmymjJwipS5txGAR9Rx2ef4wc6QTfWV1Jf61jZexq3SGkDgfTj5biI0Oakrky-K6ZMQ3OWKuqwTnkoBZeuJ9CjvkhQutyVcM4pe27ujdyVPWFq9jVexZDNpp1IBiqZCoNKQ2y-rjblPTq)

The plus-sign in the scatterplots marks the origin.

![](https://lh6.googleusercontent.com/AN6BtNeyLbmfz4PO4cWAslEZFlo0W-nMZIYzPBNcjdeDksOZjXLDjiElzrOitLWm-eoTpaY6rt7GtOT4rfIClQmsbgfolUWNchVHa6LKMANb-EeRNv3lZi2SS5sh1DtJO_VjxcVPeydSuhsui8SyNA38DA2q9-FjZS8scbHGE0XHQKZ-UoUmll-xiyzI)![](https://lh4.googleusercontent.com/XcDQjZ_I7jxwLtYEtRSdEodIMu443mHi3t-SOUZkYmnf7xrZSokWXdKcefuTwzeMVRAfCSCtmJAZYGqHiYGWLZ5CDsTXnHEgrXhMVKLlXYynv4V0TBscPivmk0TiSJetv0uPLdMkowpLUg_H7Im30hQqeXjztiZkxzDOG27EvfIPu3ODxdFyncswRQ7y)

Weird outlier tokens and zero-layer GPT-2
=========================================

While digging through the embedding weight, certain tokens showed up repeatedly as outliers on many axes. It is not entirely clear why they group together the way they do, but I have some guesses.

I first noticed these outliers while trying out a zero-layer version of GPT-2, just to see what would happen.

GPT-2 without any of its residual blocks is equivalent to W^T W, where W is the embedding matrix. This is symmetric, so it can’t even do bigram statistics properly, unlike transformers with separate embedding and unembedding matrices. It still has position embeddings, but we're going to ignore them. Also, since GPT-2 is obviously not trained for zero-layer performance, it’s not clear that it should do anything interesting in this setting anyway. Nevertheless, we're going to ask the question: what does zero-layer GPT-2 output, when given various tokens as input?

Note that the entries in W^T W are the dot products of the embedding vectors of tokens. If all embedding vectors were of the same length, then the largest value in each row of W^T W would be on the diagonal, so the highest logit at each output position would be for the token at the corresponding (shifted) input position.

In practice, almost all tokens follow this pattern, but there are exceptions. (In the images below, the tokens on the left produce the tokens on the right. I’ve left out additional examples of unprintable bytes – the question-mark glyphs – and of initial-space-removal.)

![](https://lh3.googleusercontent.com/drB5cJlh2pa4xJ4ajIA8Q0vCVYPp5hfyr6N8Ke-nwyQ0vAKsMU9bRIatMs6NrutvAUOHFHVRSv-Zmo6fXkCWIAuEnO3-TH9HtPYGUJau_7FDoQmoUZWf2JdOctQhDn95FiWxmowKt98lqLmPl0e7rPzRIty1qoPJz04B0CwZTq7xtN5ntuPvxpnc1z-4)

![](https://lh4.googleusercontent.com/70g4Y1HsLZGCuxlCXGSsjcC_o_VPzkkzdvK4uMo3TTJ_WzHKrGiRN8mvggSCv2NVBkHMWwODEvqT1-DACgANAH5RbUv_7cBW8PaSY6RA164yolpZsexS2CJvweYPToSqa0BY10Sv91nEnbrk-AhD2310VfbJNcvBwFyc3eyVlrb9QohvEF8mBi1qZmwF)

![](https://lh5.googleusercontent.com/i_Eu714V80fOzdZokVObpDxwG2hgkmeZx_crd8mOof8z-lC8PWw5NzmQRiguJopQKucaoLTSA1PYgIzRzUdQOIUMSGlxQBP7A3Oks1eEFpZjTksPjYFowE3d1zX2EtaoZGooHb4aCNvtGhW2wbI1hPklMw3woqSJlr99nyrQ5QjJdWpzdrfFfb7cTOWJ)

These token pairs (u, v) have embedding vectors that are nearly parallel and significantly different in length, |u| < |v|, such that (u . v) > (u . u).

For the space-removal case, this can be explained in terms of two facts:

*   The tokens with and without the space have similar embedding vectors, presumably for semantic reasons.
*   Tokens with spaces are smaller because the vector between the initial-space and no-space clusters is correlated with the mean of embedding vectors (SVD dim 0; see above).

The other cases are more confusing. Notably, \`BuyableInstoreAndOnline\` – the longer vector in many pairs – is one of the top-20 tokens by embedding vector length. It is also one of the five lowest tokens on channel dim 138. Per the results above, both of these properties might indicate that GPT-2 thinks this token is very uncommon and/or interesting.

Many of the confusing cases look like machine-readable text (from HTML/CSS/Javascript presumably). This seems consistent with the unprintable bytes, which *could* occur as part of a Unicode character in UTF-8 text, but show up more frequently in binary data. There might be accidental binary files in the training data or the data used to construct the tokenizer. (Also, many Unicode characters get their own multibyte tokens, so they wouldn't appear as individual bytes to GPT-2.)

\`conservancy\` is a surprisingly normal word. Maybe it shows up a lot in some sort of machine-readable text? One clue is that \`natureconservancy\` has one of the longest embedding vectors of any token. It seems to be part of the URLs of images on the Nature Conservancy’s website; I have no idea why GPT's tokenizer saw so many of these. Querying GPT-3 davinci at T=0 with \`natureconservancy\` yields this image URL, which is functional: [http://natureconservancy-h.assetsadobe.com/is/image/content/dam/tnc/nature/en/photos/tnc\_12681454\_4000x2200.jpg?crop=0,0,2933,2200&wid=300&hei=225&scl=9.7777777777](http://natureconservancy-h.assetsadobe.com/is/image/content/dam/tnc/nature/en/photos/tnc_12681454_4000x2200.jpg?crop=0,0,2933,2200&wid=300&hei=225&scl=9.7777777777)

![](http://natureconservancy-h.assetsadobe.com/is/image/content/dam/tnc/nature/en/photos/tnc_12681454_4000x2200.jpg?crop=0,0,2933,2200&wid=300&hei=225&scl=9.7777777777)

GPT-3's favorite nature photo?

\`BuyableInstoreAndOnline\`, sampled with GPT-3 davinci at low temperature, produces things that appear in the HTML source of David’s Bridal item pages. Usually that's metadata for clothing items, including product IDs, color options, etc. GPT-3 especially likes this dress in Teal Blue: [https://www.davidsbridal.com/product/short-sleeveless-all-over-lace-bridesmaids-dress-f18031](https://www.davidsbridal.com/product/short-sleeveless-all-over-lace-bridesmaids-dress-f18031)

![](https://img.davidsbridal.com/is/image/DavidsBridalInc/Image-F18031-10569356-TealBlue)

GPT-3's favorite dress?

`ÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂÃÂ` is a sort of “eigenstring” of text encoding errors (mojibake) – it grows exponentially when encoded and decoded with different character encodings (usually Unicode vs. “ANSI”). You can see it in action here: [https://paperbackbooks.com.au/p/children-s-ya-howl-s-moving-castle-fti](https://paperbackbooks.com.au/p/children-s-ya-howl-s-moving-castle-fti)

Many of the short vectors in these pairs have fairly similar low values on dim 138 and extremely similar short embedding-vector lengths, although neither of these properties are at the extreme tails of the token distribution.

Note the clump at bottom-left of this scatterplot:

 ![](https://lh6.googleusercontent.com/8znjqdubFWZ8eLJBIHN6n0qMPMIz19cuw7S5QKuG4EZ29eJFI2x-nzopL2t6WL41i-HoTJjIGPK-YfGM--x0vUe2T4rXfyP2GSFFitxbvMxk1SsFOf2tP1RyweRp2WFXJTbbsQg2ux08Iz8gsxBZcZ-r6iB0A-Hb_tGKGFHecrVW9brr4q4RD9hzzuMs)

Zooming in and labelling the clump:

![](https://lh5.googleusercontent.com/N6kU59Ib9p3EpRJ6qBBvQXdRjU5_Aj-csW1HWqMM1KxZ-1FCU3tj6hCslYCTz0xh6dp0aRvoju2J74bLFVB-ksTQs4Y08T7gngSfo0J8K9pO_UJpT2TY3IIH3gSFXVaGUE6STUUNXQ3Y5zNHt6Xr0pq32149GhQovCMDnKQ3EZ3VwU6tm9Nqjf4Bjwd1)

My best guess is that this crowded spot in embedding space is a sort of wastebasket for tokens that show up in machine-readable files but aren’t useful to the model for some reason. Possibly, these are tokens that are common in the corpus used to create the tokenizer, but *not* in the WebText training corpus. The oddly-specific tokens related to Puzzle & Dragons, Nature Conservancy, and David’s Bridal webpages suggest that BPE may have been run on a sample of web text that happened to have those websites overrepresented, and GPT-2 is compensating for this by shoving all the tokens it doesn’t find useful in the same place. (This is somewhat contradicted by the fact that GPT-3 davinci is perfectly happy to spit out coherent URLs and metadata when prompted with them, but that could just be because it's bigger and can afford to care about really obscure tokens.)