kenlm
Self-contained static binaries of the fastest n-gram language model toolkit — download, run, done.
Download for your platform Read the tutorials
CPU-only · pthreads + memory-resident sort · no GPU is ever required
About this site (credits)
kenlm is an open-source n-gram language model toolkit written
by Kenneth Heafield
(first released 2011; see
Heafield 2011).
Its canonical home is github.com/kpu/kenlm; that's where
kenlm is developed, maintained, and bug-fixed.
This site —
github.com/ljh-sh/kenlm
— is only a static-build distribution. We don't own,
rebrand, or maintain kenlm; we just compile it as fully
self-contained static binaries for every major platform so you
can download and use it without a toolchain.
For questions, bug reports, and contributions → please go to the upstream project.
Download v0.1.0
Every archive is a fully self-contained, statically-linked binary. No system libraries to install. Works on any Linux distro (Alpine, Debian, Ubuntu, RHEL, Arch…), macOS, or Windows.
Detecting your platform…
5-minute quick start
If you just want to score text or train a model, you don't need to read anything else:
tar xzf kenlm-x86_64-linux-musl.tar.gz
cp kenlm-x86_64-linux-musl/bin/* /usr/local/bin/
cat > corpus.txt <<'EOF'
the cat sat on the mat
the cat ran fast and far
the dog sat down by the door
a small cat and a small dog
the cat and the dog sat together
EOF
lmplz -o 3 --discount_fallback < corpus.txt > model.arpa
build_binary model.arpa model.bin
echo "the cat sat" | query model.bin
# Perplexity including OOVs: 3.49
That's the whole pipeline. The full tutorials cover vocabulary
pruning, memory tuning, C++ embedding, batch scoring, and reading
every byte of kenlm output.
Tutorials
Beginner · 5 minutes
Train your first language model. Install the binaries, run
lmplz, build_binary, and query
on a tiny corpus, then learn what every line of output means.
Intermediate · tuning & integration
Order, memory, discounting, vocabulary pruning, quantization, mmap, C++ embedding, batch scoring, real-world recipes for re-ranking and perplexity evaluation.
Read the tuning tutorial →What's in v0.1.0
Seven platform targets, all built natively on GitHub Actions and verified to run on their target OS:
| target | runner | linkage |
|---|---|---|
x86_64-linux-gnu | ubuntu-latest | glibc fully static |
aarch64-linux-gnu | ubuntu-24.04-arm | glibc fully static |
x86_64-linux-musl | ubuntu-latest + alpine | musl-static, verified on Alpine |
aarch64-linux-musl | ubuntu-24.04-arm + alpine | musl-static, ARM64 Linux |
aarch64-macos | macos-14 | macos static Boost, system libc++ |
x86_64-windows | windows-latest + vcpkg | win static CRT, /MT |
aarch64-windows | windows-11-arm + vcpkg | win Windows-on-ARM |
The Linux builds ship as both glibc-static and musl-static so one archive works on every Linux distro — Alpine, Debian/Ubuntu, RHEL, Arch. The musl build is verified by running its smoke test inside Alpine on CI.
See musl-vs-glibc comparison for the bench numbers (musl is ~10 % smaller on x86_64) and the reasoning behind shipping both.