Skip to main content

kaldingram

kaldingram provides Python and CLI tools to:

  • train Kneser-Ney back-off n-gram language models in ARPA format
  • entropy-prune ARPA language models

The implementation is based on Kaldi WSJ scripts and matches SRILM-style behavior.

Install

pip install kaldingram

CLI Usage

Train an n-gram LM

kaldingram train --ngram-order 4 --text corpus.txt --lm 4gram.arpa

Or stream text from stdin and write ARPA to stdout:

cat corpus.txt | kaldingram train --ngram-order 3 > 3gram.arpa

Prune an n-gram LM

kaldingram prune --threshold 1e-8 --lm 4gram.arpa --write-lm 4gram_pruned.arpa

Evaluate perplexity

kaldingram ppl --lm 4gram.arpa --text test.txt
cat test.txt | kaldingram ppl --lm 4gram.arpa

Development

Build package locally:

python -m pip install --upgrade build
python -m build

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kaldingram-0.1.2.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kaldingram-0.1.2-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file kaldingram-0.1.2.tar.gz.

File metadata

  • Download URL: kaldingram-0.1.2.tar.gz
  • Upload date:
  • Size: 21.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kaldingram-0.1.2.tar.gz
Algorithm Hash digest
SHA256 73bedc61348cb89661fe2de008c174aa79fce3127efe4b215108570914222126
MD5 064f5995766c62955f837f16d8dbbec2
BLAKE2b-256 8bdc5b34747f60d087b35b12fe6bc99985629a341508dfde20ee95b58b305403

See more details on using hashes here.

File details

Details for the file kaldingram-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: kaldingram-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kaldingram-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 348fa8e6cd1ec9a09afc75f5df3857f11381ec88b0898d654f2246e5895b3666
MD5 605647a0469e246c4b42ef36d8b533a3
BLAKE2b-256 56f1b1d682e97e0f3b9773ec5c5ee47617d72be868aad807119c1c5be3a21b0f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page