Instructions to use daveycodez/LFM2.5-1.2B-Web with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use daveycodez/LFM2.5-1.2B-Web with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-generation', 'daveycodez/LFM2.5-1.2B-Web');
LFM2.5-1.2B-Instruct ONNX for the web
A 4-bit ONNX build of LFM2.5-1.2B-Instruct by Liquid AI, made for in-browser use with Transformers.js on WebGPU, including iPhone Safari.
This is an unofficial community build. It is not made, reviewed or endorsed by Liquid AI.
Changes from the original
This repository contains a modified file. Compared with LiquidAI/LFM2.5-1.2B-Instruct-ONNX at commit 10f72e7 (onnx/model_q4f16.onnx):
- Logits only for the positions you need: the graph has a new
num_logits_to_keepinput (int64 scalar), the same input onnx-community/LFM3-1.7B-ONNX has. The final-norm hidden states are sliced to the lastnum_logits_to_keeppositions before the LM head;0keeps every position, as before. Transformers.js passes1duringgenerate(), so reading a prompt computes one row of logits instead of one per prompt token. Thelogitsoutput is[batch, num_logits_to_keep, 65536], or[batch, sequence_length, 65536]for0. - Why: the original graph returns float32 logits for every prompt token. For an 800-token prompt that is a 210 MB tensor (plus a 105 MB float16 one before the cast), made on the GPU and then copied to the page. On iPhone Safari, where a tab gets about 2 GB including GPU memory, long prompts such as ones with a tool definition crashed the tab.
- Nothing else changed: the edit adds three nodes (
Neg,Unsqueeze,Slice), three small int64 constants and the input. The weights are not touched:onnx/model_q4f16.onnx_datais byte-identical to the original (SHA-25646cfacc12941150620a3f644a5269e9baebd75d681cfa09cadeef71b8ed64ac2).
config.json, generation_config.json, tokenizer.json, tokenizer_config.json and chat_template.jinja are unchanged copies. Only the q4f16 model is included.
| Original q4f16 | This build | |
|---|---|---|
logits for an 800-token prompt |
[1, 800, 65536], 209,715,200 bytes |
[1, 1, 65536], 262,144 bytes |
| Last-token logits on 5 prompts of 18β963 tokens, max abs difference | β€ 0.0078 (logits up to Β±17), same top token on every prompt | |
All positions (num_logits_to_keep = 0), max abs difference |
0 | |
| KV and conv caches after the prompt | identical | |
| 8 greedy decode steps after each prompt | identical tokens and logits | |
| 541-token tool prompt + 24 new tokens, Transformers.js 4.3.2 on WebGPU (Node, Apple Silicon) | 250β259 ms | 222β228 ms |
| 963-token prompt, onnxruntime CPU | 1,669 ms | 1,497 ms |
Measurements were taken with onnxruntime 1.31 on CPU unless noted. The small last-token difference comes from the LM head's 4-bit matmul running on one row instead of hundreds, which changes the order of the float16 sums. Through Transformers.js 4.3.2, greedy generation gave the same tokens with both builds.
Usage
Use it like the original ONNX model, with dtype: "q4f16" and device: "webgpu". See LiquidAI/LFM2.5-1.2B-Instruct-ONNX for examples. Transformers.js sets num_logits_to_keep on its own. If you run the graph with onnxruntime directly, pass it as an int64 scalar: 1 for generation, 0 for all positions.
License
LFM2.5 is released under the LFM Open License v1.0, which also covers this build. Commercial use is licensed only for entities with annual revenue under $10 million. Original model Β© Liquid AI, Inc.
- Downloads last month
- -
Model tree for daveycodez/LFM2.5-1.2B-Web
Base model
LiquidAI/LFM2.5-1.2B-Base
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('text-generation', 'daveycodez/LFM2.5-1.2B-Web');