Skip to main content

Rust-based Python Tokenizer to Arrow

This project provides a tiny Python extension written in Rust for tokenizing text data directly into Arrow arrays. It uses the tokenizers library from Hugging Face and serializes the output directly into a pyarrow.LargeListArray without exposing any Encoding objects to the Python interpreter.

The primary benefit of this approach is memory efficiency. By avoiding the creation of intermediate Python lists of integers, it significantly reduces the overhead on the Python garbage collector, making it ideal for tokenizing very large datasets. This can provide a major speedup for large batch tokenization jobs, which otherwise can get bottlenecked on Python GC.

Features

  • Very simple API
  • Provides a zero-copy data transfer of resulting Arrow arrays

Setup and Installation

Prerequisites

  • Install Rust
  • Install Python

Installation Steps

uv run maturin develop

Arrow-based Tokenization

Luxical bundles in the arrow-tokenize Rust extension package, which exposes ArrowTokenizer, a fast tokenizer abstraction that operates on Arrow arrays and returns Arrow arrays. This avoids Python‑level overhead during large batch tokenization. Compared to the Python API of the tokenizers library, arrow-tokenize dramatically reduces pressure on the Python garbage collector and can deliver substantial speedups in bulk tokenization.

Key Python API functions:

  • load_arrow_tokenizer_from_pretrained(tokenizer_id: str) -> ArrowTokenizer
  • load_arrow_tokenizer_from_file(tokenizer_file: Path | str) -> ArrowTokenizer
  • arrow_tokenize_texts(texts: list[str], arrow_tokenizer: ArrowTokenizer, *, batch_size=4096, add_special_tokens=False, progress_bar=True) -> pa.ChunkedArray

Minimal example:

from luxical.tokenization import (
    load_arrow_tokenizer_from_pretrained,
    arrow_tokenize_texts,
)

tok = load_arrow_tokenizer_from_pretrained("google-bert/bert-base-uncased")
chunks = arrow_tokenize_texts([
    "hello world",
    "lexical embeddings are fast",
], tok, batch_size=2, add_special_tokens=False, progress_bar=False)

Release Notes

v1.0.2 - 2025-11-24

  • Clarify supported Python versions in pyproject.toml

v1.0.1 - 2025-11-24

  • Correct license metadata in pyproject.toml

v1.0.0 - 2025-09-22

  • Initial release. Intended to be the only release until we need to bump dependency versions.

Metadata

Release files for arrow-tokenize 1.0.2

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

Built distributions (wheels)

Table of built distributions (wheels) for arrow-tokenize 1.0.2
File
arrow_tokenize-1.0.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details
arrow_tokenize-1.0.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ ARM64 Details
arrow_tokenize-1.0.2-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
arrow_tokenize-1.0.2-cp313-cp313-macosx_10_12_x86_64.whl CPython 3.13 CPython 3.13 macOS 10.12+ x86-64 Details
arrow_tokenize-1.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
arrow_tokenize-1.0.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ ARM64 Details
arrow_tokenize-1.0.2-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
arrow_tokenize-1.0.2-cp312-cp312-macosx_10_12_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.12+ x86-64 Details
arrow_tokenize-1.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
arrow_tokenize-1.0.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ ARM64 Details
arrow_tokenize-1.0.2-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
arrow_tokenize-1.0.2-cp311-cp311-macosx_10_12_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.12+ x86-64 Details

Total release size: 26.9 MB

Release files / arrow_tokenize-1.0.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL arrow_tokenize-1.0.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.4 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
308cb62adab2ddd93cf96934df4d36e92443020139e4a75cfcb94195777c1e91
BLAKE2b-256 checksum
How to use checksums
99ae4607c216bf9577a5b83dc7bf9a6501e121150faf4e7a73aca70bfae926ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / arrow_tokenize-1.0.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL arrow_tokenize-1.0.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.3 MB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
919adf87009569f32a1a57aa7c0b2f1a9219c497be3687b7677eacdbaca4a4cc
BLAKE2b-256 checksum
How to use checksums
67f4f2047a03d4334e81238967ab39ff1b07f874762deca45ca11dbcb87855fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / arrow_tokenize-1.0.2-cp313-cp313-macosx_11_0_arm64.whl

