Agent skill

SentencePiece Tokenizer

by Orchestra-Research in Orchestra-Research/AI-Research-SKILLs

Trains and uses SentencePiece tokenizers on raw text, with BPE or Unigram models, for multilingual and CJK projects that need a reproducible vocabulary.

MITAuto-check: notesAI & LLM Engineering

Install SentencePiece Tokenizer

skills CLI
$ npx skills add Orchestra-Research/AI-Research-SKILLs --skill sentencepiece -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install Orchestra-Research/AI-Research-SKILLs sentencepiece --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/Orchestra-Research/AI-Research-SKILLs.git skills-src && mkdir -p .claude/skills && cp -r skills-src/02-tokenization/sentencepiece .claude/skills/sentencepiece && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
sentencepiece
GitHub stars
13k
Used in
2 other repos
Token cost
~1.4k tokens
SKILL.md length
248 words
Files
3 (incl. references)
Skills in repo
96
Repo updated
First seen
Licence
MIT

At a glance

Trains and uses SentencePiece tokenizers on raw text, with BPE or Unigram models, for multilingual and CJK projects that need a reproducible vocabulary.

  • Training a tokenizer for a multilingual model with no language rules
  • SKILL.md covers When to use SentencePiece, Quick start, Language-independent design and Tokenization algorithms, plus 7 more sections
  • Calls make, pip and git; reaches github.com
  • Tokenizing Chinese, Japanese or Korean text

What it does

SentencePiece is an unsupervised tokenizer that treats input as raw Unicode, so no language-specific pre-tokenization is needed. The skill shows installing the Python package, training a model with the spm_train command or the Python trainer, and encoding and decoding text. It explains that whitespace becomes the special symbol ▁, so 'Hello world' splits into pieces that start with that mark.

It compares the two algorithms: BPE, used by mBART, and Unigram, the default, used by T5, ALBERT and XLNet. A table gives character coverage settings, slightly under full coverage for English and multilingual text and full coverage for Chinese. Subword regularization is shown for sampling different tokenizations of the same text. HuggingFace Tokenizers, tiktoken and BERT WordPiece are named as alternatives, and reference files cover algorithms and training.

When your agent uses it

  • Training a tokenizer for a multilingual model with no language rules
  • Tokenizing Chinese, Japanese or Korean text
  • Needing the same vocabulary and tokenization on every run
  • Choosing between BPE and Unigram for a new vocabulary

Example prompts

  • “Train a BPE SentencePiece model on corpus.txt with an 8000-token vocabulary.”
  • “Set the character coverage correctly for a Japanese and English training corpus.”
  • “Encode this sentence with my trained model and show the pieces.”
  • “Switch our tokenizer from Unigram to BPE and explain what changes.”

Requirements

  • Python with the `sentencepiece` package

What it can do on your machine

Read from SKILL.md and the folder at commit 773a529. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • make
    • pip
    • git
    • cmake

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • github.com

    Also links to:

    • arxiv.org

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

SentencePiece Tokenizer loads about 1.4k tokens when it runs, and up to ~4k if it reads all its reference files. Until then it costs about 88 tokens; SKILL.md has 248 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~88
When it runs · the whole SKILL.md, loaded when a task matches
~1.4k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NoteRuns commands with sudoSKILL.md:47
    sudo make install

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from Orchestra-Research/AI-Research-SKILLs at commit 773a529, republished under its MIT licence (© Orchestra-Research). 248 words, ~1,403 tokens.

Download SKILL.mdSave it as .claude/skills/sentencepiece/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
sentencepiece
description
Language-independent tokenizer treating text as raw Unicode. Supports BPE and Unigram algorithms. Fast (50k sentences/sec), lightweight (6MB memory), deterministic vocabulary. Used by T5, ALBERT, XLNet, mBART. Train on raw text without pre-tokenization. Use when you need multilingual support, CJK languages, or reproducible tokenization.
version
1.0.0
author
Orchestra Research
license
MIT
tags
Tokenization, SentencePiece, Language-Independent, BPE, Unigram, Multilingual, CJK Languages, Unicode, Deterministic, Google
dependencies
sentencepiece, transformers

SentencePiece - Language-Independent Tokenization

Unsupervised tokenizer that works on raw text without language-specific preprocessing.

When to use SentencePiece

