1
$\begingroup$

If your task is to predict $t_{n+1}$ given tokens $(t_1,...,t_n)$, you could do two things:

  1. Straight NN - feed $t=(t_1,...,t_n)$ into a neural network as an n-dimensional input and train it on predicting $t_{n+1}$ (with all the embedding / layernorm / skip connection stuff that transformer models have)
  2. Attention - take $t_n$ plus information from $t_1,...,t_{n-1}$ relevant to $t_n$ computed in the attention layer (plus positional encoding) and feed that into a neural network to predict $t_{n+1}$

In one case you're putting everything into the NN, equally weighted. In another, you're taking certain information from each token weighted by relevance to $t_n$.

My question is: why can't the straight NN learn this? What was wrong with the straight NN model so that we needed into introduce attention? If it was helpful to upweight certain things by a relevance metric, why wouldn't the NN learn that?

My only thought so far is long-range dependency: that a NN might forget information far back in the sequence (as in general it will be less useful). For example, 'he walked into the kitchen, took the chocolate from the drawer, opened wide and put it into' – to predict the next word you really need to look all the way back to the start of the sentence.

$\endgroup$

1 Answer 1

1
$\begingroup$

Neural networks are universal approximators, so they could approximate any function. But for it to really work you possibly would need a huge number of weights, a lot of data, and training it for a really long time. All the new kinds of neural networks and other improvements in this area are to make them smaller, work with realistically big datasets, and be able to train in a reasonable time. So theoretically it could be possible, but not practically.

The difference is between the model figuring everything by itself vs us giving it a reasonable starting point. We have different ways of making life easier for the machine learning algorithms: using feature engineering, initializing the weights cleverly, using informative priors for the parameters, or using architectures that already force some informed way of using the data as in this case. Machine learning to a great degree is about finding those shortcuts.

As a side comment, notice that the same applies to the brains of humans and other animals: we do not start with a set of neurons and need to figure out how to use them all by ourselves. We start with pre-build architecture, and innate knowledge, with many of the reflexes and basic “functionalities” available to us at birth. Starting at tabula rasa would be really ambitious.

$\endgroup$
1
  • $\begingroup$ Helpful answer, thank you! $\endgroup$ Commented Mar 19, 2023 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.