Lesson 2 of 30 ~15 min
Course progress
0%

How Extended Thinking Works

Pochopte mechanismus extended thinking - co se děje uvnitř modelu.

Extended thinking umožňuje Opus “přemýšlet nahlas” před finální odpovědí. Pojďme pochopit, jak to funguje.

Základní princip

Běžný model:
[Input] → [Model] → [Output]

Extended thinking:
[Input] → [Model] → [Thinking tokens] → [Final Output]

                   (viditelné uživateli)

Jak to vypadá v praxi

Bez extended thinking:

User: What's the bug in this code?
Assistant: The bug is on line 5 where...

S extended thinking:

User: What's the bug in this code?

<thinking>
Let me analyze this step by step...
1. First, I'll trace the data flow...
2. The variable `count` is initialized to 0...
3. In the loop, it's incremented but...
4. Ah, I see - the condition should be <= not <
</thinking>

The bug is on line 5. The loop condition uses `<` 
but should use `<=` to include the boundary case...

API aktivace

from anthropic import Anthropic

client = Anthropic()

response = client.messages.create(
    model="claude-opus-4-5-20250101",
    max_tokens=16000,
    thinking={
        "type": "enabled",
        "budget_tokens": 10000  # max thinking tokens
    },
    messages=[{
        "role": "user", 
        "content": "Solve this complex problem..."
    }]
)

# Thinking je v response
for block in response.content:
    if block.type == "thinking":
        print("Thinking:", block.thinking)
    elif block.type == "text":
        print("Answer:", block.text)

Effort Levels

Můžete kontrolovat “hloubku” přemýšlení:

BudgetPoužitíTypický output
1,000Quick check1-2 kroky analýzy
5,000Standard3-5 kroků
10,000Deep5-10 kroků
30,000+ExhaustiveKomplexní analýza

Kdy model sám použije více thinking

  • Komplexní matematické problémy
  • Multi-step reasoning
  • Kód s mnoha závislostmi
  • Ambiguitní zadání
  • Problémy s mnoha edge cases

Interní mechanismus

  1. Priming: Model rozpozná, že potřebuje reasoning
  2. Exploration: Generuje alternativní cesty řešení
  3. Evaluation: Vyhodnocuje jednotlivé cesty
  4. Selection: Vybírá nejlepší cestu
  5. Articulation: Formuluje finální odpověď

Tento proces je transparentní - vidíte, jak model “přemýšlí”.

V další lekci se podíváme na cost kalkulace.