Downloads · 30 days
38
54% of all-time downloads
clarenceorg/llmlingua-2-onnx
llmlingua-2-onnx is a token classification model from clarenceorg. Use it when you need labels on individual words, such as names. It is set up for transformers.js. The card lists the license as apache-2.0.
ONNX conversion of microsoft/llmlingua-2-bert-base-multilingual-cased-meetingbank, for running prompt compression in the browser with Transformers.js.
Downloads · 30 days
38
54% of all-time downloads
All-time downloads
71
Public
Repo size
179 MB
Likes
1
Public
Click a slice to open those files.
.onnx179 MB · 96%
From the Hugging Face model README
ONNX conversion of
microsoft/llmlingua-2-bert-base-multilingual-cased-meetingbank,
for running prompt compression in the browser with
Transformers.js.
Only the format was changed: PyTorch → ONNX, then dynamic int8 quantization. The weights are not retrained or otherwise modified.
The upstream repository ships PyTorch weights only, and browsers can only run ONNX. Existing community conversions were unusable for redistribution because they declared no licence — and with no licence, the default is "all rights reserved". This conversion is made from the Apache 2.0 original so that the same permissions carry over, attribution included.
| file | size |
|---|---|
onnx/model_quantized.onnx | 179 MB — int8, this is what you want |
The fp32 export is not published: it is 710 MB and no runtime here needs it. Regenerate it from the upstream weights if required.
The export was verified against the original PyTorch model rather than assumed correct. Numbers are the mean/max absolute difference in p(keep) per token, and the number of flipped decisions (keep vs. drop) over a French/English probe set:
| mean | max | flipped | |
|---|---|---|---|
| this export, fp32 | 0.00000 | 0.0000 | 0 |
| this export, int8 per-channel | 0.01217 | 0.1049 | 1 |
| int8 per-tensor (not used) | 0.02916 | 0.2154 | 1 |
The fp32 figure is the one that matters: the export itself is exact, and the remaining gap comes only from quantization.
per_channel=True is deliberate — per-tensor quantization degrades roughly 3×
more for 1 MB less. reduce_range=True was also measured and made things
clearly worse, so it is not used.
Verified to load and run under onnxruntime-web 1.14 (the version bundled by Transformers.js v2) in a real browser.
import { pipeline } from '@xenova/transformers';
const pipe = await pipeline(
'token-classification',
'clarenceorg/llmlingua-2-onnx',
{ quantized: true }
);
The model has no id2label, so labels come out as LABEL_0 / LABEL_1.
LABEL_1 means "keep the token"; p(keep) for LABEL_0 is 1 - score.
Two practical notes, both learned the hard way:
index field skips
values). Aligning a cursor over that stream desynchronises it permanently.
Re-tokenize yourself and join scores back by index.@inproceedings{pan2024llmlingua2,
title = {{LLMLingua-2}: Data Distillation for Efficient and Faithful
Task-Agnostic Prompt Compression},
author = {Pan, Zhuoshi and Wu, Qianhui and Jiang, Huiqiang and Xia, Menglin
and Luo, Xufang and Zhang, Jue and Lin, Qingwei and Rühle, Victor
and Yang, Yuqing and Lin, Chin-Yew and Zhao, H. Vicky and Qiu, Lili
and Zhang, Dongmei},
booktitle = {Findings of ACL 2024},
year = {2024}
}
Apache 2.0, inherited from the upstream model. Copyright Microsoft Corporation.
See the NOTICE file in this repository.
Converted for Clarence, a client-side PII anonymizer for LLM prompts.