Skip to main content

SentencePiece Python Wrapper

Python wrapper for SentencePiece. This API supports the encoding, decoding, and training of SentencePiece models.

For a detailed feature and API comparison with Hugging Face Tokenizers and OpenAI's tiktoken, see the Tokenizer Comparison Cheat Sheet.

Installation

For Linux (x86_64/aarch64), macOS, and Windows (x64/arm64) environments, you can use the pip command to install the SentencePiece Python module.

pip install sentencepiece

Basic Usage

The SentencePieceProcessor class provides the primary interface for text tokenization (encoding) and detokenization (decoding).

Core Methods

  • sp.encode(...): Segments input text into token IDs, string pieces, or other formats (like NumPy arrays or Protobuf messages).
  • sp.decode(...): Reconstructs the original text from token IDs or string pieces.

Input Types & Batch Processing

Both methods support polymorphic inputs and can execute in either single or batch mode:

  • Single Input: Pass a single Unicode str or raw bytes (for encoding), or a single list of IDs/pieces or a 1D NumPy array (for decoding).
  • Batch Input: Pass a list of str or bytes (for encoding), or a list of lists of IDs/pieces or a 2D NumPy array (for decoding). Batch operations automatically release the Python GIL and can run in parallel in C++ (see Batch Encoding).

Here is a Python example showing basic usage:

import sentencepiece as spm
import numpy as np

# Load the model
sp = spm.SentencePieceProcessor(model_file='test/botchan_en_unigram_1000.model')

# Encode text to IDs (default return_type is int)
print(sp.encode('This is a test'))
# Output: [284, 47, 11, 4, 15, 400]

# Encode batch of texts to IDs
print(sp.encode(['This is a test', 'Hello world'], return_type=int))
# Output: [[284, 47, 11, 4, 15, 400], [151, 88, 21, 887]]

# Alternative method for encoding to IDs
print(sp.encode_as_ids(['This is a test', 'Hello world']))
# Output: [[284, 47, 11, 4, 15, 400], [151, 88, 21, 887]]

# Encode text to pieces
print(sp.encode('This is a test', return_type=str))
# Output: ['▁This', '▁is', '▁a', '▁', 't', 'est']

# Encode batch of texts to pieces
print(sp.encode(['This is a test', 'Hello world'], return_type=str))
# Output: [['▁This', '▁is', '▁a', '▁', 't', 'est'], ['▁He', 'll', 'o', '▁world']]

# Alternative method for encoding to pieces
print(sp.encode_as_pieces(['This is a test', 'Hello world']))
# Output: [['▁This', '▁is', '▁a', '▁', 't', 'est'], ['▁He', 'll', 'o', '▁world']]

# Encode text to pieces as bytes
print(sp.encode('This is a test', return_type=bytes))
# Output: [b'\xe2\x96\x81This', b'\xe2\x96\x81is', b'\xe2\x96\x81a', b'\xe2\x96\x81', b't', b'est']

# Encode to NumPy array (zero-copy)
print(sp.encode('This is a test', return_type='numpy'))
# Output: [284  47  11   4  15 400] (NumPy array)

# Encode to offset mapping
print(sp.encode('This is a test', return_type='offset_mapping'))
# Output: {
#   'ids': [284, 47, 11, 4, 15, 400],
#   'pieces': ['▁This', '▁is', '▁a', '▁', 't', 'est'],
#   'offsets': [(0, 4), (4, 7), (7, 9), (9, 10), (10, 11), (11, 14)]
# }

# Encode to Protobuf message
proto = sp.encode('This is a test', return_type='proto')
from google.protobuf import text_format
print(text_format.MessageToString(proto))
# Output:
# text: "This is a test"
# pieces {
#   piece: "▁This"
#   id: 284
#   surface: "This"
#   begin: 0
#   end: 4
# }
# ... (remaining pieces omitted for brevity)

# Alternative method for encoding to Protobuf
proto2 = sp.encode_as_proto('This is a test')
print(proto2 == proto)
# Output: True

# Encode with sampling (for subword regularization)
for _ in range(3):
  print(sp.encode('This is a test', return_type=str, enable_sampling=True, alpha=0.1, nbest_size=-1))
# Output examples:
# ['▁', 'This', '▁', 'is', '▁a', '▁', 't', 'e', 'st']
# ['▁This', '▁is', '▁a', '▁', 'te', 's', 't']
# ['▁This', '▁is', '▁', 'a', '▁', 't', 'e', 'st']

# N-best encoding
print(sp.nbest_encode('This is a test', nbest_size=3, return_type=str))
# Output:
# [['▁This', '▁is', '▁a', '▁', 't', 'est'],
#  ['▁This', '▁is', '▁a', '▁', 'te', 'st'],
#  ['▁This', '▁is', '▁a', '▁', 'te', 's', 't']]

# Decode IDs to text
print(sp.decode([284, 47, 11, 4, 15, 400]))
# Output: This is a test

# Decode batch of IDs to text
print(sp.decode([[284, 47, 11, 4, 15, 400], [151, 88, 21, 887]]))
# Output: ['This is a test', 'Hello world']

# Decode NumPy array
ids_np = np.array([284, 47, 11, 4, 15, 400], dtype=np.int32)
print(sp.decode(ids_np))
# Output: This is a test

# Decode to bytes
print(sp.decode([284, 47, 11, 4, 15, 400], return_type=bytes))
# Output: b'This is a test'

# Decode with offset mapping
print(sp.decode([284, 47, 11, 4, 15, 400], return_type='offset_mapping'))
# Output: {
#   'text': 'This is a test',
#   'ids': [284, 47, 11, 4, 15, 400],
#   'pieces': ['▁This', '▁is', '▁a', '▁', 't', 'est'],
#   'offsets': [(0, 4), (4, 7), (7, 9), (9, 10), (10, 11), (11, 14)]
# }

# Decode to Protobuf
proto_dec = sp.decode([284, 47, 11, 4, 15, 400], return_type='proto')
print(proto_dec.text)
# Output: This is a test

# Decode pieces to text
print(sp.decode(['▁', 'This', '▁', 'is', '▁a', '▁', 't', 'e', 'st']))
# Output: This is a test

# Decode batch of pieces to text
print(sp.decode([['▁This', '▁is', '▁a', '▁', 't', 'est'], ['▁He', 'll', 'o', '▁world']]))
# Output: ['This is a test', 'Hello world']

# Get vocabulary size
print(sp.get_piece_size())
# Output: 1000

# Piece to ID mapping
print(sp.piece_to_id('<s>'))
# Output: 1
print(sp.piece_to_id(['</s>', '\r', '▁']))
# Output: [2, 3, 4]

# ID to piece mapping
print(sp.id_to_piece(2))
# Output: </s>
print(sp.id_to_piece([2, 3, 4]))
# Output: ['</s>', '\r', '▁']

