Strangers in a Latent Space
the analytical engine has no pretensions whatever to originate any thing
it can do whatever we know how to order it to perform
it can follow analysis
but it has no power of anticipating any analytical relations or truths
its province is to assist us
in making available what we are already acquainted with
notes on the analytical engineada lovelace
Moving points
3

Moving points

chapter three
Science is built up with facts, as a house is with stones. But a collection of facts is no more a science than a heap of stones is a house.— Henri Poincaré, 1902

Counting symbols has taught you quite a lot about language models and the way texts behave, but the simple approaches you have tried have reached their limit - and the limit is just a few symbols! And yet, you remember that chatbots back on Earth were easily able to read entire books. To make progress, it is clear you will need novel ideas.

As you keep walking in circles in search of answers, you start feeling trapped by the walls of your spaceship, and you decide to finally open the hatch and take your first tour outside. The door opens with a hiss onto air that smells of dust and rain, and ground covered in short, pale grass. Still, so obsessed have you become with scaling your models that you almost fail to notice the weird colors surrounding you everywhere. You just keep going and going, until you realize that the alien sun has gone down and the sky is now pitch black. You look up, trying to get your bearings, and you notice for the first time constellations of alien stars and planets slowly drifting across the sky. Still deep in thought, your subconscious starts playing tricks on you, and for a moment it is the alien symbols themselves tracing the same paths in the sky. As you watch them move, a weird idea starts to crystallize in your head, and you remember something people called neural networks.

Running back to your ship and your computer, you pass by a side corridor, where a control panel with a big red button labeled “self-destruct” shines in a box. Overtaken by your desire to test your ideas, you resist your natural urge to immediately press it.1

3.1 Learning is not memorizing

Why do we need so much data to scale the models from the previous chapters? To answer, consider again how our simplest model from Chapter 1 “learns”: any time we observe a certain pair of symbols, such as th, the only action we take is to increment the counter corresponding to “h follows t”. The effect of this operation is to slightly increase the probability of selecting h after t when we sample using the model, and, correspondingly, to decrease the probability of selecting any other symbol after t. Our bigger models are similar, except that we consider slightly longer sequences of symbols.

However, in general we will be able to see only an incredibly small number of all possible sequences of symbols: for example, remember that even after reading 17,600 pages of text our biggest language model had seen fewer than one in five thousand of all the possible sequences of seven symbols that can be built using our alphabet. The number of such combinations grows exponentially every time we add one letter to our context, and while it is true that a monkey typing for an infinite amount of time on a computer would end up at some point writing Hamlet,2 it is also true our lifespan is definitely not infinite!

While I try not to lean too much on human analogies, the way humans learn is clearly more sophisticated. If I tell you that “the color of the sky is blue” and “red is a color”, you immediately know that the sentence “red and blue are colors” makes sense, even if you have never seen that sentence before. This has nothing to do with pure sequences of symbols, as it requires you to isolate a new concept in your head (the idea of “color”), to tag both “red” and “blue” with the new concept, and to know what a logical connector (“and”) is. There is nothing in our n-gram models that would allow them to make any prediction even remotely resembling this.

As another example, suppose we are shown some simple arithmetic problems:

1 + 1 = 2
1 + 2 = 3
1 + 3 = 4

The way we can use our language models to solve these problems is to feed them the expression up to the equal sign, and ask them to predict the solution as the most probable next symbol. For our simplest model, based on pairs of symbols, all these problems are identical, since they all end with “=”: the model would always predict the same solution, corresponding to whatever symbol is most common after “=” in the training data.

A model with a context of 4 (the 5-gram model, ignoring spaces) is more subtle: if the previous three expressions were present in the training data it might be able to give us the correct answer, but it would automatically fail on a new problem like “1 + 4 =”. The reason is the same as before: it is incapable of abstracting away the logic behind the concept of summing two numbers. The idea of being able to make predictions on sequences of symbols we have never seen by relating them to other sequences we have seen in the training data is called generalization in AI. Thus, the core problem of the models we have built so far is that they are extremely poor at generalizing, or outright incapable of it.

