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).dsaad68/LFM2.5-Embedding-350M-ONNX-int8.
Export tooling, parity tests, and precision rationale:
dsaad68/liquid-embedding-onnx.| File | Notes |
|---|---|
onnx/model.onnx | fp16 graph, self-contained single file (~711 MB; exported directly in fp16, not post-hoc converted) |
| 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 fp16 — upcast to fp32 if your pipeline expects it.optimum[onnxruntime]; onnx/model.onnx is found automatically:1from sentence_transformers import SentenceTransformer
2
3model = SentenceTransformer("dsaad68/LFM2.5-Embedding-350M-ONNX-fp16", 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-fp16")
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) fp16 unit vectors; cosine similarity = dot product
16print(emb.astype(np.float32) @ emb.astype(np.float32).T)Uint16Array (JS has no native float16). See the
web-test harness
for a worked example.torch.onnx.export (opset 17, dynamic batch + sequence axes) from the
upstream remote-code Lfm2BidirectionalModel with attn_implementation="eager",
which reproduces the exact training-time masking behavior.SentenceTransformer(..., trust_remote_code=True) ≥ 0.999 on both outputs, plus
retrieval-ranking equality.