# Dictionary-like access
print(len(sp))
# Output: 1000
print(sp['</s>'])
# Output: 2

# Special token IDs
print('bos=', sp.bos_id())  # Output: bos= 1
print('eos=', sp.eos_id())  # Output: eos= 2
print('unk=', sp.unk_id())  # Output: unk= 0
print('pad=', sp.pad_id())  # Output: pad= -1 (disabled)

# Get the first 5 vocabulary tokens
print([sp.id_to_piece(i) for i in range(5)])
# Output: ['<unk>', '<s>', '</s>', '\r', '▁']

Offset Mapping

If you want to perform direct character-level or byte-level alignment operations (like text highlighting, substring extraction, or mapping tokens back to original text), you can use return_type='offset_mapping'.

This yields a Python dictionary containing the token IDs, string pieces, and offsets (tuples of (start, end)).

Unicode Character Offsets (Default)

By default, using return_type='offset_mapping' returns Unicode character offsets for both encoding and decoding. Slicing Python strings directly using these offsets works out of the box:

import sentencepiece as spm

sp = spm.SentencePieceProcessor(model_file='test/botchan_en_unigram_1000.model')

text = "吾輩は猫である。"

# 1. Encoding text to get offsets in the original text
enc_res = sp.encode(text, return_type='offset_mapping')
print(enc_res['offsets'])  # list[tuple[int, int]] containing Unicode char indices

for piece, (start, end) in zip(enc_res['pieces'], enc_res['offsets']):
  # Note: the first piece might be the dummy prefix (e.g. '▁') which maps to empty surface ''
  original_surface = text[start:end]
  print(f"Piece: {piece} -> Surface in original text: {original_surface}")

# 2. Decoding IDs back to text while retrieving offsets in the reconstructed text
dec_res = sp.decode(enc_res['ids'], return_type='offset_mapping')

print(dec_res['text'])    # "吾輩は猫である。" (the reconstructed text)
print(dec_res['offsets']) # Unicode char indices in `dec_res['text']`

for (start, end), piece in zip(dec_res['offsets'], dec_res['pieces']):
  # Note: piece might contain meta symbols (like '▁'), 
  # but slicing `dec_res['text']` using offsets yields the clean surface text.
  surface = dec_res['text'][start:end]
  print(f"Piece: {piece} -> Surface in reconstructed text: {surface}")

Raw Byte Offsets

You can retrieve byte-level offsets and raw byte pieces (useful for binary protocols, C++ compatibility, or raw byte slicing). Using bytes can also improve performance by bypassing Python's Unicode overhead (see Optimizing Performance).

How it is triggered:

  • Encoding: Defaults to matching the input type (i.e., bytes input triggers byte offsets, str input triggers Unicode offsets). You can explicitly override this by passing the return_bytes parameter in encode():
    • return_bytes=True: Forces raw byte offsets and bytes pieces (even with str input).
    • return_bytes=False: Forces Unicode offsets and str pieces (even with bytes input). Note: The return_bytes parameter in encode() is only allowed when return_type='offset_mapping'.
  • Decoding: Used when you explicitly set return_bytes=True in decode() (only allowed when return_type='offset_mapping').
# 1. Encoding bytes input -> returns raw byte offsets and byte pieces
text_bytes = text.encode('utf-8')
enc_res_bytes = sp.encode(text_bytes, return_type='offset_mapping')

print(enc_res_bytes['offsets']) # Byte indices in `text_bytes`
print(enc_res_bytes['pieces'])  # list[bytes] containing raw byte pieces

# Slicing the raw bytes directly works:
for piece, (start, end) in zip(enc_res_bytes['pieces'], enc_res_bytes['offsets']):
  # Note: the first piece is the dummy prefix (b'\xe2\x96\x81') which maps to empty surface b''
  surface_bytes = text_bytes[start:end]
  print(f"Piece: {piece} -> Surface bytes: {surface_bytes}")

# 2. Decoding to raw byte offsets
dec_res_bytes = sp.decode(enc_res_bytes['ids'], return_type='offset_mapping', return_bytes=True)
print(dec_res_bytes['text'])    # b'\xe5\x90\xbe...' (reconstructed text as bytes)
print(dec_res_bytes['offsets']) # Byte indices in `dec_res_bytes['text']`

for (start, end), piece in zip(dec_res_bytes['offsets'], dec_res_bytes['pieces']):
  # piece is returned as bytes when return_bytes=True
  surface_bytes = dec_res_bytes['text'][start:end]
  print(f"Piece: {piece} -> Surface bytes: {surface_bytes}")

Byte Fallback Behavior

When byte_fallback=True is enabled in the model, unknown characters (e.g., emojis or unsupported scripts) are decomposed into a sequence of raw UTF-8 byte tokens (such as <0xF0>, <0x9F>, etc.).

In this case, the offsets (whether Unicode character offsets or raw byte offsets) are assigned as follows:

  • Intermediate Byte Tokens: The first (N-1) byte tokens in the fallback sequence are assigned a zero-width span pointing to the start of the character (i.e., (start, start)). Slicing the text with these offsets yields an empty string ("" or b"").
  • Final Byte Token: The last byte token in the sequence is assigned the span of the entire character (i.e., (start, start + 1) in Unicode character offsets, or (start, start + byte_length) in raw byte offsets). Slicing the text with these offsets yields the full reconstructed character.

This ensures that the text can still be cleanly sliced and reconstructed without producing invalid Unicode byte sequences during slicing.

Protobuf Output

When encoding text with return_type='proto' (or EncodeAsProto), SentencePiece returns a structured SentencePieceText protobuf message.

Benefits of Protobuf Output:

  • Rich Metadata: Provides highly detailed information for each token, including alignment offsets, scores (log-likelihoods), and whether tokens represent control characters or raw bytes.
  • Language-Agnostic Contract: Because it is a standard serialized protobuf message, it can be passed directly to downstream C++, Go, or Java servers, ensuring consistent deserialization across language boundaries.
  • Format Flexibility: Protobuf messages can be easily converted to other popular structures (such as JSON strings) using standard protobuf utilities without manual parsing.

Each token inside the protobuf message contains begin and end alignment offsets representing raw byte offsets in the UTF-8 encoded representation of the original string.

To slice the original text using these offsets, you must first encode the string to UTF-8 bytes, perform the slice, and then decode it back:

import sentencepiece as spm

sp = spm.SentencePieceProcessor(model_file='test/botchan_en_unigram_1000.model')

text = "吾輩は猫である。"
proto = sp.encode(text, return_type='proto')

# Slice the UTF-8 bytes and decode back to string
text_bytes = text.encode('utf-8')
for piece in proto.pieces:
  surface = text_bytes[piece.begin:piece.end].decode('utf-8')
  print(f"Piece: {piece.piece} -> Surface: {surface}")
  assert surface == piece.surface

