概念
Tokens and the context window
The small pieces of text a model reads and writes, and the limit on how many fit in one request.
このレッスンはまだ翻訳されていないため、英語で表示しています。
- 1Your prompt is split into tokens and sent to the model.
- 2The model writes the response token by token. Both count toward the window.
cat
- May split into
- cat
- Tokens
- 1
Hello!
- May split into
- Hello + !
- Tokens
- 2
unbelievable
- May split into
- un + believ + able
- Tokens
- 3
| Text | May split into | Tokens |
|---|---|---|
| cat | cat | 1 |
| Hello! | Hello + ! | 2 |
| unbelievable | un + believ + able | 3 |
概要
A model does not read letters or whole words. It reads tokens. A token is a piece of text: a short word, part of a longer word, a number or a punctuation mark. A tokenizer splits your text into tokens before the model sees it. The model then writes its answer one token at a time.
Every model has a context window. This is the most tokens it can handle in one request, counting the prompt you send and the answer it writes. If the prompt is long, less room is left for the answer. Text that does not fit is cut off or rejected.
概要
Tokens matter for two more reasons. Providers bill by tokens (see the token pricing lesson), and more tokens take more time to process.
覚えること
- A token is a piece of text, not always a whole word.
- Different models split text in different ways, so token counts differ between models.
- The context window is the limit on tokens in one request: input tokens plus output tokens.
- A longer prompt leaves less room for the answer.
- More tokens mean more cost and more waiting time.
試験では
- “The maximum amount of text a model can handle in one request” points to the context window.
- “The unit a model reads and the unit it is billed by” points to a token.
- “A prompt and answer together are too long” points to the context window limit.