模型:
helenai/gpt2-ov
这是将模型 gpt2 转换为 OpenVINO 以进行加速推理的示例。
进行这个模型的推理的示例:
from optimum.intel.openvino import OVModelForCausalLM 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/gpt2-ov" tokenizer = AutoTokenizer.from_pretrained(model_id) model = OVModelForCausalLM.from_pretrained(model_id) pipe = pipeline("text-generation", model=model, tokenizer=tokenizer) result = pipe("My name is Julien and I like to") print(result)