← ZPĚTBACK

16Od doplňovače textu k asistentoviFrom text predictor to assistant

V příkladu 15 jsme viděli, že jazykový model jen losuje další token. Proč tedy ChatGPT nebo Claude na otázku odpoví, místo aby prostě pokračoval v textu? Protože po předtréninku přijdou ještě dvě fáze: doladění na konverzacích a učení z lidského hodnocení. A nejnovější modely si navíc umí před odpovědí „promyslet“ mezikroky. In example 15 we saw that a language model only samples the next token. So why do ChatGPT or Claude answer a question instead of simply continuing the text? Because pre-training is followed by two more phases: fine-tuning on conversations and learning from human feedback. And the newest models can also "think through" intermediate steps before answering.

Co a jak?What & how?

Co to jeWhat it is Cesta od základního modelu, který jen doplňuje text, k asistentovi, který odpovídá: stejný princip predikce dalšího tokenu, jen jiná trénovací data a jiná odměna.The path from a base model that only continues text to an assistant that answers: the same next-token principle, just different training data and a different reward.

Co zkusitWhat to try (1) Pošli stejnou otázku základnímu modelu i asistentovi a podívej se, co model skutečně dostane na vstup. (2) Hodnoť dvojice odpovědí (nebo nech hodnotit automat) a sleduj, jak se model posouvá — a co se stane, když hodnotitel miluje lichotky. (3) Porovnej rychlý tip a odpověď „po přemýšlení“.(1) Send the same question to the base model and to the assistant and look at what the model really gets as input. (2) Rate pairs of answers (or let a bot rate) and watch the model shift — and what happens when the rater loves flattery. (3) Compare a quick guess with an answer "after thinking".

Proč je to důležitéWhy it matters Právě tyhle kroky udělaly z doplňovače textu užitečný nástroj (ChatGPT, listopad 2022). Když víš, jak vznikly, chápeš i jejich slabiny: model se naučí to, co odměňujeme, a pořád jen předpovídá další token — takže si umí i sebevědomě vymýšlet.These very steps turned a text predictor into a useful tool (ChatGPT, November 2022). Knowing how they came about also explains their weaknesses: the model learns what we reward, and it still only predicts the next token — so it can confidently make things up.

1 předtrénink (doplňuj text)pre-training (continue text) → 2 doladění na konverzacíchfine-tuning on conversations → 3 hodnocení lidmi (RLHF)human ratings (RLHF) → 4 asistentassistant

1Základní model × asistentBase model × assistant

Dva malé slovní modely (jako v příkladu 15, počítají, co po čem následuje). Základní se učil jen z „internetového“ textu. Asistent je tentýž model doučený na konverzacích v chatové šabloně. Stejná otázka — dvě úplně jiná chování.Two small word models (like in example 15, they count what follows what). The base one learned only from "internet" text. The assistant is the same model further trained on conversations in a chat template. Same question — two completely different behaviours.

tvoje otázkayour question

📄 Základní model (jen předtrénink)Base model (pre-training only)

Co model skutečně vidí: jen tvůj text. Doplňuje, jak by pokračoval dokument.What the model really sees: just your text. It continues the way a document would go on.

💬 Asistent (doladěný na konverzacích)Assistant (fine-tuned on conversations)

Co model skutečně vidí: otázku zabalenou do chatové šablony se systémovým promptem. Role jsou jen speciální tokeny.What the model really sees: the question wrapped in a chat template with a system prompt. Roles are just special tokens.

co z toho ukáže aplikacewhat the app shows you
📚 Na čem se modely učily (celá trénovací data)📚 What the models learned from (the entire training data)

Předtrénink: „internetový text“Pre-training: "internet text"

Doladění: konverzace v šabloněFine-tuning: conversations in the template

