tensorflow-text
TF.Text is a TensorFlow library of text related ops, modules, and subgraphs.
What it is and what it does
TensorFlow Text is a library of text-related operations and tokenizers designed to run within TensorFlow's computation graph. It provides utilities for Unicode normalization, case folding, tokenization (whitespace, Unicode script-based, and character-level), n-gram generation, and other text preprocessing tasks commonly needed for NLP models. The key advantage is that all preprocessing happens inside the TensorFlow graph, ensuring identical behavior between training and inference without needing separate preprocessing scripts.
The library depends solely on TensorFlow and is distributed as precompiled wheels for multiple Python versions (3.9–3.13) and architectures (x86_64, aarch64, macOS ARM64). It handles UTF-8 strings natively and supports operations like byte offset tracking during tokenization, integration with tf.data pipelines, and Keras API compatibility for ragged tensor inputs.
Use it for:
- Normalize and tokenize text within a TensorFlow model pipeline to ensure consistent preprocessing at training and serving time.
- Split multilingual or punctuation-heavy text using Unicode script boundaries instead of simple whitespace splitting.
- Extract byte offsets during tokenization to trace tokens back to their original positions in source text.
- Build end-to-end NLP models in Keras that accept raw text and produce token sequences without external preprocessing.
- Handle non-ASCII Unicode text with case folding and normalization forms (NFKC, NFKD) for case-insensitive matching.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
TensorFlow Text provides text preprocessing operations and tokenizers that run within the TensorFlow computation graph, enabling consistent text handling across training and inference without external preprocessing scripts.
Yes. TensorFlow Text is actively maintained, widely used (top 5000 PyPI packages), has no known vulnerabilities, and solves a real problem—keeping text preprocessing inside the TensorFlow graph. Install it if you are building NLP models with TensorFlow and need tokenization or text normalization; ensure your tensorflow-text version matches your TensorFlow minor version.
Install
tensorflow-text on PyPI
pip
pip install tensorflow-textuv
uv add tensorflow-textpoetry
poetry add tensorflow-textInstalling tensorflow-text
Before you install
Medium install friction due to compiled wheel dependencies across multiple Python versions and architectures. Active maintenance with recent releases; repository shows 1293 stars and last commit on 2026-08-12.
License in practice
Apache 2.0 permissive license allows commercial and private use with minimal restrictions; suitable for most projects.
Quickstart
pip install tensorflow-text==2.20.1
import tensorflow as tf
import tensorflow_text as text
tokenizer = text.WhitespaceTokenizer()
tokens = tokenizer.tokenize(['hello world'])
print(tokens.to_list())
Requires TensorFlow installed; version 2.20.1 of tensorflow-text should match the minor version of your TensorFlow installation (e.g., tensorflow==2.20.x).
Verify before relying
- Exact Python version requirements beyond the classifiers (3.9, 3.10, 3.11, 3.12, 3.13 listed but requires_python field is null)
- Whether all tokenizers and ops are available on all supported platforms or if some are platform-specific
Package facts
| License | Apache 2.0 (permissive) |
| Python support | not specified |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — tensorflow |
| Maintenance | actively maintained — 157 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 5,745,982/month — #2,043 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: tensorflow_text-2.20.1-cp310-cp310-macosx_11_0_arm64.whl; tensorflow_text-2.20.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; tensorflow_text-2.20.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; tensorflow_text-2.20.1-cp311-cp311-macosx_11_0_arm64.whl; tensorflow_text-2.20.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; tensorflow_text-2.20.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; tensorflow_text-2.20.1-cp312-cp312-macosx_11_0_arm64.whl; tensorflow_text-2.20.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; tensorflow_text-2.20.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; tensorflow_text-2.20.1-cp313-cp313-macosx_11_0_arm64.whl; tensorflow_text-2.20.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; tensorflow_text-2.20.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; tensorflow_text-2.20.1-cp39-cp39-macosx_11_0_arm64.whl; tensorflow_text-2.20.1-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.whl; tensorflow_text-2.20.1-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Keywords: tensorflow, text, machine, learning
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
matchMaps tokenized words and phrases back to their…
permissive · top 5,000 on PyPI
tokenizerTokenizes Icelandic text into words,…
permissive · top 15,000 on PyPI
procesProces provides text preprocessing functions…
permissive · top 15,000 on PyPI
seqioSeqIO builds scalable data pipelines for…
permissive · top 15,000 on PyPI
jieba3kPerforms Chinese word segmentation, breaking…
unclear · top 15,000 on PyPI
sentencepieceSentencePiece is an unsupervised text tokenizer…
permissive · top 1,000 on PyPI
segtokSplits Indo-European text into sentences and…
permissive · top 15,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
urduhackUrduhack provides NLP preprocessing,…
permissive · top 15,000 on PyPI
emotExtracts emojis and emoticons from text,…
unclear · top 15,000 on PyPI