# Uwaga lokalna z przesuwnym oknem

EN: **Sliding-window (local) attention** · id `slidingwindow` · aliases: sliding window attention, SWA, local attention, uwaga lokalna, sparse attention

Path: [AI Atlas](https://aiatlasgraph.com/llms.txt) › [Sieci i modele generatywne](https://aiatlasgraph.com/t/neural.md) › [Architektury efektywne](https://aiatlasgraph.com/t/efficientarch.md) › Uwaga lokalna z przesuwnym oknem

## Description

- PL: Uwaga lokalna, w której token oddziałuje tylko z ograniczonym oknem sąsiednich tokenów zamiast z całą sekwencją. Przy stałym rozmiarze okna całkowity koszt obliczeń rośnie liniowo z długością sekwencji, a pamięć KV dla generowania może być ograniczona rozmiarem okna. Niektóre architektury łączą ją z uwagą globalną lub pełną.
- EN: Local attention in which a token interacts only with a bounded window of neighbouring tokens rather than the entire sequence. With a fixed window, total compute grows linearly with sequence length, and the KV memory used for generation can be bounded by the window size. Some architectures combine it with global or full attention.

## In one sentence

- PL: To uwaga, która dla każdego fragmentu danych korzysta tylko z ograniczonego sąsiedztwa.
- EN: This attention mechanism uses only a limited neighbourhood for each data element.

## Problem it solves

- PL: Porównywanie wszystkich fragmentów długiego tekstu ze wszystkimi zużywa dużo pamięci i obliczeń.
- EN: Comparing every part of a long text with every other part consumes substantial memory and computation.

## What it does

- PL: Okno przesuwa się wraz z tekstem, ograniczając bezpośrednie porównania; dalsze informacje mogą docierać przez inne warstwy lub dodatkową uwagę.
- EN: A window moves along the text, limiting direct comparisons; distant information can arrive through other layers or additional attention.

## Everyday example

- PL: Model analizuje długi zapis zdarzeń, skupiając każdy krok na pobliskich wpisach zamiast całej historii naraz.
- EN: A model analyses a long event log, focusing each step on nearby entries rather than the whole history at once.

## This concerns you if you…

- PL: najważniejsze zależności są lokalne
- PL: chcesz ograniczyć koszt uwagi w długiej sekwencji
- EN: work with mostly local relationships
- EN: want to reduce attention costs in long sequences

## Keywords

Longformer · Mistral 7B · local attention · global attention · rolling KV cache

## How it works

- PL: Maska uwagi ogranicza bezpośrednie porównania do lokalnego okna wokół pozycji lub poprzedzającego ją prefiksu. Kolejne warstwy mogą pośrednio przenosić informacje dalej, a pierścieniowy bufor ogranicza pamięć lokalnych kluczy i wartości podczas generowania.
- EN: An attention mask restricts direct comparisons to a local window around a position or its preceding prefix. Successive layers can indirectly propagate information further, while a rolling buffer limits local key–value memory during generation.

## Limits

- PL: Odległe informacje nie są bezpośrednio dostępne w lokalnej warstwie. Okno i głębokość wpływają na dostępny kontekst; warstwy pełnej uwagi mogą nadal wymagać rosnącej pamięci.
- EN: Distant information is not directly accessible in a local layer. Window size and depth affect available context; full-attention layers can still require growing memory.

## Key terms

- PL: **okno uwagi**: Zbiór pobliskich pozycji dostępnych dla bezpośredniego porównania.
- PL: **bufor pierścieniowy**: Pamięć zastępująca najstarsze lokalne elementy nowymi.
- EN: **attention window**: Nearby positions available for direct comparison.
- EN: **rolling buffer**: Memory replacing the oldest local elements with new ones.

## Know first

- [Mechanizm self-attention (zapytania, klucze, wartości) (Self-attention (queries, keys, values))](https://aiatlasgraph.com/t/selfattention.md)
- [Kodowanie pozycji (sinusoidalne, RoPE) (Positional encoding (sinusoidal, RoPE))](https://aiatlasgraph.com/t/posencoding.md)

## Examples

- PL: Longformer (uwaga lokalna + globalna) · Mistral 7B · przeplot uwagi lokalnej i pełnej
- EN: Longformer (local + global attention) · Mistral 7B · interleaved local and full attention

## Related topics

Untyped, symmetric "see also" links.

- [Zarządzanie KV cache (KV cache management)](https://aiatlasgraph.com/t/kvcache.md)

## Sources

- [Hugging Face LLM Course, chapter 1: 'How do Transformers work?' and 'Transformer Architectures'](<https://huggingface.co/learn/llm-course/chapter1/6>) `hf-llm-course-transformer-arch` · by Hugging Face · sponsored
- [The Big LLM Architecture Comparison — From DeepSeek V3 to GLM-5](<https://magazine.sebastianraschka.com/p/the-big-llm-architecture-comparison>) `raschka-llm-arch-comparison` · by Sebastian Raschka
- [Mistral 7B](<https://arxiv.org/abs/2310.06825>) `mistral-7b-2023` · by Albert Q. Jiang, Alexandre Sablayrolles, Arthur Mensch i in. (Mistral AI) · sponsored
- [Longformer: The Long-Document Transformer](<https://arxiv.org/abs/2004.05150>) `longformer-2020` · by Iz Beltagy, Matthew E. Peters, Arman Cohan

---

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