pynini
Finite-state grammar compilation
What it is and what it does
Pynini is a Python extension module that compiles linguistic grammar rules into weighted finite-state transducers (FSTs), pushdown transducers, and multi-pushdown transducers. It wraps OpenFst and provides a high-level interface for constructing and manipulating automata-based language models. The library is designed for computational linguists and NLP researchers who need to express complex morphological, phonological, or syntactic transformations as formal automata.
The package has no runtime dependencies beyond OpenFst itself (which must be installed separately on most platforms). Installation on Linux via pip uses precompiled manylinux wheels for Python 3.9–3.14, but Windows and macOS users typically rely on conda-forge. The library is stable and production-ready, though the last release was 344 days ago, suggesting a mature but slowly-evolving codebase.
Use it for:
- Build morphological analyzers and generators for inflectional languages by encoding rules as weighted transducers.
- Implement phonological rule systems that transform phonemic representations into surface forms.
- Compile domain-specific grammar rules for text normalization, transliteration, or dialect conversion.
- Prototype and test finite-state models of linguistic phenomena before deploying them in larger NLP pipelines.
- Combine multiple FSTs to create complex multi-stage language processing workflows.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Pynini compiles grammar rules into weighted finite-state transducers and related automata structures, enabling programmatic construction and application of complex linguistic transformations.
Yes, if you are working on computational linguistics, morphology, or formal language tasks that map naturally to finite-state automata. The library is stable, permissively licensed, and well-suited for research and production use. No, if your project does not require explicit FST manipulation or if you lack the ability to install OpenFst and a C++17 compiler on your system—the installation friction is non-trivial for casual users.
Install
pynini on PyPI
pip
pip install pyniniuv
uv add pyninipoetry
poetry add pyniniInstalling pynini
Before you install
Medium friction: requires a C++17 compiler and OpenFst 1.8.4 with grm extensions pre-installed on the system. Precompiled manylinux wheels available for Python 3.9–3.14 on x86_64 Linux, but Windows and macOS users should use conda-forge. Last release 344 days ago; maintenance status is aging.
License in practice
Apache 2.0 permissive license allows commercial and private use with minimal restrictions. You must retain license notices but face no copyleft obligations.
Quickstart
pip install pynini
import pynini
# Create a simple FST
fst = pynini.string_map([("hello", "hi")])
result = pynini.shortestpath(fst)
OpenFst 1.8.4 with grm extensions must be installed and discoverable by the build system; a C++17 compiler (GCC ≥7 or Clang ≥700) is required to build from source.
Verify before relying
- Whether precompiled wheels include OpenFst or if it must be installed separately on Linux.
- Current maintenance status and whether the 344-day gap since last release signals active development or dormancy.
- Availability of comprehensive documentation or tutorials beyond the cited 2016 paper.
Package facts
| License | Apache 2.0 (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | aging — 344 days since the last release |
| First released | |
| Downloads | 239,094/month — #8,925 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pynini-2.1.7-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; pynini-2.1.7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; pynini-2.1.7-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; pynini-2.1.7-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; pynini-2.1.7-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; pynini-2.1.7-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; pynini-2.1.7-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; pynini-2.1.7-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; pynini-2.1.7-pp310-pypy310_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; pynini-2.1.7-pp311-pypy311_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Keywords: computational linguistics, morphology, natural language processing, language
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
nemo-text-processingConverts text to normalized form and back…
permissive · top 15,000 on PyPI
PyMeta3PyMeta3 compiles pattern-matching grammars…
permissive · top 15,000 on PyPI
AutomatAutomat provides a Python library for building…
permissive · top 5,000 on PyPI
konlpyKoNLPy provides Korean natural language…
copyleft · top 15,000 on PyPI
wetextNormalizes and denormalizes text in Chinese,…
permissive · top 15,000 on PyPI
kaldifstPython wrapper for OpenFst and Kaldi…
permissive · top 15,000 on PyPI
nltkNLTK is a Python library for natural language…
permissive · top 1,000 on PyPI
TatSuTatSu compiles extended EBNF grammars into…
permissive · top 5,000 on PyPI
ParsleyParsley is a PEG-based parsing library that…
permissive · top 5,000 on PyPI
tree-sitter-pythonProvides a Python grammar for tree-sitter,…
permissive · top 5,000 on PyPI