Poctivě: oba modely jsou malinké — učily se z pár desítek vět a dívají se nejvýš 8 tokenů zpět (v příkladu 15 jen na poslední slovo; bez delšího kontextu by asistent po <|asistent|> nevěděl, na co se ptáš — skutečné modely to řeší pomocí attention, příklad 14). Na předvolby odpovídají spolehlivě. Na vlastní otázku asistent odpoví ve správném formátu, ale obsah bude často mimo: zná jen pár konverzací, takže si klidně něco vymyslí.Honestly: both models are tiny — a few dozen sentences, and they look at most 8 tokens back (example 15 looked only at the last word; without a longer context the assistant wouldn't know after <|assistant|> what you asked — real models solve this with attention, example 14). They answer the presets reliably. For your own question the assistant will answer in the right format, but the content will often be off: it knows only a few conversations, so it may well make something up.

2Učení z lidského hodnocení (RLHF), zjednodušeněLearning from human feedback (RLHF), simplified

Model nabídne dvě odpovědi a ty klikneš na tu lepší. Z porovnání se učí model odměny — pro každou vlastnost odpovědi (správnost, zdvořilost…) jednu váhu, posouvanou gradientem jako v příkladu 7. Podle odměny se pak přeskládají pravděpodobnosti odpovědí — to je „politika“ modelu, stejný pojem jako v učení odměnou (příklad 12).The model offers two answers and you click the better one. From the comparisons it learns a reward model — one weight per property of an answer (correctness, politeness…), nudged by the gradient just like in example 7. The answer probabilities are then reshuffled by the reward — that's the model's "policy", the same idea as in reinforcement learning (example 12).

dotazprompt
která odpověď je lepší? klikniwhich answer is better? click it
politika: pravděpodobnost každé odpovědi (a její odměna)policy: probability of each answer (and its reward)
model odměny: naučené váhy vlastnostíreward model: learned weights of properties

Odměna odpovědi = součet vah jejích vlastností. Vlevo od čáry = model odměny ji trestá, vpravo = odměňuje.An answer's reward = the sum of the weights of its properties. Left of the line = the reward model penalises it, right = it rewards it.

Zjednodušení: tady model jen volí z pevné sady šesti odpovědí a vlastnosti má každá ručně označené. Ve skutečnosti je model odměny velká neuronová síť, která vlastnosti sama „vidí“ v textu, a jazykový model se učením odměnou (příklad 12) doladí tak, aby psal odpovědi s vysokou odměnou. Princip porovnávání dvojic (model Bradley–Terry) je ale stejný.Simplification: here the model only chooses from a fixed set of six answers, each with hand-labelled properties. In reality the reward model is a large neural network that "sees" the properties in the text itself, and the language model is tuned with reinforcement learning (example 12) to write answers with a high reward. The principle of comparing pairs (the Bradley–Terry model) is the same, though.

3Uvažující model: „přemýšlej krok za krokem“Reasoning model: "think step by step"

Model píše po jednom tokenu. Když musí odpověď vyhrknout hned, na složitější úloze se snadno splete. Když si nejdřív vypíše mezikroky, každý další token se opírá o už spočítané mezivýsledky — za cenu mnohem víc tokenů, tedy víc výpočtu.The model writes one token at a time. When it has to blurt out the answer right away, it easily gets a harder task wrong. When it first writes out the intermediate steps, each next token can lean on results already computed — at the cost of many more tokens, i.e. more computation.

slovní úlohaword problem

⚡ Bez přemýšleníNo thinking

Odpověď hned jako první tokeny.The answer straight away as the first tokens.

🧠 S přemýšlenímWith thinking

Nejdřív mezikroky („tokeny přemýšlení“), pak odpověď.First the intermediate steps ("thinking tokens"), then the answer.

Poctivě: tohle je skriptovaná ilustrace principu (víc výpočtu při odpovídání), ne skutečný model. Rychlý tip je naschvál typická chyba a mezikroky počítá JavaScript. Skutečný uvažující model si mezikroky generuje sám, token po tokenu — a díky nim se trefí častěji, ale ne vždy.Honestly: this is a scripted illustration of the principle (more computation while answering), not a real model. The quick guess is deliberately a typical mistake, and the steps are computed by JavaScript. A real reasoning model generates the steps itself, token by token — and thanks to them it is right more often, but not always.

Jak se z doplňovače textu stane asistentHow a text predictor becomes an assistant

Uvnitř je pořád tentýž stroj z příkladu 15: spočítá pravděpodobnosti dalšího tokenu a jeden vylosuje. Mění se jen to, na čem se učil a co se mu odměňovalo. Proto se trénink velkých modelů dělí do fází. Inside it is still the same machine from example 15: it computes next-token probabilities and samples one. What changes is what it learned from and what it was rewarded for. That's why training large models is split into phases.

1 · Předtrénink1 · Pre-training

Model se učí doplňovat text na obrovském množství textu z internetu, knih a kódu — u dnešních velkých modelů řádově biliony tokenů. Učení = zmenšování chyby předpovědi (příklad 7). Výsledek „zná svět“, ale neví, že má odpovídat: na otázku klidně naváže další otázkou. The model learns to continue text on a huge amount of text from the web, books and code — for today's large models on the order of trillions of tokens. Learning = shrinking the prediction error (example 7). The result "knows the world" but doesn't know it should answer: it may well follow a question with another question.

2 · Doladění na konverzacích2 · Fine-tuning on conversations

Pak se model doučí na ukázkových konverzacích (instrukce a vzorové odpovědi, často psané lidmi). Konverzace se zapisuje chatovou šablonou: systémový prompt, uživatel, asistent — role jsou jen speciální tokeny. Model se naučí, že po tokenu asistenta přichází užitečná odpověď a pak token konce. Next the model is trained further on example conversations (instructions and model answers, often written by people). A conversation is written in a chat template: system prompt, user, assistant — roles are just special tokens. The model learns that after the assistant token comes a helpful answer and then an end token.

3 · RLHF: lidé hodnotí3 · RLHF: people rate

Lidé porovnávají dvojice odpovědí („která je lepší?“). Z toho se naučí model odměny, který umí odhadnout, jak by odpověď člověk ohodnotil. Jazykový model se pak učením odměnou (příklad 12) posouvá k odpovědím s vyšší odměnou. Riziko: když hodnotitelé mají rádi lichotky, model se naučí lichotit (sykofancie). People compare pairs of answers ("which is better?"). From that a reward model is learned that can estimate how a person would rate an answer. The language model is then pushed by reinforcement learning (example 12) towards answers with a higher reward. The risk: if raters like flattery, the model learns to flatter (sycophancy).

4 · Uvažující modely4 · Reasoning models

Od roku 2024 se objevují modely, které před odpovědí vygenerují dlouhý řetězec přemýšlení — víc výpočtu při odpovídání, ne jen při tréninku. Podle zveřejněných popisů se to učí mimo jiné učením odměnou na úlohách, kde lze výsledek automaticky ověřit (matematika, programování). Cena: víc tokenů, delší čekání. Since 2024, models have appeared that generate a long chain of thought before answering — more computation at answer time, not only during training. According to published descriptions they learn this, among other things, by reinforcement learning on tasks whose result can be checked automatically (maths, programming). The price: more tokens, longer waiting.

Proč až teď: měřítkoWhy now: scale

Architektura transformer (attention, příklad 14) je z roku 2017. Pak se ukázalo, že víc dat, víc výpočtu na GPU a větší model dávají pravidelně a předvídatelně lepší výsledky — tzv. zákony škálování. Spolu s doladěním a RLHF z toho vznikl ChatGPT (listopad 2022). The transformer architecture (attention, example 14) dates from 2017. Then it turned out that more data, more GPU compute and a bigger model give regularly and predictably better results — the so-called scaling laws. Together with fine-tuning and RLHF this produced ChatGPT (November 2022).

Co zůstává stejnéWhat stays the same

Asistent je pořád jen predikce dalšího tokenu. Halucinace z příkladu 15 proto nezmizely — model zní sebejistě, i když si fakt „domýšlí“. Proto se mu v praxi přikládají dokumenty (RAG, příklad 17) a dávají nástroje (agenti, příklad 18). The assistant is still just next-token prediction. The hallucinations from example 15 therefore haven't gone away — the model sounds confident even when it is "filling in" a fact. That's why in practice it's given documents (RAG, example 17) and tools (agents, example 18).

Pointa: asistent je tentýž doplňovač textu, jen naučený, že po <|asistent|> má přijít užitečná odpověď. A co je „užitečné“, určili lidé svým hodnocením — model se naučí to, co odměňujeme, ne nutně pravdu. The point: an assistant is the same text predictor, just taught that <|assistant|> should be followed by a helpful answer. And what counts as "helpful" was decided by people's ratings — the model learns what we reward, not necessarily the truth.

Verze 2.0.1 · aktualizováno 29. 9. 2026 Version 2.0.1 · updated 29 September 2026