3.2 Gravity, our friend

To see what we mean by “generalization” outside of language, let us go back to those planets drifting across the sky (Figure 3.1).3

Figure 3.1 Two planets (the heavier in blue) move under the influence of gravity, curving toward each other. In gray, where they would have gone without gravity.

Each planet attracts the other one via the influence of gravity, which bends their paths and determines their position after a while. To predict their movement, we could record where they start and where they end every second, then look up the answer whenever the same starting arrangement appears again (Figure 3.2). However, this approach has the same issues as the language models we have been building: change even slightly the positions or speeds of the two planets, make them start in some place we have never observed, and we have no way to predict their movement.

Figure 3.2 Look up at the planets and note where they start, how fast they move, and where they end up a second later: does this remind you of how we built our previous language models?

Back on Earth, scientists take these measurements instead to build laws of the motion of the planets that work universally.4 For example, Newton’s law states that the pull between any two planets grows in proportion to their masses and falls off with the square of the distance between them (if you really hate math, quick, close your eyes! It’s the only equation outside of boxes, I promise):

F=Gm1m2r2F = G\,\frac{m_1\,m_2}{r^2}

Here m1m_1 and m2m_2 are the masses of the two planets, rr is the distance between them, and the constant GG must be measured by experiment. Given the planets’ positions and speeds, a computer can use this law to work out where they will be a moment later (Figure 3.3), and then it can repeat the calculation to follow their paths over time (Figure 3.4). With three or more planets the situation is similar. On its own, a planet would keep coasting in the direction it is already moving (the gray paths in Figure 3.1). At the same time, every other planet pulls on it according to Newton’s law, and the simulator adds up all these forces to determine a single net force that bends its path.

Figure 3.3 A simulator for three planets. Given where they are, how fast and in which direction they are moving, and how heavy they are, together with GG, it works out where they will be a moment later based on the laws of gravitation.

Figure 3.4 The simulator of Figure 3.3, run three times in a row using the predicted positions as starting points. Faint lines show the paths of the earlier steps.

Suppose we know the formula for gravitational attraction, but we do not know the value of GG. Think of it as a knob on the simulator which has been left in a random position. To find it, we take our records, start the planets in one of the positions we measured previously (together with their measured speeds), and see where they end up. Their distance from the observed positions is our error (Figure 3.5). We then turn the knob a little and run the simulation again. If the error shrinks, we keep turning that way; otherwise we turn back. Repeating this over many observations lets us find a value that predicts their motion well (Figure 3.6). At the end of the procedure, we have learned the constant GG only by looking at examples of the planets’ motion.

Figure 3.5 A light red planet flying past a much heavier blue one (which barely moves), simulated from a recorded start with a wrong value of GG. The cross marks where the real planet was observed; the dotted line is the error.

Figure 3.6 Learning GG. The same light red planet flying past the heavier blue one, simulated from the same start with the knob GG in three positions (left): each time it ends closer to where the real planet was observed. Turn after turn the error shrinks, until no turn helps anymore (right).

Now suppose further that we do not know the formula either. For instance, we do not know that the pull depends on the masses, or that it falls off with the square of the distance. In this case we could choose a much more flexible formula, with thousands of adjustable constants (knobs), each controlling some part of the pull. If we set all knobs in a random position, the formula would describe very strange physics (Figure 3.7). However, the previous “game” still works: we run the simulator on recorded examples, measure the errors, and adjust all knobs a little bit. Working out the right direction for thousands of knobs at once sounds insane, but luckily there is a powerful mathematical technique we can use to compute the correct change automatically by tracing the error backward through the steps of the simulator (see the box “Going downhill”).

Figure 3.7 A flexible simulator with many knobs (five shown). With random settings it produces bizarre physics (left); after tuning on recorded examples, the same knobs recover the smooth gravitational path (right).

