Expand description
Safe Rust bindings for KenLM language model inference.
The crate compiles KenLM’s query-only C++ sources and exposes a small Rust API for loading ARPA or binary models, scoring sentences, inspecting vocabulary membership, and doing explicit stateful scoring.
§Safety model
The public API is safe Rust. C++ exceptions are caught in the C++ shim and
converted into KenlmError values. Opaque State values carry an
internal model identity token, so stateful scoring rejects states created by
a different Model before calling into KenLM. The raw KenLM model handle
is owned by Model and released exactly once in Drop.
Structs§
- Config
- Runtime loading options for KenLM models.
- Full
Score - Detailed score metadata for one state transition.
- Model
- A KenLM model loaded from an ARPA or KenLM binary file.
- State
- Opaque KenLM state memory used for incremental scoring.
- Token
Score - Sentence-level per-token score, including OOV metadata.
Enums§
- Arpa
Load Complain - How loudly KenLM should complain about loading ARPA instead of binary data.
- Kenlm
Error - Errors returned by the KenLM bindings.
- Load
Method - How KenLM should bring binary model data into memory.