Scan your whole stack
From OX Research Newsroom
Are you using laghu?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v0.4.2
laghu was last scanned on 25 Nov 2026 at version 0.4.2. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 0.4.2 LATEST | 25 Nov 2026 | No rules fired |
| 0.4.1 | 19 Nov 2026 | No rules fired |
| 0.4.0 | 24 Oct 2026 | No rules fired |
| 0.3.1 | 23 Oct 2026 | Not shown |
| 0.3.0 | 23 Oct 2026 | Not shown |
Findings for v0.4.2. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 0.4.2; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
model2vec makes static embedding models. A static embedding model changes a text into a vector. It splits the text into tokens. It finds a stored vector for each token. Then it calculates the average of these vectors. No neural network runs, so these models are very fast. Each model has two main parts: an embedding table with one row for each token, and a tokenizer that splits text into tokens.
laghu (लघु, Sanskrit for “light”) loads the same models with much less memory. It gives the same vectors as model2vec, bit for bit. A model that laghu loads has the same encode, encode_as_sequence and tokenize methods as a model2vec model. The section What is not supported gives the differences.
A process is one running program. Private memory is memory that only one process can use. model2vec copies two large parts of the model into the private memory of each process. laghu shares these parts between processes.
| Part of potion-multilingual-128M | model2vec | laghu |
|---|---|---|
| Embedding table | 512 MB, copied into each process | Mapped from model.safetensors and shared |
| Tokenizer search structure for 500,353 pieces | About 610 MB in each process | Mapped from a vocabulary file and shared |
Private memory after encode |
About 1.3 GB | About 60 MB, mostly Python and its imports |
laghu maps the embedding table from the file. The operating system reads a page of the file only when laghu uses it. The operating system keeps the page in its cache. It shares the page with every process that maps the same file. When memory is low, the operating system can remove the page and read it again later.
For a Unigram model, laghu also replaces the search structure of the tokenizer. A Unigram tokenizer selects the most likely sequence of pieces from a long list. laghu builds a vocabulary file one time for each tokenizer.json. The file holds the pieces in a compact marisa trie, with their ids and scores. Every process maps this file and shares it. laghu then finds the best pieces with a Viterbi search. The search is written in Python. With the optional laghu-rs wheel, the search runs in Rust. The text normalization and the first split into words come from tokenizers. laghu builds them from the same tokenizer.json, without the vocabulary.
Models with a BPE or WordLevel tokenizer use tokenizers to tokenize. WordPiece models also use tokenizers when laghu-rs is not installed. laghu maps the table of these models too. The memory that you save depends on the size of the table compared with the size of the tokenizer.
uv add laghu # or: pip install laghu
model2vec is not a dependency. Install the fallback extra, uv add 'laghu[fallback]', in these two cases:
load to use model2vec when laghu cannot read a model.same_as_model2vec.The extra installs model2vec 0.9, which laghu matches. model2vec 0.10 gives different vectors, and its tokenize does not take max_length.
The optional Rust core is the wheel laghu-rs (module laghu_rs). It needs Python 3.11 or later. Install it with pip install laghu-rs, or with the extra: uv add 'laghu[rust]'.
With laghu-rs installed, laghu tokenizes these models in Rust, on all CPU cores:
laghu_rs normalizes the text, finds the added tokens and splits the text into words with the tokenizers crate. Then it runs the Viterbi search of laghu over a byte trie in the shared vocabulary file.laghu_rs.WordPiece is a port of FastWordPiece from model2vec-rs. It calculates only the token ids. It does not calculate the offsets that tokenizers keeps.For a float32 table without weights or a token mapping, laghu_rs also calculates the average vectors. On every path, the ids and vectors are the same as the ids and vectors of model2vec, bit for bit, except for a tokenizer.json that pads (see What is not supported).
This table gives the speed and the private memory for 500-character chunks of text. The computer was an M3 Max with 14 cores. The measurements are from 2026-10-24, with a load average of 6.5 to 9. Each speed is the best of three runs of laghu.bench.speed.
| Model | Loader | Chunks per second | Private memory |
|---|---|---|---|
| potion-multilingual-128M (Unigram) | laghu with laghu-rs |
42,385 | 72 MB |
laghu without laghu-rs |
1,940 | 67 MB | |
| model2vec 0.9 | 21,105 | 1,369 MB | |
| potion-base-8M (WordPiece) | laghu with laghu-rs |
432,938 | 81 MB |
laghu without laghu-rs |
55,514 | 93 MB | |
| model2vec 0.9 | 55,600 | 140 MB | |
| potion-code-16M-v2 (WordPiece, float16) | laghu with laghu-rs |
85,164 | 126 MB |
laghu without laghu-rs |
57,367 | 109 MB | |
| model2vec 0.9 | 21,485 | 144 MB |
The potion-code-16M-v2 rows are from 2026-11-25, with a load average of 6.7, and laghu-rs 0.2.3. laghu-rs tokenizes this model, and numpy calculates the average, because the table is float16. model2vec 0.9 pads each text in a batch to the longest text, so it does more work.
laghu 0.3.0 gave 5,276 chunks per second for model2vec on potion-multilingual-128M. That number was measured with tokenizers on one core, probably because TOKENIZERS_PARALLELISM=false was set. On one core, model2vec gives 5,462 chunks per second on the same computer.
For a Unigram model, laghu tokenizes in pure Python when one of these conditions is true:
laghu_rs.LAGHU_RUST=0 is set when the model loads.shared=False.For a Unigram model, laghu splits the text in Python and does the search in Rust when one of these conditions is true:
tokenizers has a different major or minor version from laghu_rs.TOKENIZERS. A different patch version is accepted. laghu-rs 0.1.0 and 0.2.0 use tokenizers 0.23.2. They accept all Python tokenizers 0.23.x versions.tokenizers crate cannot read the tokenizer.json.PROBE differently from the Python split of laghu. PROBE is a set of 46 difficult test texts. laghu logs a warning.laghu tokenizes a WordPiece model with tokenizers when one of these conditions is true:
laghu_rs, or laghu_rs has no WordPiece.LAGHU_RUST=0 is set when the model loads.lean=False.tokenizers has a different major or minor version from laghu_rs.TOKENIZERS.normalized, or has lstrip, rstrip or single_word set, and laghu-rs is older than 0.2.3.laghu_rs.WordPiece gives different ids from tokenizers on a text in PROBE. laghu logs a warning.From laghu-rs 0.2.3, the tokenizers crate finds the added tokens of a WordPiece model when an added token is normalized, or has lstrip, rstrip or single_word set. This applies the four settings as tokenizers does. It is slower than the search of laghu_rs for other added tokens. potion-code-16M-v2 has such a token, [PAD].
laghu does not use laghu-rs for BPE and WordLevel models. It does not use laghu-rs for Unigram models with a feature that laghu does not copy.
The ids are the same on every path.
from laghu import load
m = load('minishlab/potion-multilingual-128M') # a folder, or a Hugging Face repo id (the local cache is tried first)
v = m.encode(['The quick brown fox.', 'कर्मण्येवाधिकारस्ते']) # float32, (2, 256), unit rows: the same array model2vec returns
m.tokenize(['hello world'])
m.encode_as_sequence('hello world').shape # (n_tokens, 256)
(2, 256)
load takes a local folder or a Hugging Face repo id. It returns a LeanModel. If the repo is in the local Hugging Face cache, load does not use the network.
If laghu cannot load the model, load logs the reason. Then it tries model2vec’s StaticModel, which needs laghu[fallback]. If model2vec also fails, load raises the first error from laghu. Use fallback=False to get the error without a try with model2vec.
laghu and model2vec cannot read tables stored as bfloat16 or float8, because numpy does not have these types.
laghu keeps the vocabulary file of a Unigram model in $LAGHU_CACHE. If $LAGHU_CACHE is not set, laghu uses $XDG_CACHE_HOME/laghu. If that is not set, laghu uses ~/.cache/laghu. If laghu cannot write to the folder, it puts the file next to tokenizer.json.
| Vocabulary file | Time |
|---|---|
| First load, which builds the file | 1 to 2 seconds |
| Later loads, in any process, which map the file | A few hundredths of a second |
If tokenizer.json changes, or if the file is damaged, laghu builds the file again. load(..., shared=False) keeps the vocabulary in a Python dict. This uses about 80 MB more private memory in each process.
To check your own model, use same_as_model2vec(path). It loads the model with laghu and with model2vec, and it compares the results. It uses the built-in test texts of laghu, or the texts that you give:
from laghu import same_as_model2vec
same_as_model2vec('minishlab/potion-base-8M', ['my', 'own texts'])
/Users/71293/code/personal/orgs/laghu/.venv/lib/python3.13/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
from .autonotebook import tqdm as notebook_tqdm
{'lean': False,
'n': 2,
'ids': True,
'dtype': True,
'f32': True,
'f16': True,
'exact': True,
'seq': True,
'median': True,
'unk': True,
'tokens': True}
The result shows, for each check, if the two loaders agree:
| Key | What it checks |
|---|---|
ids |
The token ids |
f32 |
The vectors, changed to float32 |
f16 |
The vectors, changed to float16 |
dtype |
The exact data type |
exact |
The exact bits |
seq |
encode_as_sequence |
median |
median_token_length |
unk |
The unknown token id |
tokens |
The token list |
lean |
laghu used its own Unigram tokenizer (not a check) |
n |
The number of texts (not a check) |
Every model in the table below gives the same ids and vectors as model2vec, bit for bit, on 4,726 texts. The texts include prose in 36 languages and random strings from 30 Unicode blocks. They also include control characters, special tokens, emoji sequences, combining marks, bidirectional text controls and a string of 200,000 characters.
These rules apply to the table:
phys_footprint after encode, and peak memory is lifetime_max_phys_footprint. On Linux, the same columns would hold RssAnon and VmHWM.encode over 3,226 texts on an M3 Max.laghu-rs, or tokenizers.laghu-rs. The third number was measured with laghu-rs, in the same way.— means that laghu-rs does not change the row. This is true for BPE and WordLevel models.laghu-rs. These rows were checked without laghu-rs. With laghu-rs, they use Rust when their tokenizer qualifies.laghu-rs on 2026-10-24. Both stay identical.The laghu-rs numbers come from different sessions than the older numbers. Compare each laghu-rs number with the numbers from its own session:
| Model | Date | model2vec, texts per second | laghu without laghu-rs, texts per second |
laghu with laghu-rs, texts per second |
Notes |
|---|---|---|---|---|---|
| potion-multilingual-128M | 2026-10-23 | 22,846 | 14,859 | 130,007 | Best of 3 runs. Load average 6.5. The slowest Rust run gave 41,988 texts per second. |
| potion-base-8M | 2026-10-24 | 82,027 | not measured | 650,395 | Best of 3 runs. Each Rust run took about 0.003 seconds. |
Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.