# Transformery i attention

EN: **Transformers and attention** · id `transformers`

Path: [AI Atlas](https://aiatlasgraph.com/llms.txt) › [Sieci i modele generatywne](https://aiatlasgraph.com/t/neural.md) › Transformery i attention

## Description

- PL: Mechanizmy łączenia informacji między elementami sekwencji.
- EN: Mechanisms for mixing information across a sequence.

## In one sentence

- PL: To modele, które łączą informacje między częściami tekstu, obrazu lub innych danych za pomocą uwagi.
- EN: These models connect information across text, image or other data elements using attention.

## Problem it solves

- PL: Znaczenie fragmentu zależy od innych miejsc w danych, czasem oddalonych o wiele słów lub części obrazu.
- EN: A fragment's meaning depends on other places in the data, sometimes many words or image patches away.

## What it does

- PL: Kolejne warstwy porównują elementy i mieszają potrzebne informacje, a różne układy służą do odczytywania danych lub generowania odpowiedzi.
- EN: Successive layers compare elements and mix relevant information, while different layouts read inputs or generate responses.

## Everyday example

- PL: Asystent czytający długi opis łączy wzmiankę o zamówieniu z dopisaną później prośbą o zmianę adresu.
- EN: An assistant reading a long description connects an order reference to a later request to change its address.

## This concerns you if you…

- PL: korzystasz z modeli tekstu lub obrazu
- PL: chcesz zrozumieć łączenie odległych informacji
- EN: use text or image models
- EN: want to understand how distant information is connected

## Keywords

scaled dot-product attention · multi-head attention · feed-forward blocks · positional encoding · causal masking · KV cache · encoder-decoder architecture · LayerNorm

## How it works

- PL: Bloki naprzemiennie mieszają informacje między pozycjami przez uwagę i przekształcają cechy każdej pozycji przez sieć feed-forward. Maski, kodowanie pozycji oraz połączenia resztkowe określają dostępny kontekst i przepływ reprezentacji przez warstwy.
- EN: Blocks alternate attention-based mixing across positions with feed-forward transformations of each position's features. Masks, positional encoding and residual connections determine available context and representation flow through layers.

## Limits

- PL: Pełna uwaga porównuje pary pozycji, zwiększając koszt długich sekwencji. Maska i trening ograniczają dostępne informacje; duży kontekst nie gwarantuje wykorzystania każdej jego części.
- EN: Full attention compares position pairs, increasing long-sequence costs. Masks and training restrict available information; large context does not guarantee use of every part.

## Key terms

- PL: **attention**: Zależne od wejścia ważenie informacji pochodzących z innych pozycji.
- PL: **blok feed-forward**: Podsieć przekształcająca cechy osobno dla każdej pozycji.
- EN: **attention**: Input-dependent weighting of information from other positions.
- EN: **feed-forward block**: A subnetwork transforming each position's features separately.

## Know first

- [Algebra liniowa: wektory i macierze (Linear algebra: vectors and matrices)](https://aiatlasgraph.com/t/linearalgebra.md)
- [Podstawy sieci neuronowych (Neural network fundamentals)](https://aiatlasgraph.com/t/neuralbasics.md)

## Examples

- PL: Self-attention · encoder · decoder

## Subtopics (5 direct, 5 in total)

- [Enkoder, dekoder i enkoder–dekoder (BERT, GPT, T5) (Encoder-only, decoder-only and encoder–decoder models)](https://aiatlasgraph.com/t/transformerfamilies.md): The three transformer layouts. Encoders (BERT) read text bidirectionally and serve classification, search and extraction; decoders (GPT, Llama) predict the next token and make up most modern LLMs; encoder–decoders (T5, BART) map one text to another, e.g. translation and summarisation.
- [FlashAttention](https://aiatlasgraph.com/t/flashattn.md): Attention computed with memory in mind: less data movement, the same result.
- [Kodowanie pozycji (sinusoidalne, RoPE) (Positional encoding (sinusoidal, RoPE))](https://aiatlasgraph.com/t/posencoding.md): A way to provide token-order information that the attention operation alone does not encode. The original Transformer added sinusoidal vectors; many contemporary LLMs use RoPE, which rotates queries and keys according to position. For context extension RoPE is often additionally scaled or interpolated; some architectures leave part of their layers without explicit positional encoding.
- [Mechanizm self-attention (zapytania, klucze, wartości) (Self-attention (queries, keys, values))](https://aiatlasgraph.com/t/selfattention.md): The heart of the transformer: each token produces a query (Q), key (K) and value (V), and the output is a weighted average of values, weighted by query–key similarity across all tokens. This lets the model mix information from the whole sequence at once; cost grows quadratically with length. Text-generating models use a causal mask (a token sees only earlier ones).
- [Oszczędne warianty uwagi (MQA, GQA, MLA) (Memory-efficient attention variants (MQA, GQA, MLA))](https://aiatlasgraph.com/t/attnvariants.md): Multi-head attention variants that reduce KV-cache memory and generation cost: MQA shares one set of keys and values across heads, GQA shares them across groups of heads, and MLA compresses key-value representations into a latent space.

## Related topics

Untyped, symmetric "see also" links.

- [Detekcja z transformerem (DETR) (Transformer-based object detection (DETR))](https://aiatlasgraph.com/t/detrdetectors.md)
- [Modele bazowe dla danych tabelarycznych (Tabular foundation models)](https://aiatlasgraph.com/t/tabularfm.md)
- [RL jako modelowanie sekwencji (Decision Transformer) (RL as sequence modelling (Decision Transformer))](https://aiatlasgraph.com/t/decisiontransformer.md)
- [Transformery w pętli (Looped transformers)](https://aiatlasgraph.com/t/loopedtf.md)
- [Vision Transformer (ViT)](https://aiatlasgraph.com/t/vit.md)
- [Wydłużanie okna kontekstu (Context window extension)](https://aiatlasgraph.com/t/contextextension.md)

## Courses

- [Attention in Transformers](<https://www.deeplearning.ai/courses/attention-in-transformers-concepts-and-code-in-pytorch>)
- [Transformers in Practice](<https://www.deeplearning.ai/courses/transformers-in-practice>)

## Sources

- [Stanford CS336 · Language Modeling from Scratch (2025)](<https://cs336.stanford.edu/spring2025/>) `cs336` · reference: Budowa modeli, dane, trening, systemy, inferencja i post-training.
- [Stanford CS231n · Computer Vision (2026)](<https://cs231n.stanford.edu/>) `vision` · reference: Sieci neuronowe i rozumienie obrazów.
- [Stanford CS229 · Machine Learning (2018, archiwum)](<https://cs229.stanford.edu/syllabus-autumn2018.html>) `cs229` · reference: Klasyczne ML, statystyka i podstawy uczenia. Użyte jako stabilny szkielet, nie przegląd nowości.
- [DeepLearning.AI — course catalogue](<https://www.deeplearning.ai/courses>) `dlai` · course catalogue: 42 topic labels with counts, about 130 courses.
- [Performance Engineering for AI Infra — learning guide](<https://github.com/wafer-ai/gpu-perf-engineering-resources>) `wafer-gpu` · GitHub repository · tiered curriculum (Tier 1–3) · MIT licence · by Wafer (wafer-ai): Company material with a hiring note, but the evidence is mostly primary sources. Table of contents sieved: only topics became nodes; tiers kept as link labels.

---

AI Atlas revision 122 (2026-10-30) · HTML: https://aiatlasgraph.com/t/transformers · index: https://aiatlasgraph.com/llms.txt · everything: https://aiatlasgraph.com/llms-full.txt · updated 2026-10-30
