Instructions to use kucukkanat/LFM2.5-Encoder-350M-ONNX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use kucukkanat/LFM2.5-Encoder-350M-ONNX with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('fill-mask', 'kucukkanat/LFM2.5-Encoder-350M-ONNX');
LFM2.5-Encoder-350M-ONNX
ONNX export of LiquidAI/LFM2.5-Encoder-350M, quantized to run fully in the browser through
transformers.js. No inference server: the weights are
fetched once, cached, and every forward pass happens in the tab.
The base bidirectional encoder with its tied masked-LM head. Outputs vocabulary logits and the final hidden states, so it doubles as a sentence-embedding backbone.
All credit for the model itself goes to Liquid AI. This repository contains only a re-export; the weights are unchanged apart from quantization, and the original LFM Open License v1.0 applies.
Try it in your browser โ โ no install, no API key.
Tooling, demo and the export pipeline: https://github.com/kucukkanat/lfm-encoders
Files
| dtype | File | Size |
|---|---|---|
q8 |
onnx/model_quantized.onnx |
424 MB |
q4 |
onnx/model_q4.onnx |
491 MB |
The graph takes input_ids + attention_mask, is dynamic in batch and sequence, and returns
logits and last_hidden_state.
Usage
import { AutoTokenizer, PreTrainedModel, Tensor } from "@huggingface/transformers";
const id = "kucukkanat/LFM2.5-Encoder-350M-ONNX";
const tokenizer = await AutoTokenizer.from_pretrained(id);
const model = await PreTrainedModel.from_pretrained(id, { dtype: "q8" });
const { input_ids } = tokenizer("some text");
const out = await model({
input_ids,
attention_mask: new Tensor("int64", new BigInt64Array(input_ids.dims[1]).fill(1n), input_ids.dims),
});
PreTrainedModel rather than AutoModel is deliberate: this is a plain "feed the named inputs, read the
named outputs" session, not one of transformers.js's built-in architectures.
Accuracy
Measured from JavaScript against the fp32 PyTorch reference. ฮ is the largest absolute difference in a final probability.
| dtype | max ฮ | mean ฮ | top-5 disagreements (3 cases) |
|---|---|---|---|
fp32 |
9.6e-5 | 4.1e-5 | 0 |
q8 |
0.1846 | 0.1235 | 4 |
q4 |
0.2180 | 0.0978 | 3 |
Notes
q8is smaller on disk but uses more browser RAM than fp32 and runs slower: onnxruntime's WASM kernels compute in float, so quantized weights are unpacked at session load. Quantization here buys download size, not speed or memory.- Budget roughly 1.5 GB of RAM per resident model, and expect a tab to hold its high-water mark until reloaded.
fp16/q4f16are deliberately absent: RMSNorm's variance overflows fp16 on this architecture and every hidden state collapses to zeros.
- Downloads last month
- -
Model tree for kucukkanat/LFM2.5-Encoder-350M-ONNX
Base model
LiquidAI/LFM2.5-350M-Base