Use SentencePiece when:

  • Building multilingual models (no language-specific rules)
  • Working with CJK languages (Chinese, Japanese, Korean)
  • Need reproducible tokenization (deterministic vocabulary)
  • Want to train on raw text (no pre-tokenization needed)
  • Require lightweight deployment (6MB memory, 50k sentences/sec)

Performance:

  • Speed: 50,000 sentences/sec
  • Memory: ~6MB for loaded model
  • Languages: All (language-independent)

Use alternatives instead:

  • HuggingFace Tokenizers: Faster training, more flexibility
  • tiktoken: OpenAI models (GPT-3.5/4)
  • BERT WordPiece: English-centric tasks

Quick start

Installation
bash
# Python
pip install sentencepiece

# C++ (requires CMake)
git clone https://github.com/google/sentencepiece.git
cd sentencepiece
mkdir build && cd build
cmake .. && make -j $(nproc)
sudo make install
Train model
bash
# Command-line (BPE with 8000 vocab)
spm_train --input=data.txt --model_prefix=m --vocab_size=8000 --model_type=bpe

# Python API
import sentencepiece as spm

spm.SentencePieceTrainer.train(
    input='data.txt',
    model_prefix='m',
    vocab_size=8000,
    model_type='bpe'
)

Training time: ~1-2 minutes for 100MB corpus

Encode and decode
python
import sentencepiece as spm

# Load model
sp = spm.SentencePieceProcessor(model_file='m.model')

# Encode to pieces
pieces = sp.encode('This is a test', out_type=str)
print(pieces)  # ['▁This', '▁is', '▁a', '▁test']

# Encode to IDs
ids = sp.encode('This is a test', out_type=int)
print(ids)  # [284, 47, 11, 1243]

# Decode
text = sp.decode(ids)
print(text)  # "This is a test"

Language-independent design

Whitespace as symbol (▁)
python
text = "Hello world"
pieces = sp.encode(text, out_type=str)
print(pieces)  # ['▁Hello', '▁world']

# Decode preserves spaces
decoded = sp.decode_pieces(pieces)
print(decoded)  # "Hello world"

Key principle: Treat text as raw Unicode, whitespace = ▁ (meta symbol)

Tokenization algorithms

BPE (Byte-Pair Encoding)
python
spm.SentencePieceTrainer.train(
    input='data.txt',
    model_prefix='bpe_model',
    vocab_size=16000,
    model_type='bpe'
)

Used by: mBART

Unigram (default)
python
spm.SentencePieceTrainer.train(
    input='data.txt',
    model_prefix='unigram_model',
    vocab_size=8000,
    model_type='unigram'
)

Used by: T5, ALBERT, XLNet

Training configuration

Essential parameters
python
spm.SentencePieceTrainer.train(
    input='corpus.txt',
    model_prefix='m',
    vocab_size=32000,
    model_type='unigram',
    character_coverage=0.9995,  # 1.0 for CJK
    user_defined_symbols=['[SEP]', '[CLS]'],
    unk_piece='<unk>',
    num_threads=16
)
Character coverage
Language TypeCoverageRationale
English0.9995Most common chars
CJK (Chinese)1.0All characters needed
Multilingual0.9995Balance

Encoding options

Subword regularization
python
# Sample different tokenizations
for _ in range(3):
    pieces = sp.encode('tokenization', out_type=str, enable_sampling=True, alpha=0.1)
    print(pieces)

# Output (different each time):
# ['▁token', 'ization']
# ['▁tok', 'en', 'ization']

Use case: Data augmentation for robustness.

Common patterns

T5-style training
python
spm.SentencePieceTrainer.train(
    input='c4_corpus.txt',
    model_prefix='t5',
    vocab_size=32000,
    model_type='unigram',
    user_defined_symbols=[f'<extra_id_{i}>' for i in range(100)],
    unk_id=2,
    eos_id=1,
    pad_id=0
)
Integration with transformers
python
from transformers import T5Tokenizer

# T5 uses SentencePiece internally
tokenizer = T5Tokenizer.from_pretrained('t5-base')
inputs = tokenizer('translate English to French: Hello', return_tensors='pt')

Performance benchmarks

Training speed
CorpusBPE (16k)Unigram (8k)
100 MB1-2 min3-4 min
1 GB10-15 min30-40 min
Tokenization speed
  • SentencePiece: 50,000 sentences/sec
  • HF Tokenizers: 200,000 sentences/sec (4× faster)

Supported models

