加载中…
加载中…
OpenVINO int8 IR of jhu-clsp/mmBERT-base, a multilingual ModernBERT encoder, quantized with NNCF SmoothQuant for CPU inference. int8 preserves the fp32 sentence-similarity structure at pearson 0.9789 - near-lossless, no onnxruntime dependency.
Run multilingual sentence embeddings on a commodity CPU box with no GPU. Produces mean-pooled, L2-normalizable token embeddings for semantic-similarity work - document-distance scoring, optimal-transport statement matching, and retrieval pre-filtering - where a quantized encoder keeps the similarity geometry intact while halving memory.
jhu-clsp/mmBERT-base (multilingual ModernBERT, ~307M params, 768-dim)openvino_model.xml + .bin), int8openvino.convert_model traces the ModernBERT graph (optimum-intel does not yet support the architecture for export), then nncf.quantize(model_type=TRANSFORMER) with SmoothQuant applies the int8 PTQopenvino_model.xml / openvino_model.bin - the int8 IRconfig.json - base model configopenvino_config.json - quantization metadatatokenizer.json / tokenizer_config.json - tokenizerimport numpy as np
import openvino as ov
from huggingface_hub import hf_hub_download
from transformers import AutoTokenizer
repo = "stellars/mmBERT-base-openvino-int8"
xml = hf_hub_download(repo, "openvino_model.xml")
hf_hub_download(repo, "openvino_model.bin")
tok = AutoTokenizer.from_pretrained(repo)
core = ov.Core()
model = core.compile_model(core.read_model(xml), "CPU", {"PERFORMANCE_HINT": "LATENCY"})
out_port = model.outputs[0]
def embed(sentences):
vecs = []
for s in sentences:
e = tok(s, return_tensors="np", padding="max_length", truncation=True, max_length=128)
last = model({"input_ids": e["input_ids"], "attention_mask": e["attention_mask"]})[out_port]
mask = e["attention_mask"][..., None].astype("float32")
v = (last * mask).sum(1) / np.clip(mask.sum(1), 1e-9, None)
vecs.append((v / np.linalg.norm(v, axis=-1, keepdims=True))[0])
return np.stack(vecs)
emb = embed(["The cat sat on the mat.", "A feline rested on the rug."])
print("cosine:", float(emb[0] @ emb[1]))
Inherits the mit license of the base model jhu-clsp/mmBERT-base. Quantized to OpenVINO int8 with NNCF SmoothQuant.
jhu-clsp/mmBERT-base