If the formula is general enough and we have enough measurements, the knobs will eventually settle on values that predict our observations well. And since what we end up with is a law (implemented inside the simulator) and not a table of measurements, we can use it on configurations that we did not see previously, just like we were able to do with Newton’s law. However, this time the law was worked out just by looking at examples of the motion of the planets! Hold onto this idea before we go back to our symbols: instead of a lookup table, a simulator uses tunable knobs to decide how to move points, and we can tune those knobs automatically by looking at many examples and moving them until the simulator works as expected.

How far are the planets from where we want them? Adding up the error (AI people call it the loss) across all recorded simulations gives one number, L(θ)L(\theta), that says how bad our current knob settings θ\theta (“theta”) are. We want the setting where L(θ)L(\theta) is as small as possible.

Suppose we have just one knob, like GG in Figure 3.6. Plotting the error L(θ)L(\theta) for every setting gives a valley-shaped curve: too low or too high gives a large error, and the best setting sits at the bottom of the curve. At any point on the curve, the slope tells us which way is uphill; mathematicians call this slope the gradient (as in “the gradient of a steep road”). Taking a small step the opposite way moves us downhill toward the lowest error:

With thousands or millions of knobs we can no longer draw the curve on paper, but the same rule works for every knob at once and is called gradient descent:

θnew=θ−η×gradient of L(θ)\theta_{\text{new}} = \theta - \eta \times \text{gradient of } L(\theta)

Here η\eta (“eta”) is the step size, called the learning rate (too small and the walk crawls; too big and it jumps across the valley). For neural networks, backpropagation computes the gradient for all knobs at once by tracing the error backward through the network; it was made popular in 1986.

3.3 Neural networks (finally)

We now return to language modeling and see how the analogy plays out in this case. First, we need to replace the planets with our symbols: we associate one position with each of the 27 symbols in our vocabulary, and we place them at random on the plane (Figure 3.8).

Figure 3.8 The 27 symbols of the alien web, placed at random on the plane. The same symbol always starts in the same place.

Unlike planets (which can be anywhere in space when we look at them), we assume that each symbol can only start from a specific initial position that depends on the symbol itself. To make things more interesting, we can treat these initial positions as additional knobs to be tuned. A sentence picked at random from one of our texts, then, can be represented by placing the corresponding symbols on their assigned initial positions as in Figure 3.9.5

Figure 3.9 A short sentence from the alien web (top). Its symbols are the “planets” of one simulation, each starting from its place on the plane.

What “forces” drive our symbols to move? As we mentioned above, since we are not bound to replicate real physical laws, we can create complex laws with thousands, or millions, or even billions of knobs to tune, so that we may be able to learn any kind of “physics” that governs the motion of the symbols. The simulator, and the description of the forces experienced by the symbols inside it, is exactly the neural network we have been hinting at from the introduction.

To make the analogy more realistic, we should mention that in neural networks each step of the simulator gets a different law, each with its own knobs (this would be similar to the amount of gravitational force we experience changing based on how much time has passed since we started measuring). AI people call each step a layer, mostly for historical reasons (see the box “Where have the neurons gone?” at the end). As an example, the network we train at the end of this chapter has six layers and almost five million knobs. A sentence, represented in terms of symbols on a plane, enters the first layer and its symbols move a little; the result enters the second layer, where they move again under slightly different forces, and so on until the last one (Figure 3.10).

Figure 3.10 A neural network opened up. The entire network is composed of multiple layers. Each layer corresponds to one step of the simulator, with knobs of its own (three are drawn for each in this example). The places where the symbols start, on the left, are also parts of the configuration.

One issue with this approach is that each individual knob is very difficult to interpret on its own (compared to, say, explaining what GG is in the previous example). One of them may make a symbol feel a stronger pull from the one before it, but only in the third layer; another may push whatever crosses a certain corner of the plane slightly to the left. Whatever the network ends up knowing is spread over all of them at once; we will consider again the issue of understanding what is happening (and why neural networks are able to make the high-level associations we hinted at in the beginning of this chapter) later on in Chapter 5.

