skillfed

pynini

Finite-state grammar compilation

pynini v2.1.7 239.1K downloads/30d#8,925 on PyPI
Permissive license Apache 2.0 AGING released

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 pynini

uv

uv add pynini

poetry

poetry add pynini

Installing 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

Development Status :: 5 - Production/StableEnvironment :: ConsoleEnvironment :: Other EnvironmentIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Scientific/Engineering :: Artificial IntelligenceTopic :: Scientific/Engineering :: MathematicsTopic :: Software Development :: Libraries :: Python ModulesTopic :: Text Processing :: Linguistic

Tags

finite-state transducers pythongrammar compilation weighted automatalinguistic rule compilationmorphology nlp libraryfst grammar rulescomputational linguistics toolkitlanguage rule transducers
finite-state-automatacomputational-linguisticsmorphology

More Python Modules packages