ONNX export of
codefuse-ai/F2LLM-v2-0.6B, a general-purpose multilingual embedding model from the F2LLM-v2 family, trained on 60M high-quality multilingual examples supporting 200+ languages.
This is the
full-precision (FP32) reference export. For production use, prefer the
INT8 or
INT4 variants which are 2–3× smaller with negligible quality loss.
The dynamo exporter traces at the FX-graph / symbolic level. All internal tensor shapes — including the Qwen3 causal attention mask — carry symbolic batch and sequence dimensions throughout. Dynamic batch verified: batch = 1, 2, 4, 8 all produce correct output shapes.
1import onnxruntime as ort
2import numpy as np
3from tokenizers import Tokenizer
4
5tokenizer = Tokenizer.from_file("tokenizer.json")
6tokenizer.enable_padding(pad_id=0, direction="right")
7tokenizer.enable_truncation(max_length=512)
8
9session = ort.InferenceSession("model.onnx", providers=["CPUExecutionProvider"])
10
11texts = ["semantic search example", "another sentence"]
12enc = tokenizer.encode_batch(texts)
13ids = np.array([e.ids for e in enc], dtype=np.int64)
14mask = np.array([e.attention_mask for e in enc], dtype=np.int64)
15
16lhs = session.run(None, {"input_ids": ids, "attention_mask": mask})[0] # [batch, seq, 1024]
17
18# Last-token pooling: take embedding at last non-padding position
19seq_lens = mask.sum(axis=1) - 1
20embeddings = lhs[np.arange(len(texts)), seq_lens]
21
22# L2 normalise
23norms = np.linalg.norm(embeddings, axis=1, keepdims=True)
24embeddings = embeddings / np.maximum(norms, 1e-8)
25print(embeddings.shape) # (2, 1024)
1@misc{f2llm-v2,
2 title={F2LLM-v2: Inclusive, Performant, and Efficient Embeddings for a Multilingual World},
3 author={Ziyin Zhang and Zihan Liao and Hang Yu and Peng Di and Rui Wang},
4 year={2026},
5 eprint={2603.19223},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2603.19223},
9}