トークン

AIとNLPの文脈では、トークンは、処理や分析に使用される単語、単語の一部、または点字マークのようなテキストの基本的な単位です。

トークン化とは、テキストをこれらのトークンに分解するプロセスです。これは、機械学習モデルのためにテキストデータを準備する上で重要なステップであり、モデルがテキストを理解し、処理できるようにします。トークン化の具体的なルールは、タスクや使用されているモデルによって異なり、異なるトークナイザーが異なる結果を生み出します。

トークン化の方法は、単純な空白分割から、サブワード単位や文字レベルの表現を考慮したより洗練された技術まで多岐にわたります。トークナイザーの選択は、NLPモデルのパフォーマンスに大きく影響します。たとえば、単語ベースのトークナイザーは「cat」と「cats」を別々のトークンとして扱う可能性がありますが、サブワードトークナイザーは「cats」を「cat」と「s」に分割する可能性があります。

        graph LR
  Center["トークン"]:::main
  Pre_cryptography["cryptography"]:::pre --> Center
  click Pre_cryptography "/terms/cryptography"
  Rel_machine_learning["machine-learning"]:::related -.-> Center
  click Rel_machine_learning "/terms/machine-learning"
  Rel_token["token"]:::related -.-> Center
  click Rel_token "/terms/token"
  Rel_tokenizer["tokenizer"]:::related -.-> Center
  click Rel_tokenizer "/terms/tokenizer"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧠 理解度チェック

1 / 3

🧒 5歳でもわかるように説明

A [token](/ja/terms/token) is like a single Lego brick that makes up a sentence. AI breaks sentences into these bricks (words, parts of words, or punctuation) so it can understand and build new sentences.

🤓 Expert Deep Dive

Tokenization is a critical preprocessing step in NLP pipelines. Subword tokenization algorithms like BPE, WordPiece, and SentencePiece have become dominant because they balance vocabulary size with the ability to represent rare words and morphology. BPE iteratively merges frequent pairs of characters or bytes, while WordPiece uses a likelihood-based approach. SentencePiece treats text as a sequence of Unicode characters and learns subword units directly, making it language-agnostic. The choice of tokenizer impacts downstream tasks: a word-level tokenizer struggles with OOV words, while character-level tokenizers result in very long sequences. Subword tokenizers offer a compromise, allowing models to handle morphology (e.g., 'running' -> 'run', '##ing') and unknown words by composing them from known subwords. The mapping from tokens to numerical IDs and then to dense vector embeddings (e.g., Word2Vec, GloVe, or contextual embeddings from Transformers) is where semantic meaning is encoded for the model.

🔗 関連用語

前提知識:

📚 出典