# Przewidywanie następnego tokenu (modele autoregresyjne)

EN: **Next-token prediction objective** · id `nexttoken` · aliases: next-token prediction, causal language modeling, autoregressive LM objective, przewidywanie następnego tokenu

Path: [AI Atlas](https://aiatlasgraph.com/llms.txt) › [Trenowanie i dostrajanie](https://aiatlasgraph.com/t/training.md) › [Trening od zera / pretraining](https://aiatlasgraph.com/t/pretraining.md) › Przewidywanie następnego tokenu (modele autoregresyjne)

## Description

- PL: Typowy cel pretrainingu autoregresyjnego modelu językowego: przewidzieć kolejny token na podstawie poprzednich. Błąd jest zwykle optymalizowany jako entropia krzyżowa.
- EN: A common pretraining objective for autoregressive language models: predict the next token from the preceding ones. The error is typically optimised as cross-entropy.

## In one sentence

- PL: To uczenie modelu przewidywania kolejnego kawałka tekstu na podstawie wcześniejszych fragmentów.
- EN: This trains a model to predict the next text piece from preceding fragments.

## Problem it solves

- PL: Masz wiele tekstów, ale nie ma przy nich ręcznie napisanych pytań i odpowiedzi do treningu.
- EN: You have many texts but no manually written training questions and answers attached to them.

## What it does

- PL: Sam tekst dostarcza celu: model widzi początek, przewiduje dalszy fragment i poprawia ustawienia według różnicy względem oryginału.
- EN: Text supplies its own target: a model sees a prefix, predicts what follows and adjusts parameters against the original continuation.

## Everyday example

- PL: Podczas treningu model dostaje początek przepisu i ćwiczy przewidywanie jego dalszych słów.
- EN: During training, a model receives the beginning of a recipe and practises predicting its next words.

## This concerns you if you…

- PL: poznajesz podstawowy cel treningu modeli językowych
- PL: masz teksty bez dodatkowych etykiet
- EN: study a basic language-model training objective
- EN: have texts without extra labels

## Keywords

causal language modeling · cross-entropy loss · teacher forcing · perplexity · autoregressive decoding · multi-token prediction

## How it works

- PL: Sekwencję wejściową przesuwa się względem celów, aby każda pozycja przewidywała następujący token. Maska przyczynowa blokuje przyszłość, a suma ujemnych log-prawdopodobieństw uczy rozkładu warunkowego na prefiksach treningowych.
- EN: Inputs are shifted relative to targets so each position predicts its following token. Causal masking blocks future information, and summed negative log probabilities train conditional distributions over training prefixes.

## Limits

- PL: Trening korzysta z prawdziwych prefiksów, a generowanie z własnych tokenów. Różnica rozkładu może kumulować błędy; niski błąd tokenowy nie gwarantuje prawdziwych ani użytecznych odpowiedzi.
- EN: Training uses reference prefixes while generation uses its own tokens. Distribution differences can accumulate errors; low token loss cannot guarantee truthful or useful answers.

## Key terms

- PL: **teacher forcing**: Używanie prawdziwych wcześniejszych tokenów jako kontekstu podczas treningu.
- PL: **ujemna log-wiarygodność**: Koszt rosnący, gdy model przypisuje małą prawdopodobność zaobserwowanemu wynikowi.
- EN: **teacher forcing**: Using reference earlier tokens as context during training.
- EN: **negative log-likelihood**: A cost increasing when a model assigns low probability to observed outcomes.

## Know first

- [Tokenizacja tekstu (BPE, WordPiece, SentencePiece) (Text tokenisation (BPE, WordPiece, SentencePiece))](https://aiatlasgraph.com/t/tokenization.md)
- [Funkcje straty (entropia krzyżowa, MSE) (Loss functions (cross-entropy, MSE))](https://aiatlasgraph.com/t/lossfunctions.md)

## Examples

- PL: model przyczynowy (causal LM) · strata entropii krzyżowej · perplexity · mały GPT od zera
- EN: causal LM · cross-entropy loss · perplexity · a small GPT from scratch

## Related topics

Untyped, symmetric "see also" links.

- [Dyfuzja blokowa (Block diffusion language models)](https://aiatlasgraph.com/t/blockdiffusion.md)
- [Dyfuzyjne modele językowe (Diffusion language models)](https://aiatlasgraph.com/t/dllm.md)
- [Enkoder, dekoder i enkoder–dekoder (BERT, GPT, T5) (Encoder-only, decoder-only and encoder–decoder models)](https://aiatlasgraph.com/t/transformerfamilies.md)
- [Maskowane modelowanie języka (MLM) (Masked language modelling (MLM))](https://aiatlasgraph.com/t/mlm.md)
- [Teoria informacji: entropia i dywergencja KL (Information theory: entropy, cross-entropy and KL divergence)](https://aiatlasgraph.com/t/infotheory.md)
- [Tokenizacja tekstu (BPE, WordPiece, SentencePiece) (Text tokenisation (BPE, WordPiece, SentencePiece))](https://aiatlasgraph.com/t/tokenization.md)

## Sources

- [Training a causal language model from scratch (Hugging Face LLM Course, ch. 7.6)](<https://huggingface.co/learn/llm-course/chapter7/6>) `hf-causal-lm` · by Hugging Face

---

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