Last updated:
Attention Is All You Need
Ashish Vaswani et al.
In collections: How LLMs work
Story · 7 cardsThere's a way for AI to understand your whole text at once. And it isn't a bigger computer.It's one idea from 2017: stop reading in order. Once you see how it works, you'll write prompts the model gets right away.See the story →The dominant sequence transduction models are based on complex recurrent or convolutional neural networks that include an encoder and a decoder. The best-performing models also connect the encoder and decoder through an attention mechanism. We propose a new, simple neural network architecture – the Transformer – based solely on attention mechanisms, dispensing with recurrence and convolutions entirely. Experiments on two machine translation tasks show that these models are superior in quality, easier to parallelize and require significantly less time to train. Our model achieves 28.4 BLEU on the English-to-German translation task (WMT 2014), improving over the best previous results, including ensembles, by more than 2 BLEU. On the English-to-French translation task (WMT 2014), our model establishes a new single-model state-of-the-art score of 41.8 BLEU after training for only 3.5 days on eight graphics processing units (GPUs), a small fraction of the training costs of the best models in the literature. We also show that the Transformer generalizes well to other tasks, applying it successfully to English constituency parsing with both large and limited training data.
Strategies from the report:
The Self-Attention mechanism: The architecture lets the model analyze an entire sequence (e.g. a sentence) at once and judge which words are most strongly related to one another, regardless of the distance between them in the text. This replaces line-by-line analysis.
Dropping sequential processing in favor of Parallelization: Instead of analyzing words one after another, the model processes huge blocks of text at the same time. This makes language processing drastically faster and more efficient.
Understanding broad global context: Transformer-based models can keep coherence and meaning across long conversations by assigning mathematical weight to individual keywords, so they don't lose the main thread.
Best practices:
Providing rich and precise context: Because the model's operation is based on "attention," the better and more detailed the context you give it, the more accurately it will connect information and generate a substantive answer.
Emphasizing key instructions (Positioning attention): Models pay the most "attention" to keywords at the beginning or the end of a message. Placing the most important rules in those spots helps the model stick to the guidelines.
Using the model's ability to connect distant facts (Cross-referencing): Construct prompts so that they let the artificial intelligence look for unconventional connections in complex, long input texts.
What to avoid
Stuffing the prompt with irrelevant information (Information noise): Adding unnecessary paragraphs or details that are not relevant to the task makes the model's attention needlessly scatter, worsening the result.
Expecting "human memory" beyond the context window: A model based on the Transformer architecture relies on the information contained in its current view of memory. It will not correctly refer to threads you don't remind it of within the given task.
Giving contradictory or mutually exclusive instructions: The weighting mechanism evaluates all fragments of the text. Contradictory commands force it to guess your intent and lower the logical quality of the answer.
Support this project by buying me a coffee ;)