T5 family: t5-base, t5-large (32k vocab, Unigram) ALBERT: albert-base-v2 (30k vocab, Unigram) XLNet: xlnet-base-cased (32k vocab, Unigram) mBART: facebook/mbart-large-50 (250k vocab, BPE)

References

Resources

© Orchestra-Research, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files (references) in 02-tokenization/sentencepiece of Orchestra-Research/AI-Research-SKILLs.

  • SKILL.md
  • references/algorithms.md
  • references/training.md

Open the folder on GitHubat commit 773a529

Used in 2 other repositories

We found 2 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 2 other GitHub owners. This page covers the copy in Orchestra-Research/AI-Research-SKILLs, which our catalogue first saw on October 7, 2026.

Compare with similar skills

SentencePiece Tokenizer next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

SentencePiece Tokenizer compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
SentencePiece Tokenizer this skillOrchestra-Research/AI-Research-SKILLs13k2 repos~1.4kAutomated safety check: NotesMIT
OpenMed Model Card Writermaziyarpanahi/openmed5.5k—~1.8kAutomated safety check: PassApache-2.0
Hugging Face Transformers Usagedavila7/claude-code-templates33k11 repos~1.2kAutomated safety check: PassMIT
Cohere V2 Pythonaiskillstore/marketplace433—~4.2kAutomated safety check: PassNone
Deepgram Text Intelligencedeepgram/deepgram-python-sdk469—~1.4kAutomated safety check: PassMIT
TransformersK-Dense-AI/scientific-agent-skills48k1 repos~2.8kAutomated safety check: NotesApache-2.0

Similar skills

  • OpenMed Model Card Writer

    maziyarpanahi/openmed

    Fills in a model card for an OpenMed clinical NER or de-identification model from its evaluation reports: intended use, metrics, subgroups and limitations.

    5.5k GitHub stars~1.8k tokensUpdated yesterday
    AI & LLM EngineeringAuto-check passed
  • Hugging Face Transformers Usage

    davila7/claude-code-templates

    Loads pre-trained Hugging Face Transformers models for text, vision and audio tasks, runs inference with pipelines and fine-tunes on custom datasets.

    33k GitHub starsUsed in 11 repos~1.2k tokens
    AI & LLM EngineeringAuto-check passed
  • Cohere V2 Python

    aiskillstore/marketplace

    Master Cohere v2 Chat API with Python, specializing in entity extraction using JSON Schema mode for structured outputs.

    433 GitHub stars~4.2k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Deepgram Text Intelligence

    deepgram/deepgram-python-sdk

    Uses the Deepgram Python SDK's Read API to analyze text for sentiment, summaries, topics and intents with client.read.v1.text.analyze, from raw text or a hosted URL.

    469 GitHub stars~1.4k tokensUpdated yesterday
    AI & LLM EngineeringAuto-check passed
  • Transformers

    K-Dense-AI/scientific-agent-skills

    Hugging Face Transformers for loading Hub models, running pipeline inference, text generation, and Trainer fine-tuning on NLP, vision, audio, and multimodal tasks.

    48k GitHub starsUsed in 1 repo~2.8k tokens
    AI & LLM EngineeringAuto-check: notes
  • Official

    Implement Conversational Language Understanding (CLU) using the azure-ai-language-conversations Python SDK.

    3.1k GitHub starsUsed in 2 repos~1.4k tokens
    AI & LLM EngineeringAuto-check passed

More from Orchestra-Research/AI-Research-SKILLs