# Convert the protobuf message to JSON
from google.protobuf.json_format import MessageToJson
json_str = MessageToJson(proto)
print(json_str)

Batch Encoding (Across-Document Parallelism)

When processing a large collection of documents or sentences (e.g., training datasets), you can pass a list of strings directly to encode (or a list of lists/numpy arrays to decode).

To speed up batch tokenization, you can specify num_threads=N to parallelize processing across multiple CPU threads. For optimal performance across multiple batch calls, you should create and reuse a ThreadPool.

import sentencepiece as spm

sp = spm.SentencePieceProcessor(model_file='test/botchan_en_unigram_1000.model')

# A large batch of sentences
sentences = ["This is a test sentence."] * 10000

# 1. Basic batch encoding (sequential)
ids_batch = sp.encode(sentences, return_type=int)

# 2. Parallelized batch encoding using multiple threads
# This processes elements of the list in parallel in C++ (releasing the GIL)
ids_batch = sp.encode(sentences, return_type=int, num_threads=4)

# 3. Best practice: Reuse a ThreadPool to avoid thread recreation overhead
pool = spm.ThreadPool(num_threads=4)
for i in range(10):
  # Reuse the same thread pool across multiple calls
  ids_batch = sp.encode(sentences, return_type=int, thread_pool=pool)

Parallel Encoding (Within-Document Parallelism)

When tokenizing a single, very large document (e.g., a whole book or a massive text dump), you can use parallel_encode to split the document and tokenize it in parallel using multiple CPU threads.

This is different from passing a list of sentences to encode(..., num_threads=N), which parallelizes across the sentences in the list. parallel_encode parallelizes within a single string.

To use it efficiently, you should create and reuse a ThreadPool, and specify a chunk_len (in Unicode characters) to define the minimum chunk size processed by each thread.

import sentencepiece as spm

sp = spm.SentencePieceProcessor(model_file='test/botchan_en_unigram_1000.model')

# 1. Create a ThreadPool to reuse threads (prevents thread recreation overhead)
pool = spm.ThreadPool(num_threads=4)

# Load a very large document
with open('large_document.txt', 'r') as f:
  large_text = f.read()

# 2. Tokenize the large text in parallel
# chunk_len=1048576 (1M characters) is recommended to minimize thread scheduling overhead
ids = sp.parallel_encode(large_text, chunk_len=1048576, thread_pool=pool, return_type=int)

Text Normalization

You can normalize text using the normalization rules defined inside the model, or by using a standalone SentencePieceNormalizer with custom configurations.

import sentencepiece as spm

sp = spm.SentencePieceProcessor(model_file='test/botchan_en_unigram_1000.model')

# Standard normalization (e.g. NFKC and space replacement)
print(sp.normalize("Hello  World."))  # Double space
# Output: ▁Hello▁World.

# Normalization with character-to-byte offset mapping
normalized, offsets = sp.normalize("Hello  World.", with_offsets=True)
print(normalized)
# Output: ▁Hello▁World.
print(offsets)
# Output: [0, 0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13]
# normalized[i] spans from original byte offsets[i] to offsets[i+1]

You can also use SentencePieceNormalizer to run normalization independently of a model, or with custom parameters:

# Replicate processor's exact normalization behavior.
# Unless given explicitly, add_dummy_prefix, escape_whitespaces and
# remove_extra_whitespaces follow the loaded model/spec.
normalizer = spm.SentencePieceNormalizer(
    model_file='test/botchan_en_unigram_1000.model')
print(normalizer.normalize("Hello  World."))
# Output: ▁Hello▁World.

# Raw normalization without whitespace handling.
normalizer = spm.SentencePieceNormalizer(
    model_file='test/botchan_en_unigram_1000.model',
    add_dummy_prefix=False,
    escape_whitespaces=False,
    remove_extra_whitespaces=False
)
print(normalizer.normalize("Hello  World."))
# Output: Hello  World.

# Initialize from mapping list of tuples (source, target).
# rule_name, rule_tsv and norm_map use the NormalizerSpec defaults (all true).
norm_map = [
    ('foo', 'bar'),
    ('apple', 'orange'),
]
normalizer = spm.SentencePieceNormalizer(norm_map=norm_map)
print(normalizer.normalize("foo apple"))
# Output: ▁bar▁orange

# Decompile back to list of tuples
print(normalizer.decompile())
# Output: [('apple', 'orange'), ('foo', 'bar')] (sorted by Unicode code point of source)

Model Training

Training is performed by passing parameters to the SentencePieceTrainer.train() function. See the training options documentation for a full list of supported parameters (which match the command-line flags of spm_train).

import sentencepiece as spm

# Train the model
spm.SentencePieceTrainer.train(
    input='test/botchan.txt',
    model_prefix='m',
    vocab_size=1000,
    user_defined_symbols=['foo', 'bar']
)

Expected output in console (stderr):