For now, let us turn to a detail we have not considered yet: what final configuration do we want our symbols to reach? This is simple: as in our previous language models, we want each symbol to end up close to the next one in the text (Figure 3.11). To make this interesting we need to add a small twist compared to before: inside each layer, we require that each symbol only feels the pull of the symbols that come before it in the sentence (otherwise the next symbol, which is in the simulation too, would simply pull it straight onto itself).

That one rule also makes training much faster. Because each symbol only feels the symbols before it, putting a whole twenty-symbol sentence into the simulator at once gives us nineteen predictions in a single run: the first symbol aims at the second, the second aims at the third, and so on down to the end.

Figure 3.11 Shown for the first symbol of the sentence (red-orange): it starts at its place on the plane and is moved by the neural network to a new position. The symbol that follows it is its target (ringed), and the dashed line between them is the error. The network does the same for every symbol at once, and we train the model to make the error as small as possible.

Every time we run a simulation we pick a sentence at random from our training data, use the neural network to find where symbols end up, and we measure the error, which is now how far each symbol ended from the next one in the sentence. We then turn every knob a little to make the error smaller (remember: the knobs are the constants inside the simulator along with the starting places of the 27 symbols). We repeat this many times, until we either run out of time or we see the knobs stop moving significantly. We will call the resulting language model a neural language model, to differentiate it from our previous counting models.

We plot one round of the simulation in Figure 3.12. After we compute the error and we move the knobs once, if we were to run the same sentence again through the neural network, each symbol would land a little closer to the next one. As an aside, note that we need to be careful not to move the knobs too much in each iteration of the simulation. For example, in this sentence t is followed by h, but in thousands of other sentences it is followed by something else, and a network tuned to perfection on one sentence would be useless on all the others. So we move on to a second sentence, then a third, millions of times over. Each one pulls the knobs its own way, and what we get at the end is a configuration that is best suited to most of them.

Figure 3.12 One round of training, shown for the first symbol (red-orange) and its target (ringed). Left: before the update, the symbol ends far from the next one. Right: after every knob is turned a little (gray pointers: old positions) and the starting places shift slightly (teal arrows; old places faint), the same symbol lands closer to its target and the error shrinks.

Notice that t does not simply get stuck halfway between every symbol that can follow it. In different sentences, the symbols coming before t pull it to different regions of the plane, so the same symbol can land near h in one context and near o in another (Figure 3.13). And when several continuations genuinely fit the same context, the symbol can also end up roughly close to each of them.

Figure 3.13 The same symbol t (red-orange) starting from the same spot in two short fragments, wit (left) and int (right). Earlier symbols pull it to different regions of the plane, so it lands near h in the first context and near o in the second.

The knobs and the laws they describe are what allow our neural networks to generalize. Our previous language models kept a separate count for every sequence of symbols, so nothing learned about one specific sequence of symbols helped with another. Here every sentence moves according to the same set of knobs (stated differently: we have a single law of gravitation, not a different law for every possible planet). Two symbols that tend to be followed by the same things are pushed in the same directions round after round, and end up starting close to each other. And since the law inside the box only looks at the positions of the symbols, whatever it has learned to do with one symbol it will also do with its neighbors, even in sentences it has never seen before.

Let us pause and summarize the whole process. From here on we will drop the word knobs and use the name AI scientists give to all these tunable numbers (both the starting positions of the symbols and the settings inside every layer): the network’s parameters.

  1. We begin by giving each symbol a starting position on the plane.
  2. We choose what goes inside our neural network, including how many layers it has and how many parameters each layer holds. This is called designing the network, and it is the subject of my previous book.6
  3. We pick random sentences from our training data and run them through the network, moving the symbols layer by layer. For each symbol we measure the error as its distance from the next symbol in that sentence.
  4. We nudge every parameter slightly so that each symbol lands a little closer to the next one and the error shrinks.
  5. We repeat the last two steps until the error stops falling. The network is now trained, and we can use it to generate text much like our earlier models.

3.4 Inside the simulator

Our analogy with gravity is actually more interesting than what we have described so far, so allow me to continue with it a bit more.

