LFM2.5-Encoder-350M-PII-Detector ONNX

FP32 ONNX export of LiquidAI/LFM2.5-Encoder-350M-PII-Detector: the bidirectional encoder plus the BIOES token-classification head (161 labels, 40 PII types). Opset 18. Weights are one file, model.onnx (about 1.4 GB).

The graph is a single forward without a KV cache.

inputs input_ids int64 [batch, sequence], attention_mask int64 [batch, sequence]
output logits float32 [batch, sequence, 161]
batch, sequence dynamic

Against the PyTorch model (attn_implementation="eager", fp32) the largest absolute difference on checked shapes was 2.6e-5, and argmax labels matched, including padded batches and length 1.

Labels are BIOES. id2label / label2id are in config.json. O is outside an entity; B / I / E are begin, inside, end of a multi-token span; S is a single-token span.

Usage

import json
import numpy as np
import onnxruntime as ort
from transformers import AutoTokenizer

repo = "Kostya165/LFM2.5-Encoder-350M-PII-Detector-ONNX"
tokenizer = AutoTokenizer.from_pretrained(repo)
labels = {int(k): v for k, v in json.load(open("config.json"))["id2label"].items()}

session = ort.InferenceSession("model.onnx", providers=["CPUExecutionProvider"])
encoded = tokenizer("Email ada@example.com or call +1 415 555 0134.", return_tensors="np")
logits = session.run(None, {
    "input_ids": encoded["input_ids"],
    "attention_mask": encoded["attention_mask"],
})[0]
pred = logits.argmax(-1)[0]
for token, label_id in zip(tokenizer.convert_ids_to_tokens(encoded["input_ids"][0]), pred.tolist()):
    label = labels[label_id]
    if label != "O":
        print(token, label)

License

Derivative of Liquid AI's model. Use, reproduction, and distribution follow LFM Open License v1.0.

Downloads last month
19
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for Kostya165/LFM2.5-Encoder-350M-PII-Detector-ONNX