Download URL arrow_tokenize-1.0.2-cp313-cp313-macosx_11_0_arm64.whl
Size 2.1 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0770b655fbb38811d1aed5f845633b9149066d10f45de6a625fe632417cdaca3
BLAKE2b-256 checksum
How to use checksums
99d45d440c4acafc9c10cdbda4ad70a0cc77ecc9a3262f13f565646a7c315017
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / arrow_tokenize-1.0.2-cp313-cp313-macosx_10_12_x86_64.whl

Download URL arrow_tokenize-1.0.2-cp313-cp313-macosx_10_12_x86_64.whl
Size 2.2 MB
Tags CPython 3.13 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
4d3407f960414b9348630db7d3d7b2911c2bf07141a3922be8daecaced535cc8
BLAKE2b-256 checksum
How to use checksums
0f0d95777ad5cb201b5c41ea308da6057799193e4a4c65980c6d5c14e3657660
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / arrow_tokenize-1.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL arrow_tokenize-1.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.4 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
6106213a724c628a48f169e6bdd43af4d3e69463b7234b968ca14636d8b56054
BLAKE2b-256 checksum
How to use checksums
a641c62edde9bdd43cdaa2574033d916c128fd0b6cfc927692c44ded31a515cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / arrow_tokenize-1.0.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL arrow_tokenize-1.0.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.3 MB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
75189a37c9439300a253156af1cf23316873a89129fabda768dc0adfbed81b7b
BLAKE2b-256 checksum
How to use checksums
45d876dbda5f38cd2aa02737bbb29a44a5aa3103e571b42c19e3f49c653d8e72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / arrow_tokenize-1.0.2-cp312-cp312-macosx_11_0_arm64.whl

Download URL arrow_tokenize-1.0.2-cp312-cp312-macosx_11_0_arm64.whl
Size 2.1 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
852c1bf7598d8627a56fd95ccad90790778633b7b655804db14b90607fcf9fe5
BLAKE2b-256 checksum
How to use checksums
5c7ebed226fd8ba41561eeb670d8179e85e85802b3073bbcd6f49270b57905c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / arrow_tokenize-1.0.2-cp312-cp312-macosx_10_12_x86_64.whl

Download URL arrow_tokenize-1.0.2-cp312-cp312-macosx_10_12_x86_64.whl
Size 2.2 MB
Tags CPython 3.12 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
99786811223c788c6e76c828503aa93fdafa18986eba20068ef4b3636794c903
BLAKE2b-256 checksum
How to use checksums
be4aa37f725a596078dc23505642f2f52fd391bfe73ff3377916529a0acea2aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / arrow_tokenize-1.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL arrow_tokenize-1.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.4 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
af1a4c694fdbae42a7dcfdd77e00495cebd56f317d48c1dd81d5725228acb0a4
BLAKE2b-256 checksum
How to use checksums
b1c28515be39c07175434b226f2899b3d2312448ef1f5ac09fa45139b5003aed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / arrow_tokenize-1.0.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL arrow_tokenize-1.0.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.3 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
2d67a45c989210bb68b80831863d99ef552ff10902c2406d724dd8381a4dc259
BLAKE2b-256 checksum
How to use checksums
8767be91604034be11bdb8831d67224158662f3033d31b87341509e5297a6bd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / arrow_tokenize-1.0.2-cp311-cp311-macosx_11_0_arm64.whl

Download URL arrow_tokenize-1.0.2-cp311-cp311-macosx_11_0_arm64.whl
Size 2.1 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
43568bd98b0f92e4a4daa581cb1ac58a0786784afb5c6367893faf2a8a03aeca
BLAKE2b-256 checksum
How to use checksums
1a7b6699ece10b4c2074205b5bbebe4a722ad636b56435df91e682b2beae80c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / arrow_tokenize-1.0.2-cp311-cp311-macosx_10_12_x86_64.whl

Download URL arrow_tokenize-1.0.2-cp311-cp311-macosx_10_12_x86_64.whl
Size 2.2 MB
Tags CPython 3.11 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
aa6b7efe4388f7fdb2556db924461ae4edd1f99a6f94c330fcc19d6a3c830dcc
BLAKE2b-256 checksum
How to use checksums
a496ca4f1330b21b95a8fff920696da07b590fa72b0be397b8002a8b9b13b822
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release history Release notifications | RSS feed

This release

1.0.2 This release

12 release files

1.0.1

12 release files

1.0.0

12 release files

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