sentencepiece_trainer.cc(73) LOG(INFO) Starts training with :
trainer_spec {
  input: test/botchan.txt
  .. snip
unigram_model_trainer.cc(500) LOG(INFO) EM sub_iter=1 size=1188 obj=10.2839 num_tokens=32182 num_tokens/piece=27.0892
unigram_model_trainer.cc(500) LOG(INFO) EM sub_iter=0 size=1100 obj=10.4269 num_tokens=33001 num_tokens/piece=30.0009
unigram_model_trainer.cc(500) LOG(INFO) EM sub_iter=1 size=1100 obj=10.4069 num_tokens=33002 num_tokens/piece=30.0018
trainer_interface.cc(595) LOG(INFO) Saving model: m.model
trainer_interface.cc(619) LOG(INFO) Saving vocabs: m.vocab

Training with a Custom Normalizer

You can pass a pre-configured SentencePieceNormalizer instance to the trainer. This ensures the exact same normalization rules are packaged with the trained model.

# 1. Create and configure a normalizer
norm_map = [('foo', 'bar')]
normalizer = spm.SentencePieceNormalizer(norm_map=norm_map, add_dummy_prefix=False, escape_whitespaces=True)

# 2. Train using the normalizer instance
spm.SentencePieceTrainer.train(
    input='test/botchan.txt',
    model_prefix='m',
    vocab_size=1000,
    normalizer=normalizer
)

You can also extend pre-defined normalization rules (like 'nfkc') by decompiling them, appending your custom rules, and loading them back:

# 1. Load pre-defined NFKC rules
base_normalizer = spm.SentencePieceNormalizer(rule_name='nfkc')

# 2. Decompile to get the base mapping list of tuples
norm_map = base_normalizer.decompile()

# 3. Add custom rules to the mapping list
norm_map.append(('foo', 'bar'))
norm_map.append(('apple', 'orange'))

# 4. Create a new normalizer with the extended mapping
# Note: we set escape_whitespaces=True as required by the trainer
extended_normalizer = spm.SentencePieceNormalizer(norm_map=norm_map, add_dummy_prefix=False, escape_whitespaces=True)

# 5. Train using the extended normalizer
spm.SentencePieceTrainer.train(
    input='test/botchan.txt',
    model_prefix='m',
    vocab_size=1000,
    normalizer=extended_normalizer
)

Training without a Local Filesystem

The SentencePiece trainer can accept any iterable object to feed training sentences. You can also pass a file-like object (any object with a write() method) to write the output model to arbitrary devices/buffers. These features are useful for running SentencePiece in environments that have limited access to the local file system (e.g., Google Colab).

import urllib.request
import io
import sentencepiece as spm

# Loads model from URL as iterator and stores the model to BytesIO.
model = io.BytesIO()
with urllib.request.urlopen(
    'https://raw.githubusercontent.com/google/sentencepiece/master/data/botchan.txt'
) as response:
  spm.SentencePieceTrainer.train(
      sentence_iterator=response, model_writer=model, vocab_size=1000)

# Serialize the model as file.
# with open('out.model', 'wb') as f:
#   f.write(model.getvalue())

# Directly load the model from serialized model.
sp = spm.SentencePieceProcessor(model_proto=model.getvalue())
print(sp.encode('this is test'))

Optimizing Performance: str vs bytes (Encode & Decode)

For maximum throughput (e.g., when processing large datasets or files), you can use Python bytes for both encoding and decoding to bypass Python's Unicode conversion overhead.

Why it is faster:

  • Zero-Copy Encoding: When you pass bytes to the encoder (e.g., read directly via open(..., 'rb')), the wrapper extracts the memory pointer zero-copy to construct std::string_view directly. If you pass str, Python must cache/convert it to UTF-8, and when reading from files, Python first decodes the file bytes to str only for the wrapper to re-encode them.
  • Fast Decoding (No UTF-8 Validation): By default, the decoder converts the reconstructed C++ UTF-8 string into a Python str, which requires validating and decoding bytes to Unicode characters in Python. Specifying return_type=bytes directly returns a Python bytes object, bypassing this validation.

Using bytes instead of str yields ~1.14x speedup on encoding and ~1.21x speedup on decoding (benchmarked on a 30MB Japanese text dataset with 300k lines). Additionally, reading files directly as raw bytes (open(..., 'rb')) bypasses Python's native UTF-8 file decoder entirely, yielding further substantial I/O savings.

Example Pipeline:

import sentencepiece as spm

sp = spm.SentencePieceProcessor(model_file="test.model")

# 1. Optimal Encoding: Read and pass raw bytes
with open("large_file.txt", "rb") as f:
  lines_bytes = f.read().splitlines()
ids = sp.encode(lines_bytes, return_type=int)

# 2. Optimal Decoding: Reconstruct directly to bytes
decoded_lines_bytes = sp.decode(ids, return_type=bytes)
with open("decoded_output.txt", "wb") as f:
  f.write(b"\n".join(decoded_lines_bytes) + b"\n")

Model Modification

Modifying an existing SentencePiece model (e.g., adding/removing tokens, editing token scores) in memory is not officially supported. The SentencePieceProcessor class is designed strictly as a read-only inference engine.

However, since the .model file is a serialized Protocol Buffer, you can load and manipulate it in Python using the standard sentencepiece_model_pb2 definitions included with the package:

from sentencepiece import sentencepiece_model_pb2 as model_pb2
import sentencepiece as spm

# 1. Read the binary model file as a Protobuf message
model_proto = model_pb2.ModelProto()
with open("old.model", "rb") as f:
  model_proto.ParseFromString(f.read())

# 2. Modify vocabulary tokens or scores (at your own risk)
new_piece = model_proto.pieces.add()
new_piece.piece = "<my_special_token>"

# Score meaning depends on the model type:
# - Unigram: Log-probability of the piece (usually negative float). Used to optimize segmentation.
# - BPE: Merge priority. Typically set to 0.0 for high priority, or negative values for lower priority.
new_piece.score = 0.0

# Piece types: NORMAL (1), UNKNOWN (2), CONTROL (3), USER_DEFINED (4), UNUSED (5), BYTE (6)
new_piece.type = model_pb2.ModelProto.SentencePiece.Type.CONTROL

# 3. Load the modified model directly from memory
sp = spm.SentencePieceProcessor(model_proto=model_proto.SerializeToString())

# 4. (Optional) Export/Inspect the modified ModelProto as JSON
from google.protobuf.json_format import MessageToJson
json_model = MessageToJson(model_proto)

# 5. Save the modified model back to a file
with open("new.model", "wb") as f:
  f.write(model_proto.SerializeToString())

# 6. Load the new model from the file
sp2 = spm.SentencePieceProcessor(model_file="new.model")

Free-Threading Support

Experimental support for no-GIL/Free-Threading has been introduced in v0.2.1. For more details, please refer to this page. This operates similarly to how NumPy handles it.

The C++ library's const and static methods (such as encode(), decode(), and train()) are thread-safe and designed to work in a free-threaded (NoGIL) environment. However, non-const methods like load() are not thread-safe and can cause data races; ensure you implement appropriate locks when calling them from multiple threads. This also applies to regular (GIL-enabled) Python builds: encode(), decode() and load() release the GIL while they run, so do not call load() on a processor while another thread is using the same processor.

While this limitation might be removed in the future, please note that it's not a simple fix, as it would require additional shared locks in C++.

Building from Source

Before building SentencePiece from source on Linux, ensure that the following dependencies are installed.

sudo apt update
sudo apt install -y cmake pkg-config build-essential

To build and install the Python wrapper from source, use the following commands to build and install the wheel package.

git clone https://github.com/google/sentencepiece.git
cd sentencepiece
mkdir build
cd build
cmake .. -DSPM_ENABLE_SHARED=OFF -DCMAKE_INSTALL_PREFIX=./root -DSPM_DISABLE_EMBEDDED_DATA=ON
make install
cd ../python
pip install build
python -m build --wheel
pip install dist/sentencepiece*.whl

If you don't have write permission to the global site-packages directory or don't want to install into it, you can use the --user flag:

pip install --user dist/sentencepiece*.whl

To build and install the Python wrapper from source on Windows using Visual Studio, first ensure you have PowerShell 7 (pwsh.exe) installed (which can be installed via winget install --id Microsoft.Powershell --source winget). Then, open a "Developer PowerShell for VS 2022" window and run the following commands:

git clone https://github.com/google/sentencepiece.git
cd sentencepiece
mkdir build
cd build
cmake .. -DSPM_ENABLE_SHARED=OFF -DCMAKE_INSTALL_PREFIX=".\root" -DSPM_DISABLE_EMBEDDED_DATA=ON
cmake --build . --config Release --target install
cd ../python
pip install build
python -m build --wheel
Get-ChildItem .\dist\sentencepiece*.whl | ForEach-Object { pip install $_.FullName }

Migration Notes (New pybind11 API)

Since v0.2.2, the SentencePiece Python wrapper has been migrated from SWIG to pybind11, introducing optimized NumPy support and robust Free-Threading (NoGIL) execution.

This migration introduces a few changes to standard usage and output formats:

1. BOS/EOS Behavior for USER_DEFINED Symbols

Historically, SentencePieceProcessor::bos_id() and eos_id() returned -1 if the corresponding tokens were defined as USER_DEFINED rather than CONTROL. However, the C++ Encode method with extra options (e.g. bos) still prepended the token, while the Python wrapper encode(..., add_bos=True) would prepend -1 or crash.

To resolve this inconsistency:

  • Behavior Alignment: The behavior has been aligned to strictly respect the CONTROL token type requirement.
  • Strict Verification & Errors: If the BOS/EOS tokens are defined as USER_DEFINED (which are essentially treated the same as NORMAL tokens, with no clear distinction in this context) or any type other than CONTROL (or if they are completely missing), trying to add them during encoding will now result in an error:
    • In C++, SetEncodeExtraOptions("bos") or SetEncodeExtraOptions("eos") will fail (return an error).
    • In Python, passing add_bos=True or add_eos=True to encode() will raise a ValueError (instead of silently ignoring it, prepending -1, or crashing).

2. Unified return_type Parameter

The previous parameter out_type has been renamed to return_type to better describe what the functions yield.

  • Backward Compatibility: The name out_type remains supported as a deprecated keyword argument alias. Passing out_type=int will work exactly as before, mapping internally to return_type=int. Specifying both return_type and out_type at the same time is invalid and will raise a ValueError.

3. Removal of immutable_proto

The custom C++ wrapper classes (ImmutableSentencePieceText, ImmutableNBestSentencePieceText) have been removed.

  • Using return_type='immutable_proto' (or out_type='immutable_proto') or helper methods like EncodeAsImmutableProto will now raise a ValueError.
  • Use return_type='proto' or EncodeAsProto instead.

4. New Classmethod Factories

To align with pythonic best practices and avoid overloaded constructor argument logic, SentencePieceProcessor now exposes clean classmethod factories to initialize processors:

  • SentencePieceProcessor.from_file(model_file, **kwargs): Creates and loads a processor from a file path.
  • SentencePieceProcessor.from_proto(model_proto, **kwargs): Creates and loads a processor directly from serialized model bytes in memory.
# 1. Loading from file
sp = spm.SentencePieceProcessor.from_file("m.model", return_type=str)

# 2. Loading from in-memory bytes
sp = spm.SentencePieceProcessor.from_proto(model_bytes, return_type=str)

Further Documentation

For more detailed information on SentencePiece concepts, options, and advanced configurations, please refer to the core documentation:

Metadata

Release files for sentencepiece 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sentencepiece 0.2.3
File Size Uploaded Provenance Actions
sentencepiece-0.2.3.tar.gz 3.8 MB Without provenance Details for sentencepiece-0.2.3.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for sentencepiece 0.2.3
File Actions
sentencepiece-0.2.3-cp315-cp315t-win_arm64.whl CPython 3.15 CPython 3.15 free-threading Windows ARM64 Details for sentencepiece-0.2.3-cp315-cp315t-win_arm64.whl
sentencepiece-0.2.3-cp315-cp315t-win_amd64.whl CPython 3.15 CPython 3.15 free-threading Windows x86-64 Details for sentencepiece-0.2.3-cp315-cp315t-win_amd64.whl
sentencepiece-0.2.3-cp315-cp315t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.15 CPython 3.15 free-threading Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for sentencepiece-0.2.3-cp315-cp315t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
sentencepiece-0.2.3-cp315-cp315t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl CPython 3.15 CPython 3.15 free-threading Linux glibc 2.27+ ARM64, Linux glibc 2.28+ ARM64 Details for sentencepiece-0.2.3-cp315-cp315t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
sentencepiece-0.2.3-cp315-cp315t-macosx_11_0_arm64.whl CPython 3.15 CPython 3.15 free-threading macOS 11.0+ ARM64 Details for sentencepiece-0.2.3-cp315-cp315t-macosx_11_0_arm64.whl
sentencepiece-0.2.3-cp315-cp315-win_arm64.whl CPython 3.15 CPython 3.15 Windows ARM64 Details for sentencepiece-0.2.3-cp315-cp315-win_arm64.whl
sentencepiece-0.2.3-cp315-cp315-win_amd64.whl CPython 3.15 CPython 3.15 Windows x86-64 Details for sentencepiece-0.2.3-cp315-cp315-win_amd64.whl
sentencepiece-0.2.3-cp315-cp315-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.15 CPython 3.15 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for sentencepiece-0.2.3-cp315-cp315-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
sentencepiece-0.2.3-cp315-cp315-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl CPython 3.15 CPython 3.15 Linux glibc 2.27+ ARM64, Linux glibc 2.28+ ARM64 Details for sentencepiece-0.2.3-cp315-cp315-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
sentencepiece-0.2.3-cp315-cp315-macosx_11_0_arm64.whl CPython 3.15 CPython 3.15 macOS 11.0+ ARM64 Details for sentencepiece-0.2.3-cp315-cp315-macosx_11_0_arm64.whl
sentencepiece-0.2.3-cp314-cp314t-win_arm64.whl CPython 3.14 CPython 3.14 free-threading Windows ARM64 Details for sentencepiece-0.2.3-cp314-cp314t-win_arm64.whl
sentencepiece-0.2.3-cp314-cp314t-win_amd64.whl CPython 3.14 CPython 3.14 free-threading Windows x86-64 Details for sentencepiece-0.2.3-cp314-cp314t-win_amd64.whl
sentencepiece-0.2.3-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for sentencepiece-0.2.3-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
sentencepiece-0.2.3-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.27+ ARM64, Linux glibc 2.28+ ARM64 Details for sentencepiece-0.2.3-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
sentencepiece-0.2.3-cp314-cp314t-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 Details for sentencepiece-0.2.3-cp314-cp314t-macosx_11_0_arm64.whl
sentencepiece-0.2.3-cp314-cp314-win_arm64.whl CPython 3.14 CPython 3.14 Windows ARM64 Details for sentencepiece-0.2.3-cp314-cp314-win_arm64.whl
sentencepiece-0.2.3-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details for sentencepiece-0.2.3-cp314-cp314-win_amd64.whl
sentencepiece-0.2.3-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for sentencepiece-0.2.3-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
sentencepiece-0.2.3-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.27+ ARM64, Linux glibc 2.28+ ARM64 Details for sentencepiece-0.2.3-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
sentencepiece-0.2.3-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details for sentencepiece-0.2.3-cp314-cp314-macosx_11_0_arm64.whl
sentencepiece-0.2.3-cp313-cp313-win_arm64.whl CPython 3.13 CPython 3.13 Windows ARM64 Details for sentencepiece-0.2.3-cp313-cp313-win_arm64.whl
sentencepiece-0.2.3-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for sentencepiece-0.2.3-cp313-cp313-win_amd64.whl
sentencepiece-0.2.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for sentencepiece-0.2.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
sentencepiece-0.2.3-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.27+ ARM64, Linux glibc 2.28+ ARM64 Details for sentencepiece-0.2.3-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
sentencepiece-0.2.3-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for sentencepiece-0.2.3-cp313-cp313-macosx_11_0_arm64.whl
sentencepiece-0.2.3-cp312-cp312-win_arm64.whl CPython 3.12 CPython 3.12 Windows ARM64 Details for sentencepiece-0.2.3-cp312-cp312-win_arm64.whl
sentencepiece-0.2.3-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for sentencepiece-0.2.3-cp312-cp312-win_amd64.whl
sentencepiece-0.2.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for sentencepiece-0.2.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
sentencepiece-0.2.3-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ ARM64, Linux glibc 2.27+ ARM64 Details for sentencepiece-0.2.3-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
sentencepiece-0.2.3-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for sentencepiece-0.2.3-cp312-cp312-macosx_11_0_arm64.whl
sentencepiece-0.2.3-cp311-cp311-win_arm64.whl CPython 3.11 CPython 3.11 Windows ARM64 Details for sentencepiece-0.2.3-cp311-cp311-win_arm64.whl
sentencepiece-0.2.3-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for sentencepiece-0.2.3-cp311-cp311-win_amd64.whl
sentencepiece-0.2.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for sentencepiece-0.2.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
sentencepiece-0.2.3-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.27+ ARM64, Linux glibc 2.28+ ARM64 Details for sentencepiece-0.2.3-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
sentencepiece-0.2.3-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for sentencepiece-0.2.3-cp311-cp311-macosx_11_0_arm64.whl
sentencepiece-0.2.3-cp310-cp310-win_arm64.whl CPython 3.10 CPython 3.10 Windows ARM64 Details for sentencepiece-0.2.3-cp310-cp310-win_arm64.whl
sentencepiece-0.2.3-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details for sentencepiece-0.2.3-cp310-cp310-win_amd64.whl
sentencepiece-0.2.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for sentencepiece-0.2.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
sentencepiece-0.2.3-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.27+ ARM64, Linux glibc 2.28+ ARM64 Details for sentencepiece-0.2.3-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
sentencepiece-0.2.3-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details for sentencepiece-0.2.3-cp310-cp310-macosx_11_0_arm64.whl

Total release size: 71.1 MB

Release files / sentencepiece-0.2.3.tar.gz

Download URL sentencepiece-0.2.3.tar.gz
Size 3.8 MB
Tags Source
SHA-256 checksum
How to use checksums
21618ad31f0453a1ebf5ec58defed99758d54af0b670546ecac639ddd8b86fbd
BLAKE2b-256 checksum
How to use checksums
54830664683546ffca8e36653d39d6217c361d931953f40ce28210b56927a9b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp315-cp315t-win_arm64.whl

Download URL sentencepiece-0.2.3-cp315-cp315t-win_arm64.whl
Size 2.0 MB
Tags CPython 3.15 CPython 3.15 free-threading Windows ARM64
SHA-256 checksum
How to use checksums
61993a60493c44f8c99a773d2b0f1162cbbab319989ce3fe04ef4130b740397a
BLAKE2b-256 checksum
How to use checksums
ed022d41f5ac76ee221913fd4775ad95da0f4ea47a7e2c66f479cd1f187ac19d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp315-cp315t-win_amd64.whl

Download URL sentencepiece-0.2.3-cp315-cp315t-win_amd64.whl
Size 1.8 MB
Tags CPython 3.15 CPython 3.15 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
821cd46446d0791df174e7f9e463aa3fc5a923286b98f3509f79bda9992e51cb
BLAKE2b-256 checksum
How to use checksums
cec99532310b0f0d4a3e30c5606b57b72e4694cfe3d63eb13a7339fa7b2ff1d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp315-cp315t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL sentencepiece-0.2.3-cp315-cp315t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.7 MB
Tags CPython 3.15 CPython 3.15 free-threading Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
5b280042f92596dbbfeae01759578897b49fdf1ac1a24ec8ddd6a3de1f6a996d
BLAKE2b-256 checksum
How to use checksums
dbf6c9d335834e4dbaf057d778528cc8a9c280edbd8cfc46a1b31c1d13f99bb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp315-cp315t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL sentencepiece-0.2.3-cp315-cp315t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 1.6 MB
Tags CPython 3.15 CPython 3.15 free-threading Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
d8dd43abf868aa70508d463709812250266aa3f2e4bd4c3d524a5f7d8c18856e
BLAKE2b-256 checksum
How to use checksums
0b5de16c2d83f20e904fc8b7572d7694456a5836bbc3b4b089122e15d89ab191
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp315-cp315t-macosx_11_0_arm64.whl

Download URL sentencepiece-0.2.3-cp315-cp315t-macosx_11_0_arm64.whl
Size 1.4 MB
Tags CPython 3.15 CPython 3.15 free-threading macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2b79f0bbd03ca46ae117595c830eef17bc31a00c566f3b7be3b5f03d51efda3a
BLAKE2b-256 checksum
How to use checksums
ee7dc39a28a48d7545b0dc4ef4cf46d15dc408c49f44c8ad7b27e3fc9abed756
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp315-cp315-win_arm64.whl

Download URL sentencepiece-0.2.3-cp315-cp315-win_arm64.whl
Size 2.0 MB
Tags CPython 3.15 Windows ARM64
SHA-256 checksum
How to use checksums
a0a75095caa5d4ac208dd8d1c051dd78fa7dbdb3b62d2aae86986b678324f759
BLAKE2b-256 checksum
How to use checksums
11d01ea6fae967b746d907162b3459c67024a0fe0f686c17143372eb455e45df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp315-cp315-win_amd64.whl

Download URL sentencepiece-0.2.3-cp315-cp315-win_amd64.whl
Size 1.8 MB
Tags CPython 3.15 Windows x86-64
SHA-256 checksum
How to use checksums
b3dcda6a6eaa297db9e595d1d59a0ca4127ff01af573a24f2665a938c14b9e2a
BLAKE2b-256 checksum
How to use checksums
2fb42d823ad807db17bfde7b4349113617cbad6514cb30de6afa74db1563609f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp315-cp315-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL sentencepiece-0.2.3-cp315-cp315-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.7 MB
Tags CPython 3.15 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
016218e381da4c492323f2d7959012338795a2fb2dfccf14a2bc421c1b040612
BLAKE2b-256 checksum
How to use checksums
8328916674d1b5d3edfc5c8b6dbcda94b8898f81cbd082b182e44bbccd5dfe05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp315-cp315-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL sentencepiece-0.2.3-cp315-cp315-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 1.6 MB
Tags CPython 3.15 Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
e55cea81a9e68ee3bd119ca530225cbf1f4ac46bf35604c8aa677bfd5055bc7c
BLAKE2b-256 checksum
How to use checksums
26b3425151b9086b8814f070e954b3ac94f6899df8e26091769fb26b6ff2b2cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp315-cp315-macosx_11_0_arm64.whl

Download URL sentencepiece-0.2.3-cp315-cp315-macosx_11_0_arm64.whl
Size 1.4 MB
Tags CPython 3.15 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0ef20da5e56faff98bfcd1eb78c9abedc10253035051ab34e0c4be22734390ef
BLAKE2b-256 checksum
How to use checksums
c7f802dc219a545896743edbb0bc60dd7e48fbb1cc96d9299a870b5fca0014ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp314-cp314t-win_arm64.whl

Download URL sentencepiece-0.2.3-cp314-cp314t-win_arm64.whl
Size 2.0 MB
Tags CPython 3.14 CPython 3.14 free-threading Windows ARM64
SHA-256 checksum
How to use checksums
7e9cd3b7229da250c8988e46dc29ae339147d463ab50e1fb697bc59d02880cc1
BLAKE2b-256 checksum
How to use checksums
940115194c03a2ea0171ab08e5f7c3f8977ef310f81ea09feb84ca2b9674d389
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp314-cp314t-win_amd64.whl

Download URL sentencepiece-0.2.3-cp314-cp314t-win_amd64.whl
Size 1.8 MB
Tags CPython 3.14 CPython 3.14 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
deba7b85448bf4cfabf2e097f3d42e51a45ba5d531421f28fefecf542e0aa9d5
BLAKE2b-256 checksum
How to use checksums
e219070292b72b2aba95e8c18aec301d978dcc23c6b518f08e76223aee612f02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL sentencepiece-0.2.3-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.7 MB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
2e39d12eead4e417a6a2e852305f890fd7f09bf48b2577a4e336285ae24439ab
BLAKE2b-256 checksum
How to use checksums
0314bf300d47736e8cd161bbbb0fb39a36e52d3043f26b3316f811cb0df39a18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL sentencepiece-0.2.3-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 1.6 MB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
e64c49a30001245702035aba15ff3833895d3598228dd9f980df3d146dc4fd33
BLAKE2b-256 checksum
How to use checksums
057ae0fab6eb0b0488943ccb620f12c18e5bdcc7a3d1ddd868b2232519ec0c70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp314-cp314t-macosx_11_0_arm64.whl

Download URL sentencepiece-0.2.3-cp314-cp314t-macosx_11_0_arm64.whl
Size 1.4 MB
Tags CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5ea5e9c9b40bb7e9ff64151071ab04365890da2e1edaa1d7e1a131ffdb735509
BLAKE2b-256 checksum
How to use checksums
8a40e55b496924e55f954d4ae4988785728ec514d543cbf650be0eb4eaf076b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp314-cp314-win_arm64.whl

Download URL sentencepiece-0.2.3-cp314-cp314-win_arm64.whl
Size 2.0 MB
Tags CPython 3.14 Windows ARM64
SHA-256 checksum
How to use checksums
39ce776c5564192c4361085f10cfe3f1bcc0749feab314060b2bbb4244266dec
BLAKE2b-256 checksum
How to use checksums
4d4297d3e65a74a4a68a2b1ee15ab7fd1af21258edafbbc2213388526835cb8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp314-cp314-win_amd64.whl

Download URL sentencepiece-0.2.3-cp314-cp314-win_amd64.whl
Size 1.8 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
0d1235ccd36c3e8c2021355258b47866c694a55003a89f00701c513eac1aef06
BLAKE2b-256 checksum
How to use checksums
105f54ded99266afba048f53d7cd0f6383178172415005dff5f298cb13786145
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL sentencepiece-0.2.3-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.7 MB
Tags CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
22dce81a65b8a1819eef9fef4970d6581ea0cbde7f58fbbbb42521535eba15e2
BLAKE2b-256 checksum
How to use checksums
adb34269e1c4494b9a17ed6d11a072b3ae52786eac9084bb5c18cdfa9434b5a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL sentencepiece-0.2.3-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 1.6 MB
Tags CPython 3.14 Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
9f77802993eb51a08e856278f73894615b9a6cc3244857fcf962bc657578f591
BLAKE2b-256 checksum
How to use checksums
6b79918626ea30fe00370ae34ed297189d5572a7b190019ee565074ad2d249d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp314-cp314-macosx_11_0_arm64.whl

Download URL sentencepiece-0.2.3-cp314-cp314-macosx_11_0_arm64.whl
Size 1.4 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ba4dfdbb2972e42d01ad32fe03788717e94d92830f981b7895835e65bfe92b2c
BLAKE2b-256 checksum
How to use checksums
a75b267e83f3990d0ef941141cb1bb9d0ed4c595623bb07ee5d78ee78aa05ee4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp313-cp313-win_arm64.whl

Download URL sentencepiece-0.2.3-cp313-cp313-win_arm64.whl
Size 1.9 MB
Tags CPython 3.13 Windows ARM64
SHA-256 checksum
How to use checksums
01e62cf99d3af7950cff04986c7e58dd4cd376fcf2367cd1c5314182d5f4adc5
BLAKE2b-256 checksum
How to use checksums
001812f01c575ea8afaa459959b9f71175c2caa9268639defe367db6d66a89bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp313-cp313-win_amd64.whl

Download URL sentencepiece-0.2.3-cp313-cp313-win_amd64.whl
Size 1.7 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
84e9def430ca8cc848b84adb304ffb77bff151cfc7dc66eb881f0385258f536b
BLAKE2b-256 checksum
How to use checksums
a33941b3c56beb8ced46bfb346a638ca588741fcd10b6e1143d9143787e1c66d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL sentencepiece-0.2.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.7 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
4d82f2a0f704f5d0cf027bc8cc5ad49e23c11a9cc0b5bd08ca51985917963bf5
BLAKE2b-256 checksum
How to use checksums
8f7e78634050dcac5c3a6aedd6c315b83ce6bd466ccebf68f31a57d8d5655900
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL sentencepiece-0.2.3-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 1.6 MB
Tags CPython 3.13 Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
dfc31f9f133a2712d396efa94d666c2ad83d5611ce34f11339429c6831253014
BLAKE2b-256 checksum
How to use checksums
bb31a06474a3e0dc8366873fd10b7bbf690b9ad9b00603e02e5f14a370c74ed3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp313-cp313-macosx_11_0_arm64.whl

Download URL sentencepiece-0.2.3-cp313-cp313-macosx_11_0_arm64.whl
Size 1.4 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
80fe42d6ecd3860ee43327de31687f222af8e93f7d66e248d241cf9a0466eb73
BLAKE2b-256 checksum
How to use checksums
4e867ccc32fa2059e6d9217e31fe6d502dcb24a5760013f850292f59b85dc115
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp312-cp312-win_arm64.whl

Download URL sentencepiece-0.2.3-cp312-cp312-win_arm64.whl
Size 1.9 MB
Tags CPython 3.12 Windows ARM64
SHA-256 checksum
How to use checksums
ceaf9a73f7e1672990547e8efe5bb79ea61884a8fe24600662d12e3a8aaf1a5b
BLAKE2b-256 checksum
How to use checksums
e45c6f921049ef4136e360437d370396ac36b927ce1be0184ddbeca50581580d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp312-cp312-win_amd64.whl

Download URL sentencepiece-0.2.3-cp312-cp312-win_amd64.whl
Size 1.7 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
972af959c63cde446210a8935524806820c253afa4b0a97d83c206b857085f44
BLAKE2b-256 checksum
How to use checksums
b57847be22c27976afed9f88cb9bcdb225abb37991c1ff442a9234e64e7a3d23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL sentencepiece-0.2.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.7 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
cc3189b79c1ffda767f71b04238c27ac746f3b7abc263eab9a41c4cf46aee49e
BLAKE2b-256 checksum
How to use checksums
517242952e5b9f254aa2952c04360b38ed614ca4f5600ee2b0cf8e1c0f6661c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL sentencepiece-0.2.3-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 1.6 MB
Tags CPython 3.12 Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
a6b735a8027b998c163e540fdde66ac0bb95fc471f6f4165c8df35fb45385116
BLAKE2b-256 checksum
How to use checksums
3126fb6572cc96090953051089f8e4260a455b6b0c7378bb06fb87725224ce61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp312-cp312-macosx_11_0_arm64.whl

Download URL sentencepiece-0.2.3-cp312-cp312-macosx_11_0_arm64.whl
Size 1.4 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9b39b16b889c9d3be4f00f1a0a4283ee81ad8af745d48023e5ab18c724019c08
BLAKE2b-256 checksum
How to use checksums
f8a98dbb891f51a80f1f47afa3d5336b165e269c4fa87f47b7fba6fc34a4a6a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp311-cp311-win_arm64.whl

Download URL sentencepiece-0.2.3-cp311-cp311-win_arm64.whl
Size 1.9 MB
Tags CPython 3.11 Windows ARM64
SHA-256 checksum
How to use checksums
ec5c6a53f9f7adfe6e7f62b12696280632c0da2352a696b436ae4152f72ff706
BLAKE2b-256 checksum
How to use checksums
c86b939dca65c0eee57be23a01c35b0264656dddf3b2fa60b0af8051dd548464
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp311-cp311-win_amd64.whl

Download URL sentencepiece-0.2.3-cp311-cp311-win_amd64.whl
Size 1.7 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
a01e76cf49a0c1abc527c4e5fd6d3a87a3139a1d3ad2d5761567179a70805cce
BLAKE2b-256 checksum
How to use checksums
c1ed8c25ed68a0e9380813f880b0bc3d986f232191e0989d035253c8deb8cfbf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL sentencepiece-0.2.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.7 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
141dc0bef1e28a5cf7e41c8354ad6cc14525758278045286dcb5429b9906d39f
BLAKE2b-256 checksum
How to use checksums
0f907a01161697ff2a6dc1968a735b7ea7fefd7eb09827d90242923ff76e33fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL sentencepiece-0.2.3-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 1.6 MB
Tags CPython 3.11 Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
855b047e02fb9c7aae2f673f5c1adbd42a4a0e8ce77e5090d14ff26f9282749d
BLAKE2b-256 checksum
How to use checksums
c24f6db415ccb1d9508becda7e56092f63f24972dea0605fe94a8c1d9d4b5075
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp311-cp311-macosx_11_0_arm64.whl

Download URL sentencepiece-0.2.3-cp311-cp311-macosx_11_0_arm64.whl
Size 1.4 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6b94ccd8554338970e1d73959a7e3ed4d110a60dab95d459990b30a508fa0998
BLAKE2b-256 checksum
How to use checksums
37fa02579970d01a0e92619967c7c2401839e3f3806fb1852d3bb8ae0e7013c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp310-cp310-win_arm64.whl

Download URL sentencepiece-0.2.3-cp310-cp310-win_arm64.whl
Size 1.9 MB
Tags CPython 3.10 Windows ARM64
SHA-256 checksum
How to use checksums
65f26939063414c5f57a46a625789e9b32f952a800490d5cce6d4c4ad0094fff
BLAKE2b-256 checksum
How to use checksums
c56bc9028d221ee091978d9960f0337a58cee3e2140d8477b00ae2e25a43568b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp310-cp310-win_amd64.whl

Download URL sentencepiece-0.2.3-cp310-cp310-win_amd64.whl
Size 1.7 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
901f38530a93e14505bfa3279c8a4705158f30af406bc2721cf3ffd7175170c2
BLAKE2b-256 checksum
How to use checksums
7abb736b8a6f08294fded810483abfe649ccbf71c2e373548e29913945b7e864
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL sentencepiece-0.2.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.7 MB
Tags CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
21cb90585b2d9a1cf78c5e889af0a12b35536dc65e2f0ba2daf540c60d431c87
BLAKE2b-256 checksum
How to use checksums
1406e0d67a135e58a5999429553732bd0f74df5918047b02d012d1cf806419ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL sentencepiece-0.2.3-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 1.6 MB
Tags CPython 3.10 Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
dc4d17ad8728f47062496a7c03e000bb37de9c6741f8423b822d51e4f2f86fcf
BLAKE2b-256 checksum
How to use checksums
9c1e1d29b3b0c6d7c924842f75a99a01722e6fb0faf632834b9108941f4ac8e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Release files / sentencepiece-0.2.3-cp310-cp310-macosx_11_0_arm64.whl

Download URL sentencepiece-0.2.3-cp310-cp310-macosx_11_0_arm64.whl
Size 1.4 MB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
51ae35f32ddc832b8ff5f57dd69dae5a814ab6b6e027c83e6f5632335bf21e98
BLAKE2b-256 checksum
How to use checksums
29ff2da9d340530f2fdb54449865aeb1eb6b3294a0f88773ac5c856397190594
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.15

Security for sentencepiece 0.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.3 This release

41 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page