模型:

helenai/bert-base-uncased-ov

英文

bert-base-uncased

这是将 bert-base-uncased 模型转换为 OpenVINO ,用于加速推理。

如何对此模型进行推理的示例:

from optimum.intel.openvino import OVModelForMaskedLM
from transformers import AutoTokenizer, pipeline

# model_id should be set to either a local directory or a model available on the HuggingFace hub.
model_id = "helenai/bert-base-uncased-ov-fp32"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = OVModelForMaskedLM.from_pretrained(model_id)
pipe = pipeline("fill-mask", model=model, tokenizer=tokenizer)
result = pipe("I am a [MASK] model")
print(result)