First, in the previous section we assumed that the simulator moves the symbols based on their position in the plane, which can be described by two numbers (the coordinates on the plane). The simulator for gravity was slightly more involved, because for each planet it needed to know its position along with its speed and its mass, that is, each planet was described by a total of five numbers (two for its position on the plane, two for its speed, and one for its mass). In physics, the set of numbers that describe each planet would be called its state. In AI, we prefer to call them embeddings (as in “the nail is embedded in the wood”). Real-world neural networks tend to have relatively complex embeddings, on the order of hundreds or thousands of numbers per symbol, which allows the learned laws of motion to be extremely rich. Visualizing something that travels in a space with so many dimensions is (for all intents and purposes) impossible (even the 4D space of general relativity can stretch our imagination to its limits), so in the book we will stick with visualizations over the plane.7 The network we train below uses 256 dimensions for the embeddings, so our pictures flatten those positions back down onto the page.

What about what goes on inside the box? The specific type of neural network used in most language models today is called a transformer. Although we cannot really go into much detail at this point without resorting to math, we can still say a little bit about it, since it will help us later on in Chapter 5. Luckily, it still fits quite well into our analogy!

Inside a transformer, each step of the simulator combines two moves for every symbol, much like a planet moving on its own while being pulled by all the others (Figure 3.14). First, just as gravity adds up the pairwise pulls from every other planet, each symbol is moved by the sum of pairwise forces exerted by all the symbols before it. Here, however, learned constants set the strength and direction of each pull from the positions of the symbols involved,8 rather than a fixed law of masses and distances: a relevant symbol far away can pull strongly while a nearby one is ignored. This is called attention, because each symbol effectively chooses which earlier symbols to pay attention to, focusing strongly on a few and ignoring the rest. Second, each symbol gets a push of its own that ignores all the other symbols and depends only on its current position (playing a role similar to a planet’s own motion). For historical reasons this part is called a multilayer perceptron, after Frank Rosenblatt’s perceptron of 1958, a machine meant to learn to “perceive” simple images. (In practice, each layer runs several independent sets of pulls in parallel, so one set can focus on the symbol right before while another looks much further back in the sentence.)

Figure 3.14 One layer of a transformer acting on the last symbol (red-orange) of a four-symbol word. Left (attention): the symbol receives a pairwise pull from each earlier symbol (teal arrows, thickness showing strength) and moves along their sum to an intermediate position (open dot); unlike gravity, a distant symbol can pull harder than a close one. In a real transformer, learned parameters set both the strength and the direction of each pull. Right (multilayer perceptron): ignoring the other symbols (faded), the symbol receives a solo push that depends only on its current position and moves to its final position for the layer (solid dot).

3.5 Testing our first neural language model

A neural language model differs from our previous language models in several important ways. First, we have a lot of control over the number of its parameters: we can add more parameters by, among other things, adding new layers to the neural network (i.e., making the simulation a bit longer), adding new parameters to an existing layer, or representing each symbol with a bigger embedding (more numbers to describe its position). Second, training on the same text multiple times actually helps, since every time we will move the parameters a bit more. Third, as we mentioned, neural networks can generalize to combinations of symbols they never saw during training, and they can easily handle very long contexts.9

To start with, let us train a simple neural network on our data from the alien web.10 Let us start from some sequences that our previous language models were unable to handle: we go through the hidden pages and stop wherever the last six symbols never appeared, in that order, anywhere in the training data. In all these places our best previous model was useless, since its table entry for that sequence is empty and it has nothing to go on. Our neural network instead guesses the next symbol right 46% of the time! This is the generalization we were looking for at the beginning of the chapter: the network has learned something about how symbols behave that still holds for sequences it has never met before.

On the hidden pages taken as a whole the two models are closer (Figure 3.15). Starting from random parameters, the network first guesses almost blindly, catches up with the 2-gram model after a few hundred pages, and only catches up with the 7-gram after reading the whole training set once. After one pass over the training data it is about as good as the 7-gram model (59%), and the second and third passes take it to 62%. As we will see in the next chapter, however, our neural network still has a lot of room to grow.

