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.3

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.3
File Size Uploaded Provenance Actions
laghu_rs-0.2.3.tar.gz 18.5 kB Without provenance Details for laghu_rs-0.2.3.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for laghu-rs 0.2.3
File Actions
laghu_rs-0.2.3-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for laghu_rs-0.2.3-cp311-abi3-win_amd64.whl
laghu_rs-0.2.3-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.3-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
laghu_rs-0.2.3-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.11 abi3 Linux glibc 2.17+ ARM64 Details for laghu_rs-0.2.3-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
laghu_rs-0.2.3-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for laghu_rs-0.2.3-cp311-abi3-macosx_11_0_arm64.whl
laghu_rs-0.2.3-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details for laghu_rs-0.2.3-cp311-abi3-macosx_10_12_x86_64.whl

Total release size: 7.5 MB

Release files / laghu_rs-0.2.3.tar.gz

Download URL laghu_rs-0.2.3.tar.gz
Size 18.5 kB
Tags Source
SHA-256 checksum
How to use checksums
95cfb2537520ccef301365629bb8c4ddd0f49a7effbbc304c3606e1401116356
BLAKE2b-256 checksum
How to use checksums
b920b094c50616802853b107b7e9c4754aaff83dea528b63f984e4ae369e7c36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

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

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

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

Download URL laghu_rs-0.2.3-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
6bbc886bdc93fe86e16cce7b6c07ac42695d1a152f0e6a49bd6977e88be416b3
BLAKE2b-256 checksum
How to use checksums
728601abfcfcaf089bbd717bf0f2dc0c94dc950dc411430133dcfefde49b5a07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

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

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

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

Download URL laghu_rs-0.2.3-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
362743e35183e63d19ea6ad606417853c39f44e53fb74afcf1784d59e84c7423
BLAKE2b-256 checksum
How to use checksums
aa86b15bf5508f3e7ee0eb3cdc7e9515dd2488bd8594a08da8c48494da13edb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

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

Download URL laghu_rs-0.2.3-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
b50acbea4e5cbb199e103b9860ffa20e9bd32ca8728cd903961d066a2660e9e7
BLAKE2b-256 checksum
How to use checksums
08f1ec8ea53e5392ae74f57fcfeaa084f574f65a192d0c7d8d0dbcd303238567
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Security for laghu-rs 0.2.3

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