Zubnet AIAprenderWiki › Vocabulary
Fundamentos

Vocabulary

Vocab, Token Vocabulary
O conjunto fixo de tokens que um modelo pode reconhecer e produzir. Um vocabulário é construído pelo tokenizer durante o treinamento e tipicamente contém 32K a 128K entradas — palavras comuns, fragmentos de subpalavras, caracteres individuais e tokens especiais. Qualquer texto que o modelo processa deve ser expressável como uma sequência de tokens deste vocabulário. Tokens não no vocabulário são quebrados em pedaços menores que estão.

Por que importa

O vocabulário determina o que o modelo pode “ver”. Um vocabulário treinado principalmente em inglês lidará com inglês eficientemente (um token por palavra) mas pode fragmentar chinês, árabe ou código em muitos tokens pequenos (caro, mais lento, menos contexto). Design de vocabulário é uma das decisões mais consequentes e menos discutidas no desenvolvimento de modelos.

Deep Dive

Building a vocabulary: the tokenizer algorithm (usually BPE) starts with individual bytes or characters and iteratively merges the most frequent pairs. After 32K–128K merges, you have a vocabulary where common words are single tokens ("the," "and," "function") and rare words are split into subword pieces ("un" + "common," "pre" + "process" + "ing"). Special tokens like <BOS> (beginning of sequence), <EOS> (end), and <PAD> (padding) are added explicitly.

The Size Trade-off

Larger vocabularies compress text better (fewer tokens per sentence = cheaper, fits more in context) but increase the model's embedding table size. A 128K vocabulary with 4096-dimensional embeddings adds ~500M parameters just for the token tables. For a 7B model, that's 7% of total parameters doing nothing but mapping tokens to vectors. For a 1B model, it would be 50%. This is why smaller models tend to use smaller vocabularies.

Multilingual Vocabulary

A vocabulary's language coverage depends on its training corpus. Llama's early tokenizer was trained predominantly on English and represented Chinese characters as 3–4 tokens each, making Chinese inference 3–4x more expensive than English. Llama 3's tokenizer was trained on more balanced multilingual data, dramatically improving non-English efficiency. This is a solvable problem, but it requires deliberate effort — the default is English-dominant.

Conceitos relacionados

← Todos os termos
← vLLM Voice AI →