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 →

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 ;)