Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

tokenizers

> 数据库
Open source

Fast State-of-the-Art Tokenizers optimized for Research and Production

10.9K stars0 likes2 views
WebsiteGitHub

About

Fast State-of-the-Art Tokenizers optimized for Research and Production


<br>

<a href="https://github.com/huggingface/tokenizers/blob/main/LICENSE">
    
</a>
<a href="https://pepy.tech/project/tokenizers">
    
</a>

Provides an implementation of today's most used tokenizers, with a focus on performance and versatility.

Main features:

  • Train new vocabularies and tokenize, using today's most used tokenizers.
  • Extremely fast (both training and tokenization), thanks to the Rust implementation. Takes less than 20 seconds to tokenize a GB of text on a server's CPU.
  • Easy to use, but also extremely versatile.
  • Designed for research and production.
  • Normalization comes with alignments tracking. It's always possible to get the part of the original sentence that corresponds to a given token.
  • Does all the pre-processing: Truncate, Pad, add the special tokens your model needs.

Performances

Performances can vary depending on hardware, but running the ~/bindings/python/benches/test_tiktoken.py should give the following on a g6 aws instance:

Bindings

We provide bindings to the following languages (more to come!):

  • Rust (Original implementation)
  • Python
  • Node.js
  • Ruby (Contributed by @ankane, external repo)

Installation

You can install from source using:

bash
pip install git+https://github.com/huggingface/tokenizers.git#subdirectory=bindings/python

or install the released versions with

bash
pip install tokenizers

Quick example using Python:

Choose your model between Byte-Pair Encoding, WordPiece or Unigram and instantiate a tokenizer:

python
from tokenizers import Tokenizer
from tokenizers.models import BPE

tokenizer = Tokenizer(BPE())

You can customize how pre-tokenization (e.g., splitting into words) is done:

python
from tokenizers.pre_tokenizers import Whitespace

tokenizer.pre_tokenizer = Whitespace()

Then training your tokenizer on a set of files just takes two lines of codes:

python
from tokenizers.trainers import BpeTrainer

trainer = BpeTrainer(special_tokens=["[UNK]", "[CLS]", "[SEP]", "[PAD]", "[MASK]"])
tokenizer.train(files=["wiki.train.raw", "wiki.valid.raw", "wiki.test.raw"], trainer=trainer)

Once your tokenizer is trained, encode any text with just one line:

python
output = tokenizer.encode("Hello, y'all! How are you  ?")
print(output.tokens)
# ["Hello", ",", "y", "'", "all", "!", "How", "are", "you", "[UNK]", "?"]

Check the documentation or the quicktour to learn more!

Issues· 214 open

View all issuesOpen on GitHub
  • #2458

    [1.0.0rc2] Encoding.ids_array panics while another thread decodes the ids

    Updated Sep 28, 2026
  • #2447

    [1.0.0rc2] Possible regressions vs. `0.23.x`: Byte atom not found in the vocabulary

    Updated Sep 28, 2026
  • #2460

    v1.0.0-rc.2: canonicalize_file rejects ByteLevel add_prefix_space=true supported by 0.23.2

    Updated Sep 26, 2026
  • #1918

    do we have plan support java ,we need you

    bindingsUpdated Sep 25, 2026
  • #2088

    Two incorrect type annotations affect input typing to tokenizers.Tokenizer.encode()

    StaleUpdated Sep 25, 2026
  • #2456

    Type Stubs for subpackages don't work with basedpyright

    Updated Sep 24, 2026
  • #2091

    Release 0.23.1 introduces breaking change in Encoding.overflowing

    StaleUpdated Sep 24, 2026
  • #2225

    [Feature/Security] Support trusted and untrusted special-token spans

    Updated Sep 22, 2026
  • #1663

    Inconsistent behaviour of `PreTrainedTokenizerFast`s on diacritics marked texts

    bugUpdated Sep 21, 2026
  • #2094

    [Security] Load-time process abort when loading a malicious tokenizer.json (BPE merge buffer overrun)

    Updated Sep 21, 2026

> Tags

Rustbertgptlanguage-modelnatural-language-processing

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 28, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库