Figure 3.15 How often the network guesses the next symbol right on the hidden pages during training (three passes over the training data, about 53,000 pages in all), against two language models of Chapter 2 (gray, dashed): the 2-gram, which looks one symbol back, and the 7-gram, which looks six symbols back.

We can also show the learned starting positions of the symbols after training completes (Figure 3.16; compare to Figure 3.8, where they were initially placed at random).

Figure 3.16 Where the network starts each symbol after training, flattened from 256 numbers onto the plane so that symbols close together in the network stay close in the picture.

The network has organized its symbols in an interesting way. The vowels, a, e, i, o and u, end up together with y, next to the space; the common consonants fill the middle; the rarest symbols, j, q, x and z, gather at the far end. Symbols that behave alike end up close together, because they need to be moved in similar ways. These positions are not part of the training data but have been “discovered” by the training process, which is why scientists call the space where they live a latent space. Everything a network knows about a symbol is where that symbol sits in this space, and everything it does with a sentence is move its symbols around in it.

3.6 Generating text with our neural network

To understand how we can use our new model, suppose we start from a simple sentence, the sun is sh. We put the symbols on the plane, run the simulation (with all the parameters of the neural network set by our previous training), and we look at the final position of the last symbol in the sequence. We then compare its position with the starting positions of all symbols, and take one of the closest ones as the proposed next symbol (Figure 3.17). The closer a symbol’s starting position sits to where our last symbol landed, the higher the probability the network assigns to it. From there, generation works just as in Chapter 1: we can either pick the closest symbol every time, or sample at random according to those probabilities. When several continuations fit the same context, the last symbol lands between them so that each has a similar probability.

Figure 3.17 The sentence (top) goes through the network, on a flattened map of the same starting places (the symbols of the sentence in a darker gray). We follow only the last one, h, from its starting place through the numbered layers to its final position. The symbols closest to it, inside the gray circle, are the likeliest next symbols (closeness is measured in all 256 numbers, which the flattened picture can only suggest). The three likeliest: e 40%, o 28%, a 19%.

Like before, we then add the chosen symbol to our sentence and repeat the process to generate text of any length.11 This is the biggest difference from our previous models: where the last symbol lands depends on the pull of every symbol before it, rather than only the last few. The longest stretch of text a neural network can hold in a single simulation is called its context window. Our small network uses a context window of 128 symbols, while modern chatbots handle hundreds of thousands or millions of symbols at once, enough to keep entire books in view at the same time. Once a text grows past that limit, the earliest symbols drop out of the simulation and the model can no longer feel their pull (a limit we will run into again in Chapter 7).

3.7 Before closing

You go back to the driver’s question (Figure 2.8) one more time, armed with our first neural language model. Translated into plain English, always taking the likeliest symbol (the closest one) gives “and the stranger s head and then the stranger”; sampling at random in proportion to how close each symbol sits to the final position gives “around that t month and he glanced at this instant one of the”. Real words and, for a few words at a time, almost real grammar, but still no coherent answer. To get one, our network will have to grow much bigger.

Figure 3.18 A month later, you try again with our first neural network: first always taking the most probable symbol, then sampling at random (choosing each symbol according to how close it is to the end position of the previous one).

You keep walking every day, hoping for inspiration to strike again. One evening, from the top of the nearest hill, you see something shining on the horizon. You stay until the light fades. Back at the ship, the computer has finished its training simulations. For once, you leave the results until morning.

