Skip to main content

laghu-rs

The optional Rust core of laghu. laghu loads model2vec static embedding models with far less memory than model2vec and gives the same vectors. With laghu-rs installed, laghu runs normalization, pre-tokenization, the Unigram Viterbi search and mean pooling in Rust threads, over the same memory-mapped files. It also tokenizes BERT WordPiece models (a BertNormalizer, a BertPreTokenizer and a WordPiece model) in Rust, with a port of FastWordPiece from model2vec-rs, MIT, copyright (c) 2025 The Minish Lab (LICENSE-model2vec-rs).

pip install laghu-rs     # or: pip install 'laghu[rust]'

Nothing else changes: laghu finds laghu-rs and uses it for the models it supports. Output is identical, bit for bit, to laghu's pure-Python path and to model2vec 0.9.

500-character chunks on the 14 cores of an M3 Max, best of three runs of laghu.bench.speed, measured on 2026-10-24 at a load average of 6.5 to 9. potion-multilingual-128M (Unigram):

path chunks/s private memory
laghu with laghu-rs 42,385 72 MB
laghu, pure Python 1,940 67 MB
model2vec 0.9 21,105 1,369 MB

potion-base-8M (WordPiece):

path chunks/s private memory
laghu with laghu-rs 432,938 81 MB
laghu with tokenizers 55,514 93 MB
model2vec 0.9 55,600 140 MB

The figure laghu-rs 0.1.0 gave for model2vec, 5,276 chunks/s, was measured with tokenizers on one core.

laghu falls back to pure Python when laghu-rs is not installed or LAGHU_RUST=0 is set. It keeps Python's normalization and pre-tokenization when the tokenizers crate inside laghu-rs is not the same version as the installed Python tokenizers, or when the two disagree on a set of probe texts. It tokenizes a WordPiece model with tokenizers under the same two conditions, and for any pipeline the port does not reproduce.

laghu-rs needs Python 3.11 or later. Building it from source needs Rust and a C compiler.

Metadata

Release files for laghu-rs 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for laghu-rs 0.2.1
File Size Uploaded Provenance Actions
laghu_rs-0.2.1.tar.gz 17.9 kB Without provenance Details for laghu_rs-0.2.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for laghu-rs 0.2.1
File Actions
laghu_rs-0.2.1-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for laghu_rs-0.2.1-cp311-abi3-win_amd64.whl
laghu_rs-0.2.1-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.11 abi3 Linux glibc 2.17+ x86-64 Details for laghu_rs-0.2.1-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
laghu_rs-0.2.1-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details for laghu_rs-0.2.1-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
laghu_rs-0.2.1-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for laghu_rs-0.2.1-cp311-abi3-macosx_11_0_arm64.whl
laghu_rs-0.2.1-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details for laghu_rs-0.2.1-cp311-abi3-macosx_10_12_x86_64.whl

Total release size: 7.5 MB

Release files / laghu_rs-0.2.1.tar.gz

Download URL laghu_rs-0.2.1.tar.gz
Size 17.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a4377ee5e329cda9512e9661941b53c4cfb350e9d8ec87b28bdd570e2fd4c53f
BLAKE2b-256 checksum
How to use checksums
ae564d3f1b82177e8ef9ba6efea1345b09955a690977e437fca24eef98bb3ab8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / laghu_rs-0.2.1-cp311-abi3-win_amd64.whl

Download URL laghu_rs-0.2.1-cp311-abi3-win_amd64.whl
Size 1.4 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
f0325927101363d06a7ebf5b44fa78b77929e53eedcb18d51a45918eb5a268c0
BLAKE2b-256 checksum
How to use checksums
52cf78c00166de683b5036bf2b0fae898390c7f9ba09945dd17558ef89e2817f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / laghu_rs-0.2.1-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL laghu_rs-0.2.1-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.6 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
658b38cc1f4a93609047dc839d045701533e7f88f662a0e1347286d66616224e
BLAKE2b-256 checksum
How to use checksums
8802237d622ba019054205349832d08bdab6c2202318bd735a0419fd667a1f72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / laghu_rs-0.2.1-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL laghu_rs-0.2.1-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 1.5 MB
Tags CPython 3.11 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
5c610af45b1840b570b17e236144385f94df86faf78f3eaaf497ac75126ec7b6
BLAKE2b-256 checksum
How to use checksums
f126c05da63168b6106aa8d971478684701ac5f985af5790e7a1f37ad8b3654f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / laghu_rs-0.2.1-cp311-abi3-macosx_11_0_arm64.whl

Download URL laghu_rs-0.2.1-cp311-abi3-macosx_11_0_arm64.whl
Size 1.4 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
46ea736621f683bf8bca17e0ae59f0195cdc0d2cc092a3295dbd934267c59348
BLAKE2b-256 checksum
How to use checksums
1325513c2ce5e0210386dece2b7db7525235bc9e56ea3b722aead24bf841b5d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Release files / laghu_rs-0.2.1-cp311-abi3-macosx_10_12_x86_64.whl

Download URL laghu_rs-0.2.1-cp311-abi3-macosx_10_12_x86_64.whl
Size 1.5 MB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
2f5df9a9abe99702d778ed9c75fb5b356d0de23941fa24ae84b69f15c6d97ae0
BLAKE2b-256 checksum
How to use checksums
ded0fb6a7bfc42f647520c09d7eb38384ca255cdc0a7b8adbc90062f90e883fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Security for laghu-rs 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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