Skip to content
Read-only mirror of Pynini
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Pynini is a Python extension module which allows the user to compile, optimize, and apply grammar rules. Rules can be compiled into weighted finite state transducers, pushdown transducers, or multi-pushdown transducers. For general information and a detailed tutorial, see

Pynini is primarily developed by Kyle Gorman with the help of contributors. If you use Pynini in your research, we would appreciate if you cite the following paper:

K. Gorman. 2016. Pynini: A Python library for weighted finite-state grammar compilation. In Proc. ACL Workshop on Statistical NLP and Weighted Automata, 75-80.

(Note that some of the code samples in the paper are now out of date.)


Pynini depends on:

  • A standards-compliant C++ 11 compiler (GCC >= 4.8 or Clang >= 700)
  • The most recent version of OpenFst (at the time of writing, 1.7.2) built with the far, pdt, mpdt, and script extensions (i.e., built with ./configure --enable-grm) and headers
  • Python 2.7 or 3.6+ and headers

It is tested with: Debian Linux 4.18.10 on x86_64, GCC 7.3.0, Cython 0.29.2 and Python 2.7.13 and Python 3.7.1.

Installation instructions

Execute python install. Depending on your environment, you may need to be superuser while running this command for installation to complete.

To confirm successful installation, execute python test.

Python 3 support

Python 3 support is available as of Pynini 2.0.0.


Pynini is released under the Apache license. See LICENSE for more information.

Interested in contributing?

See CONTRIBUTING for more information.

Mandatory disclaimer

This is not an official Google product.

You can’t perform that action at this time.