Перевірити рівеньКурсиПрограмиДля командТарифи
RUУвійтиРеєстрація
Перевірити рівеньКурсиПрограмиДля командТарифиТест із ClaudeПромптиБлогПитання та відповідіПошукРеєстраціяRU
AcademlКурсиHugging Face LLM Course: Practical TransformersTokenization: BPE, WordPiece, SentencePiece
Донавчання LoRA: велика матриця ваг і дві вузькі, які до неї додаютьКоманда ollama run і шкала відеопамʼяті, в яку вміщується модельПолиця з відкритими моделями: DeepSeek, Qwen, Mistral, Llama
Курс

Hugging Face LLM Course: Practical Transformers

Модуль 1 · Transformers and Tokenization
01Pipeline API: Run Models in Three Lines02Tokenization: BPE, WordPiece, SentencePiece03Hugging Face Hub: Finding and Downloading Models
Модуль 2 · Fine-Tuning
04Dataset Preparation: load_dataset and Tokenization05Trainer API: Fine-Tuning a Classifier06PEFT and LoRA: Fine-Tuning Without Full Training
Модуль 3 · Advanced Capabilities
07Hugging Face Inference Providers: Serverless Inference08Gradio + Spaces: Deploy an ML Demo in 10 Minutes09vLLM + smolagents: Inference Server and Tool-Using Agents
Hugging Face LLM Course: Practical Transformers · Урок 2

Tokenization: BPE, WordPiece, SentencePiece

A tokenizer splits text into subwords and converts them to numbers the model understands. For chat models it also holds the dialogue format (chat template).

ENМатеріали курсів поки англійською. Інтерфейс, ШІ-наставник і перевірка завдань — українською.

40 хв читанняОновлено 02.12.20262 питання у квізіГотовий промпт включено

Algorithms

  • BPE (GPT-2, RoBERTa) — iteratively merges the most frequent symbol pairs. Its byte-level variant works on bytes, so any text, including Cyrillic and emoji, splits without unknown tokens. Most current LLMs use it: Llama 3 and Llama 4, Qwen, GPT models.
  • WordPiece (BERT) — merges that maximise corpus likelihood.
  • SentencePiece (T5, Llama 1 and 2) — trains BPE or Unigram directly on raw text and encodes the space as an ordinary symbol ▁, so it is whitespace-agnostic.

The examples target transformers 5. Version 5 has one tokenizer per model: the split into slow (Python) and fast (Rust) implementations is gone, and AutoTokenizer picks the backend for you.

from transformers import AutoTokenizer

tok = AutoTokenizer.from_pretrained("google-bert/bert-base-uncased")
print(tok.tokenize("Hugging Face!"))  # ['hugging', 'face', '!']
enc = tok("Hugging Face!", return_tensors="pt")
print(enc.input_ids)           # tensor([[101, ..., 102]])

batch_enc = tok(["Short.", "Much longer."], padding=True, truncation=True,
                max_length=16, return_tensors="pt")
print(batch_enc.attention_mask)  # 1=real, 0=pad

print(tok.decode([101, 7592, 2088, 102], skip_special_tokens=True))  # hello world
print(tok.decode(batch_enc.input_ids.tolist(), skip_special_tokens=True))  # list of strings

enc = tok("Hello world", return_offsets_mapping=True)
print(enc.offset_mapping)  # character span of each token

Далі урок відкривається після безкоштовної реєстрації

Реєстрація через email або Google відкриває перші два уроки кожного курсу назавжди і 7 днів повного доступу до всього каталогу. Картка не потрібна.

Зареєструватися безкоштовноАбо пробний урок без реєстрації →
У цьому уроці
AlgorithmsChat templates for LLMsSpecial TokensПрактикаГотовий промптКвіз
КурсиКурси з LLMДля командТарифиПитання та відповідіБлогПро насКонфіденційність
© 2026 AcademlРозробка та просування сайтів —MMIX — Marketing Mix
Почати безкоштовно