Curated Tokenizers is a lightweight Python library by Explosion (creators of spaCy) that provides efficient and production-ready implementations of various piece tokenization algorithms, including Byte-Pair Encoding (BPE), WordPiece, and SentencePiece. It focuses on fast, reliable tokenization suitable for integrating into larger NLP pipelines. The library is currently at version 2.0.0, with an active but less frequent release cadence focused on performance and stability.
pip install curated-tokenizersVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to instantiate and use a `ByteBPEProcessor` for encoding and decoding text. Note that while this example creates a processor in memory, typical usage involves loading pre-trained models from files using `from_file` methods (e.g., for `vocab.json` and `merges.txt`).
Change `pip install cutlery` to `pip install curated-tokenizers` and update all `from cutlery import ...` to `from curated_tokenizers import ...`.
Install with `pip install curated-tokenizers[sentencepiece]` if you plan to use `SentencePieceProcessor`.
For production or realistic examples, use `Processor.from_file(path_to_model)` and ensure you have the necessary model files.
Thoroughly test existing tokenization logic after upgrading to v2.0.0 to ensure consistent output, especially for Byte BPE.
Ensure all related packages (`curated-tokenizers`, `curated-transformers`, and `spaCy`) are updated to their latest compatible versions. If updating doesn't resolve it, a temporary fix might involve downgrading `curated-tokenizers` or `curated-transformers` to known compatible versions as indicated in project issue trackers.
Install the required build tools for your operating system (e.g., 'Build Tools for Visual Studio' on Windows, `build-essential` on Linux, Xcode Command Line Tools on macOS). Alternatively, try using a Python version for which pre-built wheels are readily available, or install `curated-transformers` as a dependency, which often handles `curated-tokenizers` installation.
Install the library using `pip install curated_tokenizers`. Verify that your Python environment is correctly activated and that the import statement, such as `import curated_tokenizers` or `from curated_tokenizers import ...`, is spelled correctly.
Ensure both `spaCy` and `spacy-curated-transformers` are installed and compatible. Verify the `factory` name for the transformer component in your spaCy configuration, typically `'curated-transformer'`. For new projects, use `python -m spacy init fill-curated-transformer` to generate a correctly configured pipeline.