All 96 skills in this repo
  • AudioCraft Audio Generation

    Orchestra-Research/AI-Research-SKILLs

    Generates music from text descriptions with MusicGen and sound effects with AudioGen, using Meta's AudioCraft PyTorch library with melody and style conditioning.

    13k GitHub starsUsed in 8 repos~3.9k tokens
    Auto-check passed
  • LLM Benchmarking with lm-evaluation-harness

    Orchestra-Research/AI-Research-SKILLs

    Runs lm-evaluation-harness to benchmark language models on academic suites such as MMLU, GSM8K and HumanEval, compare models and track training checkpoints.

    13k GitHub starsUsed in 8 repos~3k tokens
    Auto-check passed
  • Segment Anything Model Guide

    Orchestra-Research/AI-Research-SKILLs

    Guide to using Meta's Segment Anything Model for zero-shot image segmentation with point, box or mask prompts, or automatic mask generation.

    13k GitHub starsUsed in 8 repos~3.3k tokens
    Auto-check passed
  • Chroma Vector Database

    Orchestra-Research/AI-Research-SKILLs

    Shows how to store documents and embeddings in Chroma, query them by similarity with metadata filters, and persist them to disk for RAG and semantic search projects.

    13k GitHub starsUsed in 7 repos~2.3k tokens
    Auto-check passed
  • CLIP Image-Text Matching

    Orchestra-Research/AI-Research-SKILLs

    Explains OpenAI's CLIP model for zero-shot image classification, image-text similarity, semantic image search and content moderation, with install steps and code patterns.

    13k GitHub starsUsed in 7 repos~1.7k tokens
    Auto-check passed
  • Whisper Speech Recognition

    Orchestra-Research/AI-Research-SKILLs

    Transcribes audio with OpenAI's Whisper: 99 languages, translation to English, language detection, six model sizes and word-level timestamps, from Python or the CLI.

    13k GitHub starsUsed in 7 repos~1.9k tokens
    Auto-check: notes

Works with

Questions about SentencePiece Tokenizer

What does SentencePiece Tokenizer do?

Trains and uses SentencePiece tokenizers on raw text, with BPE or Unigram models, for multilingual and CJK projects that need a reproducible vocabulary. SentencePiece is an unsupervised tokenizer that treats input as raw Unicode, so no language-specific pre-tokenization is needed. The skill shows installing the Python package, training a model with the spm_train command or the Python trainer, and encoding and decoding text.

When should I use SentencePiece Tokenizer?

SentencePiece Tokenizer fits situations like: training a tokenizer for a multilingual model with no language rules; tokenizing Chinese, Japanese or Korean text; needing the same vocabulary and tokenization on every run; choosing between BPE and Unigram for a new vocabulary.

How do I install SentencePiece Tokenizer in Claude Code?

Run `npx skills add Orchestra-Research/AI-Research-SKILLs --skill sentencepiece -a claude-code`. Or copy the skill folder (02-tokenization/sentencepiece in Orchestra-Research/AI-Research-SKILLs) into .claude/skills/sentencepiece in your project. Claude Code loads it when a task matches its description.

How do I install SentencePiece Tokenizer in Codex?

Run `npx skills add Orchestra-Research/AI-Research-SKILLs --skill sentencepiece -a codex`. Or copy the skill folder (02-tokenization/sentencepiece in Orchestra-Research/AI-Research-SKILLs) into .agents/skills/sentencepiece in your project. Codex loads it when a task matches its description.

Can I use SentencePiece Tokenizer in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add Orchestra-Research/AI-Research-SKILLs --skill sentencepiece -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/sentencepiece, .gemini/skills/sentencepiece, .github/skills/sentencepiece and .opencode/skills/sentencepiece in your project.

What does SentencePiece Tokenizer need to run?

Going by SKILL.md and its folder, SentencePiece Tokenizer needs the command-line tools its instructions call (make, pip, git and cmake). Our summary lists: Python with the `sentencepiece` package.

Does SentencePiece Tokenizer access the network?

SKILL.md names 2 domains. In commands or code: github.com; the agent is likely to contact it when it follows the instructions. As links in the text: arxiv.org. This is read from the text; nothing was executed.

Is SentencePiece Tokenizer safe to install?

Our automated static check of SKILL.md found notes only (runs commands with sudo), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does SentencePiece Tokenizer use?

SentencePiece Tokenizer is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does SentencePiece Tokenizer use?

About 1.4k tokens (SKILL.md is roughly 5.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 2.6k tokens, read only when the agent opens those files.

What are the alternatives to SentencePiece Tokenizer?

Skills that share tags, products or a category with SentencePiece Tokenizer: OpenMed Model Card Writer (maziyarpanahi/openmed, 5.5k stars), Hugging Face Transformers Usage (davila7/claude-code-templates, 33k stars), Cohere V2 Python (aiskillstore/marketplace, 433 stars) and Deepgram Text Intelligence (deepgram/deepgram-python-sdk, 469 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains SentencePiece Tokenizer?

Orchestra-Research (a GitHub organization) maintains it in Orchestra-Research/AI-Research-SKILLs, which has 13,405 GitHub stars. The repository holds 96 skills in this directory. The repository was last updated on June 16, 2026.

Source: Orchestra-Research/AI-Research-SKILLs on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.