# Trenowanie i dostrajanie

EN: **Training and adaptation** · id `training`

Path: [AI Atlas](https://aiatlasgraph.com/llms.txt) › Trenowanie i dostrajanie

## Description

- PL: Jak powstają i zmieniają się wagi modelu.
- EN: How model weights come into being and change.

## In one sentence

- PL: To uczenie modeli na przykładach i dostosowywanie ich do nowych zadań lub oczekiwanego zachowania.
- EN: This trains models on examples and adapts them to new tasks or desired behaviour.

## Problem it solves

- PL: Gotowy model nie zawsze zna twoją dziedzinę, odpowiada w potrzebny sposób lub mieści się w dostępnym budżecie.
- EN: A pretrained model may lack your domain knowledge, respond in the wrong way or exceed your budget.

## What it does

- PL: Dane, przykłady, oceny i sygnały innych modeli zmieniają ustawienia sieci; różne metody obejmują całość, małe części lub łączenie wariantów.
- EN: Data, examples, evaluations and other models' signals change network parameters; methods update the whole network, small parts or combine variants.

## Everyday example

- PL: Uczysz asystenta na przykładach firmowych odpowiedzi i sprawdzasz, czy nowe rozmowy prowadzi zgodnie z potrzebami zespołu.
- EN: You train an assistant on company response examples and check whether new conversations meet the team's needs.

## This concerns you if you…

- PL: chcesz zmienić zachowanie lub umiejętności modelu
- PL: masz dane, przykłady albo sposób oceny prób
- EN: want to change model behaviour or abilities
- EN: have data, examples or a way to evaluate attempts

## Keywords

AdamW · Muon · Chinchilla · SFT · RLHF · DPO · GRPO · LoRA · QLoRA · PEFT · knowledge distillation · model merging · continued pretraining · gradient clipping

## How it works

- PL: Dane i funkcja celu wyznaczają gradienty, według których optymalizator zmienia parametry modelu. Pretraining, dostrajanie, uczenie z nagrodą i transfer używają różnych sygnałów, a walidacja sprawdza jakość oraz utrzymanie wcześniejszych zdolności.
- EN: Data and objectives determine gradients used by optimisers to update model parameters. Pretraining, fine-tuning, reward-based learning and transfer use different signals, while validation checks quality and retention of earlier capabilities.

## Limits

- PL: Cel może nie odpowiadać zadaniu, a dane zawierać błędy i przecieki. Koszt zależy od architektury oraz przebiegu; poprawa treningowa nie gwarantuje uogólniania ani zachowania wcześniejszych umiejętności.
- EN: Objectives can mismatch tasks, while data contain errors and leakage. Costs depend on architecture and training runs; training gains guarantee neither generalisation nor retention of earlier skills.

## Key terms

- PL: **aktualizacja parametrów**: Zmiana wag modelu wynikająca z wybranego sygnału uczącego.
- PL: **checkpoint**: Zapis parametrów i stanu potrzebnego do wznowienia lub oceny treningu.
- EN: **parameter update**: A model-weight change driven by a selected learning signal.
- EN: **checkpoint**: Stored parameters and state needed to resume or assess training.

## Know first

- [Propagacja wsteczna (backpropagation) (Backpropagation)](https://aiatlasgraph.com/t/backprop.md)
- [Spadek gradientu i optymalizacja ciągła (Gradient descent and continuous optimisation)](https://aiatlasgraph.com/t/mathoptimization.md)

## Subtopics (8 direct, 65 in total)

- [Destylacja (Knowledge distillation)](https://aiatlasgraph.com/t/distillation.md): Training a model on signal from another model.
  - [Destylacja kontekstu (wpisanie instrukcji w wagi modelu) (Context distillation)](https://aiatlasgraph.com/t/contextdistill.md): Fine-tuning a model so that without a long prompt it answers as it did with one.
  - [Destylacja na miękkich etykietach (logity nauczyciela) (Soft-label (logit) distillation)](https://aiatlasgraph.com/t/logitdistill.md): The student learns to reproduce the teacher's full probability distribution, not just its top answer. Requires access to the teacher's outputs (logits).
  - [Destylacja on-policy (uczeń generuje, nauczyciel ocenia) (On-policy distillation)](https://aiatlasgraph.com/t/onpolicydistill.md): The student generates its own responses and the teacher provides a dense token-level signal for them. This trains the student on states it visits itself rather than only on finished teacher-generated answers.
    - [Destylacja on-policy dla hierarchicznych zespołów agentów (On-policy distillation for hierarchical multi-agent teams)](https://aiatlasgraph.com/t/multiagentopd.md): Combines on-policy distillation with reinforcement learning to train a shared-parameter Leader-Searcher-Answerer team end to end.
    - [Eksploracja w kontekście przez asymetryczną destylację on-policy (In-context exploration through asymmetric on-policy distillation)](https://aiatlasgraph.com/t/asteroid.md): A student-teacher framework in which the student's on-policy history receives action labels from a privileged expert, teaching test-time exploration.
  - [Destylacja polityki ze względną przewagą krokową (Step-Advantage Policy Distillation)](https://aiatlasgraph.com/t/sapd.md): An on-policy distillation method over recorded prefixes of multi-turn trajectories, using relative advantages among responses at a single decision step.
  - [Destylacja przez odpowiedzi nauczyciela (dane syntetyczne) (Sequence-level distillation from teacher outputs)](https://aiatlasgraph.com/t/seqdistill.md): The teacher generates answers and the student is fine-tuned on them like ordinary data (SFT). Works even with an API-only teacher; licence terms need checking.
  - [Rekurencyjna samodestylacja (Recursive self-distillation)](https://aiatlasgraph.com/t/recursiveselfdistill.md): Self-distillation repeated across rounds, with the updated model becoming the teacher for the next iteration.
- [Efektywne dostrajanie (Parameter-efficient fine-tuning)](https://aiatlasgraph.com/t/peft.md): Training selected parameters or small adapters.
  - [Adaptery (małe warstwy wstawiane do modelu) (Adapter modules)](https://aiatlasgraph.com/t/adapters.md): Small trainable layers are inserted into a frozen model and only they are trained. One base model can serve many tasks with separate, swappable adapters.
  - [Dostrajanie przez interwencje w reprezentacje (Fine-tuning through representation interventions)](https://aiatlasgraph.com/t/reft.md): Instead of changing weights, it learns small interventions on hidden representations at chosen layers and positions of a frozen model.
  - [Dostrajanie wyłącznie wektorów biasu (Bias-only fine-tuning)](https://aiatlasgraph.com/t/bitfit.md): Fine-tuning a model by updating only its bias terms or a subset of them while leaving all other weights frozen.
  - [LoRA (Low-rank adaptation)](https://aiatlasgraph.com/t/lora.md): Fine-tuning with low-rank adapters. Used for language and image models alike.
    - [QLoRA (Quantized low-rank adaptation (QLoRA))](https://aiatlasgraph.com/t/qlora.md): LoRA on top of a base model stored in 4 bits. Cuts the GPU memory needed for fine-tuning.
    - [Warianty LoRA (DoRA, LoRA+, AdaLoRA) (LoRA variants)](https://aiatlasgraph.com/t/loravariants.md): Refinements of basic LoRA: separating weight magnitude and direction, different learning rates for the two adapter matrices, adaptive rank allocation. They aim to close the gap to full fine-tuning.
  - [Miękkie prompty (prompt tuning, prefix tuning) (Soft prompts: prompt and prefix tuning)](https://aiatlasgraph.com/t/softprompts.md): The model stays frozen while a small set of continuous vectors is learned. Prompt tuning adds them as virtual input tokens, whereas prefix tuning supplies learned prefixes to successive attention layers.
  - [Skalowanie aktywacji wyuczonymi wektorami (Learned-vector activation rescaling)](https://aiatlasgraph.com/t/ia3.md): A PEFT method that multiplies attention keys, values and feed-forward activations by learned vectors.
- [Post-training](https://aiatlasgraph.com/t/posttraining.md): Shaping a pretrained model toward the behaviour you want.
  - [Preferencje i RL dla LLM (Preference optimization and RL for LLMs)](https://aiatlasgraph.com/t/preferences.md): Shaping behaviour with preferences or rewards.
    - [DPO i optymalizacja offline (Direct preference optimization and offline variants)](https://aiatlasgraph.com/t/dpo.md): Training directly on chosen–rejected answer pairs, with no separate reward model. Computationally cheaper than RL.
      - [Iteracyjne DPO na świeżych danych preferencji (Iterative DPO with newly generated preference data)](https://aiatlasgraph.com/t/onlinedpo.md): Repeated rounds of DPO in which the current model generates answer pairs and a human, reward model or judge rates them.
      - [Optymalizacja preferencji bez modelu referencyjnego (Reference-free preference optimization)](https://aiatlasgraph.com/t/refreepo.md): DPO variants that need no frozen copy of the model as a reference point.
    - [Modele nagrody (Reward models)](https://aiatlasgraph.com/t/rewardmodels.md): A model trained on human judgements that scores answers. Used for RL, data filtering and evaluation.
    - [Optymalizacja preferencji z ocen binarnych (Preference optimization from binary desirability feedback)](https://aiatlasgraph.com/t/kto.md): Aligning a model on single responses labelled desirable or undesirable, using a utility function from prospect theory.
    - [RL z nagrodą (Reinforcement learning with rewards)](https://aiatlasgraph.com/t/rlpolicy.md): Iteratively improving the model's policy against a reward while staying close to its starting behaviour. Costlier and sensitive to hyperparameters.
      - [Destylacja posterioru świadoma drzewa dla długich agentów (Tree-aware posterior self-distillation for long-horizon agentic RL)](https://aiatlasgraph.com/t/treeopsd.md): Critic-free tree-aware posterior self-distillation for credit assignment in agentic RL.
      - [GRPO i warianty bez krytyka (GRPO and critic-free policy optimization)](https://aiatlasgraph.com/t/grpo.md): A PPO variant without a separate value model: the model samples a group of answers to the same prompt and estimates advantage relative to rewards within that group. This reduces memory requirements and is used in several newer reasoning-training recipes.
      - [Klasyczny RLHF: SFT → model nagrody → PPO (Classic RLHF pipeline with PPO)](https://aiatlasgraph.com/t/rlhfppo.md): The three-stage RLHF recipe popularised by InstructGPT: supervised fine-tuning on demonstrations, training a reward model from human rankings, then policy optimisation with PPO while constraining divergence from a reference model.
      - [Uczenie agentów na trajektoriach wielosesyjnych (Multi-session agentic reinforcement learning)](https://aiatlasgraph.com/t/mosaicmsarl.md): Critic-free hierarchical advantage optimization for agent trajectories composed of multiple sessions.
  - [SFT / instruction tuning (Supervised fine-tuning)](https://aiatlasgraph.com/t/sft.md): Fine-tuning on examples of the expected answer.
    - [Dostrajanie do wywoływania funkcji i narzędzi (Function-calling and tool-use fine-tuning)](https://aiatlasgraph.com/t/toolcallingft.md): Fine-tuning a model on examples whose answer is a correct, structured tool call with arguments.
  - [Szablony czatu i formaty rozmów (Chat templates and conversation formats)](https://aiatlasgraph.com/t/chattemplates.md): How a conversation is stored in a dataset and turned into text for the model. The training template has to match at inference.
- [Proces uczenia (Training optimization)](https://aiatlasgraph.com/t/optimization.md): Steering how the weights get updated.
  - [Harmonogram learning rate (rozgrzewka, cosinus, WSD) (Learning-rate schedules)](https://aiatlasgraph.com/t/lrschedules.md): A plan for changing the learning rate during training. Common patterns include warm-up followed by decay; WSD adds a longer stable-rate phase before the final decay, making training runs easier to extend.
  - [Optymalizatory (SGD, Adam/AdamW, Muon) (Optimizers for neural network training)](https://aiatlasgraph.com/t/optimizers.md): Rules that turn a gradient into a weight update: from SGD with momentum, through adaptive Adam and AdamW, to newer matrix-aware optimisers such as Muon.
  - [Oszczędzanie pamięci podczas treningu (Memory-efficient training)](https://aiatlasgraph.com/t/memefficienttraining.md): Techniques that shrink memory used by activations, gradients and optimiser states, so larger models train on the same hardware.
    - [8-bitowe stany optymalizatora (8-bit optimizer states)](https://aiatlasgraph.com/t/eightbitoptim.md): Storing optimiser statistics (e.g. Adam moments) in 8 bits with block-wise quantisation instead of 32 bits.
    - [Niskorzędowe rzutowanie gradientu (Low-rank gradient projection)](https://aiatlasgraph.com/t/galore.md): Full-parameter training in which gradients and optimiser states are kept in a low-dimensional projection.
    - [Ponowne liczenie aktywacji (gradient checkpointing) (Gradient (activation) checkpointing)](https://aiatlasgraph.com/t/gradcheckpointing.md): Only selected activations are stored; the missing ones are recomputed during backpropagation.
  - [Pakowanie sekwencji w treningu (sequence packing) (Sequence packing for training)](https://aiatlasgraph.com/t/seqpacking.md): Concatenating several short examples into one context-length sequence to reduce padding in a batch.
  - [Przenoszenie hiperparametrów z małego modelu na duży (μP) (Maximal update parametrization (μP) and hyperparameter transfer)](https://aiatlasgraph.com/t/mup.md): A network parametrisation under which optimal hyperparameters are tuned on a small model and transferred unchanged to a large one.
  - [Rozmiar partii treningowej i akumulacja gradientu (Training batch size and gradient accumulation)](https://aiatlasgraph.com/t/batchsize.md): Choosing how many examples go into each update step: gradient accumulation over micro-batches and the critical batch size.
  - [Stabilność treningu i skoki straty (Training stability)](https://aiatlasgraph.com/t/trainingstability.md): Diagnosing and mitigating instabilities such as sudden spikes or divergence in loss during long training runs of large models. The problems can be reproduced in smaller models to test safeguards in the training recipe.
  - [Trening w mieszanej precyzji (FP16, BF16, FP8) (Mixed-precision training)](https://aiatlasgraph.com/t/mixedprecision.md): Running most operations in shorter number formats while keeping key values in full precision. It cuts memory use and speeds up training on modern GPUs.
- [Trening od zera / pretraining (Training from scratch and pretraining)](https://aiatlasgraph.com/t/pretraining.md): Teaching a model from initial weights. Pretraining is the stage that prepares it for later use or adaptation.
  - [Maskowane modelowanie języka (MLM) (Masked language modelling (MLM))](https://aiatlasgraph.com/t/mlm.md): A pretraining objective for encoders: the model restores masked tokens from context on both sides.
  - [Mid-training (późna faza pretrainingu) (Mid-training)](https://aiatlasgraph.com/t/midtraining.md): A late pretraining phase on a smaller, carefully chosen data mix (e.g. maths, code, reasoning, long documents), usually while the learning rate is annealed. It strengthens selected capabilities before post-training.
  - [Prawa skalowania i budżet obliczeń (Scaling laws and compute-optimal training)](https://aiatlasgraph.com/t/scalinglaws.md): Predictable relationships between model size, data, compute and quality. They let you plan a large training run from small ones and choose the ratio of parameters to tokens.
  - [Przewidywanie następnego tokenu (modele autoregresyjne) (Next-token prediction objective)](https://aiatlasgraph.com/t/nexttoken.md): A common pretraining objective for autoregressive language models: predict the next token from the preceding ones. The error is typically optimised as cross-entropy.
  - [Przewidywanie wielu tokenów naraz (multi-token prediction) (Multi-token prediction)](https://aiatlasgraph.com/t/multitoken.md): An auxiliary pretraining objective: from each position the model predicts several upcoming tokens with separate heads.
  - [Wydłużanie okna kontekstu (Context window extension)](https://aiatlasgraph.com/t/contextextension.md): Further training intended to improve performance on sequences longer than those used previously — often by modifying positional encoding and training on long examples.
- [Uczenie ciągłe i transfer (Continual and transfer learning)](https://aiatlasgraph.com/t/continual.md): Adapting to new data and new tasks.
  - [Dotrenowanie na tekstach z dziedziny (continued pretraining) (Continued (domain-adaptive) pretraining)](https://aiatlasgraph.com/t/continuedpretraining.md): An additional pretraining phase of an existing model on unlabelled data from a selected domain, task or language, usually before downstream fine-tuning. It aims to adapt the model to a new data distribution and vocabulary.
  - [Edycja wiedzy w modelu (ROME, MEMIT) (Knowledge editing in language models)](https://aiatlasgraph.com/t/knowledgeediting.md): A targeted change to facts or behaviours stored in a model without full retraining — by editing weights or using external memory. The goal is to limit side effects outside the edit's scope, but this is not guaranteed.
  - [Katastrofalne zapominanie i jego ograniczanie (Catastrophic forgetting and its mitigation)](https://aiatlasgraph.com/t/forgetting.md): While learning new data or tasks, a network may lose earlier capabilities. Mitigation methods include replaying earlier data, protecting important weights and reducing the scope of parameter updates.
  - [Selektywny nadzór eksperta w ciągłym treningu agentów (Selective expert supervision in continual agent reinforcement learning)](https://aiatlasgraph.com/t/tsrlcontinual.md): RL as backbone with selective SFT activated on hard states for continual agent training.
- [Uczenie w czasie testu (Test-time training)](https://aiatlasgraph.com/t/testtimeadapt.md): Updating part of the parameters on an unlabeled test sample before the actual prediction.
  - [Maskowanie obrazu w czasie testu (Masked autoencoder test-time training)](https://aiatlasgraph.com/t/tttmae.md): One-sample test-time training whose auxiliary objective is reconstructing a masked image.
  - [Warstwy z modelem w stanie ukrytym (Test-time training layers)](https://aiatlasgraph.com/t/tttlayers.md): A sequence layer whose hidden state is a model updated by a self-supervised step also at test time.
  - [Zadanie pomocnicze na jednej próbce (One-sample self-supervised test-time training)](https://aiatlasgraph.com/t/tttselfsup.md): A short self-supervised update on one sample or a stream, before the main-task prediction.
- [Łączenie modeli (Model merging)](https://aiatlasgraph.com/t/merging.md): Building a new model by arithmetic on the weights of already-trained models, with no further training.
  - [Arytmetyka zadań (task vectors, TIES, DARE) (Task arithmetic and task vectors)](https://aiatlasgraph.com/t/taskarithmetic.md): The difference between fine-tuned and base-model weights forms a 'task vector' that can be added, subtracted and combined. TIES resolves sign conflicts between vectors, while DARE sparsifies delta parameters before merging.
  - [Ewolucyjne łączenie modeli (Evolutionary model merging)](https://aiatlasgraph.com/t/evolutionarymerge.md): An evolutionary algorithm searches weight mixtures or layer compositions instead of relying on one hand-designed recipe. The source paper also demonstrates merging models specialised in different domains.
  - [Uśrednianie i interpolacja wag (model soups, SLERP) (Weight averaging and interpolation)](https://aiatlasgraph.com/t/weightaveraging.md): Combining several fine-tunes of the same base model by averaging or smoothly interpolating their weights. Often improves quality and robustness at no extra inference cost.

## Sources

- [Stanford CS336 · Language Modeling from Scratch (2025)](<https://cs336.stanford.edu/spring2025/>) `cs336` · reference: Budowa modeli, dane, trening, systemy, inferencja i post-training.
- [Berkeley CS185/285 · Deep Reinforcement Learning (2026)](<https://rail.eecs.berkeley.edu/deeprlcourse/>) `rl` · reference: Uczenie przez wzmacnianie, imitacja, sterowanie i RL dla LLM.

---

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