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

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.2
File Size Uploaded Provenance Actions
laghu_rs-0.2.2.tar.gz 18.1 kB Without provenance Details for laghu_rs-0.2.2.tar.gz

Built distributions (wheels)

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

Total release size: 7.5 MB

Release files / laghu_rs-0.2.2.tar.gz

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

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

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

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

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

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

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

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

Download URL laghu_rs-0.2.2-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
085ea068583f23828837feede6d60941c4905a35f4bbcfe96fe8c627da0137c7
BLAKE2b-256 checksum
How to use checksums
297ca3e7283950e4a4f0505da6306974a2bd1019e1589e1eab9c5fd18427284c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

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

Download URL laghu_rs-0.2.2-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
1d48082d0c59fae4951d791190f8e863ea3306d8288abd7519dcd14e70d8f1d4
BLAKE2b-256 checksum
How to use checksums
21ea9d17635a928c8756fdf95cd9a6a85397dad5f9d309b8528071dbad54a6e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.16.0

Security for laghu-rs 0.2.2

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