We haven’t explained yet where the name “neural networks” comes from. In 1943 Warren McCulloch and Walter Pitts proposed a simplified model of a neuron, a cell of the brain. In the 1950s multiple groups experimented with combining many such units in networks they could train to learn simple patterns (such as the perceptron mentioned previously). Current neural networks (a more proper name would be artificial neural networks) are descendants of these experiments, although they are vastly more complex: inside each multilayer perceptron, that individual push is still computed by hundreds or thousands of these small units working together. Because of their origin they have kept most of the terminology: the units are still called neurons, they are organized in layers; a network with many layers is called deep, and learning with deep networks is called deep learning.


  1. “What an incredible amount of foreshadowing”, the omniscient narrator mutters to himself in appreciation.↩︎

  2. See the infinite monkey theorem: https://en.wikipedia.org/wiki/Infinite_monkey_theorem↩︎

  3. The same curious reader from Chapter 1 will wonder how planets move so fast to be visibly drifting in such a short amount of time; we would too, curious reader, but we spent most of the time deciding on the shade of blue for the chapter covers.↩︎

  4. The Danish astronomer Tycho Brahe and his collaborators collected over twenty years of observations of the sky, which were then used by Johannes Kepler to build his laws of planetary motion. Curiously, Tycho Brahe’s own model based on his measurements still kept the Earth fixed at the center, like the old (and soon to be superseded) Ptolemaic system. I should mention that this footnote has absolutely no bearing on the content of the book, and Claude desperately wanted to remove it. Keeping it is however my way of asserting a short remnant of human control. I realize it might be too late to suggest that you skip it.↩︎

  5. I should note briefly that the analogy between planets and symbols is not perfect: first, each symbol in a sentence also has a specific position in the sentence (for example “e” in “the” is the third symbol, while in “beat” it is the second), which is lost in this visualization. Second, symbols can appear twice, like t in “the cat”. Adding these details is feasible but would be very confusing, and the gods of analogical thinking are already very angry with me.↩︎

  6. Alice’s Adventures in a Differentiable Wonderland: https://www.sscardapane.it/alice-book/↩︎

  7. One practical limit of our visualization is that you shouldn’t draw too many conclusions from them. For example, 27 symbols on the plane look like a lot (Figure 3.8), but 27 symbols in a space of one hundred dimensions would probably be more like golf balls spread across the solar system.↩︎

  8. We will continue to say position for simplicity, but remember that we are always referring to their full embeddings instead.↩︎

  9. This is because the number of parameters in general does not depend on the length of the context but only on the structure of our neural network.↩︎

  10. All the details about the experiments of this and the following chapters are in the online version on the Sources page. Note that our neural network guesses the next symbol from its distance to every symbol’s starting position, while real networks use a separate set of constants. In our tests the two were equivalent. When feasible, we plot the real results of the experiments using methods such as UMAP, which flatten high-dimensional points onto a plane while keeping neighbors close. When this impacts readability, we draw them by hand while staying close to the true results.↩︎

  11. Real chatbots also have one extra symbol that means “the answer ends here”. When the network picks it, the chatbot stops writing.↩︎

Sources

Sources

Passages cited in this chapter.

heap of stones is a house Poincaré, H. 1902 Science and hypothesis.
it was made popular in 1986 Rumelhart, D. E., et al. 1986 Learning representations by back-propagating errors. Nature 323.
a few and ignoring the rest Vaswani, A., et al. 2017 Attention is all you need. Advances in neural information processing systems 30.
to learn to “perceive” simple images Rosenblatt, F. 1958 The perceptron. Psychological Review 65.
neuron, a cell of the brain McCulloch, W. S., and W. Pitts 1943 A logical calculus of the ideas immanent in nervous activity. Bulletin of Mathematical Biophysics 5.
Rosenblatt’s perceptron “New Navy device learns by doing.” The New York Times, 8 July 1958.
words can share what they learn Bengio, Y., et al. 2003 A neural probabilistic language model. Journal of Machine Learning Research 3.
rush to (deep) neural networks begins Krizhevsky, A., et al. 2012 ImageNet classification with deep convolutional neural networks. Advances in neural information processing systems 25.
fascinate researchers all over the world Mikolov, T., et al. 2013 Linguistic regularities in continuous space word representations. Proceedings of the 2013 Conference of the North American Chapter of the Association for Computational Linguistics.
inside every chatbot today, ours included Vaswani, A., et al. 2017 Attention is all you need. Advances in neural information processing systems 30.

Chapter 4: More tokens, please is coming soon. Meanwhile, explore the alien web to browse the pages and try cracking the cipher yourself.

Browse the alien webAll chapters