0Pricing
Deep Learning Academy · Aula

Tokenize e Crie um Vocabulário

Mapeie texto para identificadores inteiros

Tokenize e Crie um Vocabulário é uma aula grátis de Deep Learning Academy no CoddyKit. Esta é a aula 1 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Deep Learning Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Deep Learning Academy inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

Networks Only Eat Numbers

A neural net cannot read raw letters. Before any learning happens, you must turn text into numbers the model can crunch. 🔢

First Step: Tokenize

To tokenize means to split text into small pieces called tokens. The simplest choice is to split a sentence on spaces into words.

text = "I love deep learning"
tokens = text.split()
# ["I", "love", "deep", "learning"]

Tokens Can Be Smaller

A token need not be a whole word. It can be a character or a sub-word piece, which helps the model handle rare or unseen words.

Build a Vocabulary

A vocabulary is the full set of unique tokens your model knows. You collect every distinct token across your training text.

Give Each Token an Id

Each unique token gets one integer id. This mapping from token to id is how words become numbers the network can index.

vocab = {"i": 0, "love": 1, "deep": 2, "learning": 3}

Encode a Sentence

To encode text, you look up each token in the vocabulary and replace it with its id, producing a list of integers.

ids = [vocab[t] for t in ["i", "love", "deep"]]
# [0, 1, 2]

Handle Unknown Words

Some tokens at test time were never seen in training. Map them to a special unknown token so the model still gets a valid id.

unk_id = vocab.get("dragons", vocab["<unk>"])

Special Tokens Help

Add special tokens like padding, start, and end markers. They give the model structure beyond the plain words themselves.

Lowercase and Clean

Normalizing text by lowercasing and stripping punctuation shrinks the vocabulary so Cat and cat share a single id.

Limit the Vocabulary Size

Real corpora have huge vocabularies. Keep only the most frequent tokens to control the vocab size; the rest become unknown.

Now Text Is a Tensor

Once encoded, a sentence is a list of ids you can wrap in a tensor. The pipeline from raw text to model input is complete.

import torch
ids = torch.tensor([0, 1, 2, 3])

Quick Check

What does building a vocabulary give every unique token?

Recap

You split text into tokens, gather the unique ones into a vocabulary, and map each to an integer id so text becomes numbers. ✅

Perguntas Frequentes

A aula “Tokenize e Crie um Vocabulário” é grátis?

Sim — o texto completo de “Tokenize e Crie um Vocabulário” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Deep Learning Academy, atualize para CoddyKit PRO. O curso de Deep Learning Academy inclui 4 aulas no total.

O que vou aprender em “Tokenize e Crie um Vocabulário”?

Mapeie texto para identificadores inteiros Você pratica Deep Learning Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Deep Learning Academy?

Nenhuma experiência prévia é necessária. Deep Learning Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 1 de 4.

Quanto tempo leva a aula “Tokenize e Crie um Vocabulário”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Deep Learning Academy?

Sim. Cada aula de Deep Learning Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Tokenize e Crie um Vocabulário
  2. nn.Embedding: Vetores de Palavras Aprendíveis
  3. Por Que Embeddings Capturam Significado
  4. Treine um Classificador de Texto
← Voltar para Deep Learning Academy