huggingface-tokenizers

Train and apply fast BPE, WordPiece, and Unigram tokenizers for NLP pipelines.

1|Updated Mar 12, 2026
One-click install
npx skills add https://github.com/kaminocorp/hermes-alpha-hunter --skill huggingface-tokenizers-kaminocorp
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: huggingface-tokenizers
Source: https://github.com/kaminocorp/hermes-alpha-hunter/tree/main/skills/mlops/evaluation/huggingface-tokenizers
Command: npx skills add https://github.com/kaminocorp/hermes-alpha-hunter --skill huggingface-tokenizers-kaminocorp

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires tokenizers, transformers, datasets, and includes references (resource) components.

What problem does it solve? Tokenizing large text corpora with pure Python implementations is slow, and building custom vocabularies for domain-specific or multilingual models requires deep knowledge of subword algorithms. This Skill provides guidance for using the Rust-based HuggingFace Tokenizers library to tokenize 1GB of text in under 20 seconds and train custom tokenizers from scratch. ## Core Features & Use Cases - High-Speed Tokenization: Encode text 10-100x faster than pure Python, with batch encoding, padding, truncation, and multi-processing support. - Custom Tokenizer Training: Train BPE, WordPiece, or Unigram tokenizers on files, iterators, or streaming datasets with configurable vocabulary size and special tokens. - Alignment Tracking: Map tokens back to original character offsets for NER, question answering, and token classification tasks. - Transformers Integration: Wrap custom tokenizers with PreTrainedTokenizerFast and use them with AutoTokenizer and any transformers model. - Use Case: Train a domain-specific BPE tokenizer on a medical corpus, wrap it for transformers, and use it to tokenize training data for a custom language model. ## Quick Start Train a BPE tokenizer with a 30,000-token vocabulary on my corpus file and show me how to encode text with padding and truncation.

Frequently Asked Questions about huggingface-tokenizers

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I train a custom BPE tokenizer in Python?▼

Initialize a Tokenizer with the BPE model, set a pre-tokenizer like Whitespace or ByteLevel, configure a BpeTrainer with vocab_size and special tokens, then call tokenizer.train() with your corpus files. Training 100MB takes roughly 1-2 minutes on a modern CPU.

What is the difference between BPE, WordPiece, and Unigram tokenization?▼

BPE merges the most frequent character pairs and is used by GPT-2 and RoBERTa. WordPiece scores merges by likelihood ratio and powers BERT. Unigram starts with a large vocabulary and prunes tokens probabilistically, used by T5 and ALBERT via SentencePiece.

How do I use a custom tokenizer with transformers AutoTokenizer?▼

Save your trained tokenizer to JSON, then wrap it with PreTrainedTokenizerFast specifying special tokens like unk_token and pad_token. After save_pretrained(), it loads with AutoTokenizer.from_pretrained() like any Hub tokenizer.

Does HuggingFace Tokenizers support alignment tracking for NER?▼

Yes, fast tokenizers return offset mappings that link each token to character positions in the original text. Use output.offsets or the word_ids() method to align token predictions back to words for NER and question answering.

Why is my tokenizer producing too many unknown tokens?▼

High unknown rates usually mean the vocabulary is too small, min_frequency is too high, or training data is not representative. Increase vocab_size, lower min_frequency, or switch to byte-level BPE which eliminates unknown tokens entirely.

When should I use SentencePiece or tiktoken instead of HuggingFace Tokenizers?▼

Use SentencePiece for language-independent tokenization required by T5 or ALBERT checkpoints, and tiktoken when matching OpenAI GPT model tokenization exactly. HuggingFace Tokenizers is best for training custom vocabularies and fast batch encoding.