Views
No views yet
LiquidAI/LFM2.5-Embedding-350M,
a 354M-parameter bidirectional LFM2 embedding model (hybrid short-conv + attention,
CLS pooling, 1024-dimensional, query: / document: prompt prefixes). Weights are
dynamically quantized to int8 (onnxruntime.quantization.quantize_dynamic) from an
fp32 base — ~356 MB, half the size of the
fp16 variant.| File | Notes |
|---|---|
onnx/model.onnx | int8 dynamic-weight-quant graph, single self-contained file (~356 MB) |
| Output | Shape | Use |
|---|---|---|
sentence_embedding | (batch, 1024) | CLS pooling + L2 normalization baked in — use this for retrieval |
last_hidden_state | (batch, sequence, 1024) | raw token embeddings — pool externally (used by the sentence-transformers ONNX backend) |
query: to
queries and document: to passages. Max sequence length is 512 tokens.
Outputs are fp32.optimum[onnxruntime]; onnx/model.onnx is found automatically:1from sentence_transformers import SentenceTransformer
2
3model = SentenceTransformer("dsaad68/LFM2.5-Embedding-350M-ONNX-int8", backend="onnx", trust_remote_code=True)
4q = model.encode(["How do I reset my password?"], prompt_name="query",
5 normalize_embeddings=True)
6d = model.encode(["Click 'Forgot password' on the sign-in page."],
7 prompt_name="document", normalize_embeddings=True)
8print(q @ d.T)1import numpy as np, onnxruntime as ort
2from huggingface_hub import snapshot_download
3from transformers import AutoTokenizer
4
5repo = snapshot_download("dsaad68/LFM2.5-Embedding-350M-ONNX-int8")
6tok = AutoTokenizer.from_pretrained(repo)
7sess = ort.InferenceSession(f"{repo}/onnx/model.onnx")
8
9texts = ["query: How do I reset my password?",
10 "document: Click 'Forgot password' on the sign-in page."]
11enc = tok(texts, padding=True, truncation=True, max_length=512, return_tensors="np")
12emb = sess.run(["sentence_embedding"],
13 {"input_ids": enc["input_ids"].astype(np.int64),
14 "attention_mask": enc["attention_mask"].astype(np.int64)})[0]
15# emb: (2, 1024) fp32 unit vectors; cosine similarity = dot product
16print(emb @ emb.T)torch.onnx.export (opset 17, dynamic batch + sequence
axes) from the upstream remote-code Lfm2BidirectionalModel with
attn_implementation="eager", then dynamically quantized to int8 weights.SentenceTransformer(..., trust_remote_code=True) ≥ 0.985 on both outputs, plus
retrieval-ranking equality.