# Uczenie on-policy i off-policy

EN: **On-policy vs off-policy learning** · id `onoffpolicy` · aliases: on-policy, off-policy, behaviour policy vs target policy

Path: [AI Atlas](https://aiatlasgraph.com/llms.txt) › [Uczenie ze wzmocnieniem i decyzje](https://aiatlasgraph.com/t/decisions.md) › [Podstawy RL](https://aiatlasgraph.com/t/rlbasics.md) › Uczenie on-policy i off-policy

## Description

- PL: Podział metod RL według tego, czy polityka zbierająca dane (behawioralna) jest tą samą, którą się uczy (docelową); część metod off-policy koryguje tę różnicę, np. ważeniem istotności.
- EN: Splits RL methods by whether the data-collecting (behaviour) policy equals the learned (target) policy; some off-policy methods correct this mismatch, for example with importance sampling.

## In one sentence

- PL: Rozróżnienie, czy program uczy się tylko z własnych, bieżących prób, czy także z cudzych lub dawnych doświadczeń.
- EN: The distinction between a program learning only from its own current attempts or also from others' or older experience.

## Problem it solves

- PL: Zebrane doświadczenia szybko się dezaktualizują, gdy program zmienia sposób działania, a wyrzucanie ich jest marnotrawstwem.
- EN: Collected experience goes stale once the program changes how it acts, yet throwing it away is wasteful.

## What it does

- PL: Jak nauka gotowania tylko z własnych prób w porównaniu z nauką także z cudzych zapisanych przepisów i ich ocen.
- EN: Like learning to cook only from your own attempts versus also learning from others' recorded recipes and their ratings.

## Everyday example

- PL: Asystent zakupowy poprawia rekomendacje na podstawie historii zamówień z czasów, gdy działał według starszych reguł.
- EN: A shopping assistant improves recommendations using order history from when it followed older rules.

## This concerns you if you…

- PL: wybierasz metodę uczenia agenta, a zbieranie danych jest drogie
- PL: chcesz ponownie wykorzystać stare zapisy działań
- EN: you choose how to train an agent and data is costly
- EN: want to reuse old logs of actions

## Keywords

importance sampling · behavior policy · target policy · sample efficiency · replay buffer · Retrace · V-trace

## How it works

- PL: Metody on-policy, np. REINFORCE czy PPO, aktualizują politykę na danych zebranych przez jej bieżącą wersję i potem je odrzucają. Metody off-policy, np. Q-learning, DQN czy SAC, uczą się z bufora danych zebranych przez inne lub starsze polityki; przy ocenie zwrotów korygują różnicę rozkładów współczynnikami istotności albo, jak Q-learning, korzystają z celu niezależnego od polityki behawioralnej.
- EN: On-policy methods such as REINFORCE or PPO update the policy on data from its current version, then discard it. Off-policy methods such as Q-learning, DQN or SAC learn from buffers of data from other or older policies, correcting the mismatch with importance ratios or, like Q-learning, using a target independent of the behaviour policy.

## Limits

- PL: On-policy jest zwykle stabilniejsze, ale wymaga wielu nowych prób. Off-policy jest oszczędniejsze w danych, lecz bardziej podatne na niestabilność, a współczynniki istotności mogą mieć ogromną wariancję przy dużej różnicy polityk.
- EN: On-policy is usually more stable but needs many fresh trials. Off-policy is more data-efficient but more prone to instability, and importance ratios can have huge variance when policies differ a lot.

## Key terms

- PL: **polityka behawioralna**: Sposób działania, który faktycznie zebrał dane.
- PL: **polityka docelowa**: Sposób działania, którego program się uczy lub który ocenia.
- PL: **ważenie istotności**: Przeskalowanie danych, by udawały pochodzenie z innej polityki.
- EN: **behaviour policy**: The way of acting that actually collected the data.
- EN: **target policy**: The way of acting the program learns or evaluates.
- EN: **importance sampling**: Rescaling data so it mimics coming from another policy.

## Know first

- [Uczenie z różnic czasowych (TD) i metody Monte Carlo (Temporal-difference learning and Monte Carlo methods)](https://aiatlasgraph.com/t/tdlearning.md)
- [Statystyka i niepewność (Statistics and uncertainty)](https://aiatlasgraph.com/t/probability.md)

## Related topics

Untyped, symmetric "see also" links.

- [Bufor doświadczeń i priorytetowe odtwarzanie (Experience replay and prioritised replay)](https://aiatlasgraph.com/t/experiencereplay.md)
- [Ocena polityki off-policy (OPE) (Off-policy evaluation (OPE))](https://aiatlasgraph.com/t/ope.md)

## Sources

- [Reinforcement Learning: An Introduction (2nd edition)](<http://incompleteideas.net/book/the-book-2nd.html>) `sutton-barto-rl-2018` · by Richard S. Sutton, Andrew G. Barto
- [OpenAI Spinning Up — Part 2: Kinds of RL Algorithms](<https://spinningup.openai.com/en/latest/spinningup/rl_intro2.html>) `spinningup-rl-taxonomy` · by Joshua Achiam / OpenAI

---

AI Atlas revision 128 (2026-11-04) · HTML: https://aiatlasgraph.com/t/onoffpolicy · index: https://aiatlasgraph.com/llms.txt · everything: https://aiatlasgraph.com/llms-full.txt · updated 2026-11-04
