Optimum Intel

1.27.0 · active · verified Thu Apr 16

Optimum Intel extends the Hugging Face Transformers and Diffusers libraries, providing a framework to integrate Intel's specialized tools and libraries like OpenVINO, Neural Compressor, and Intel Extension for PyTorch. It enables optimization, conversion (e.g., to OpenVINO IR format), and accelerated inference of deep learning models on Intel architectures. The library is actively maintained with frequent minor version releases, currently at 1.27.0.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates loading a pre-trained sentiment analysis model, converting it to OpenVINO Intermediate Representation (IR) format on the fly using `export=True`, and running inference with a Hugging Face pipeline. Ensure `optimum-intel[openvino]` and `transformers` are installed.

from transformers import AutoTokenizer, pipeline
from optimum.intel import OVModelForSequenceClassification

model_id = "distilbert-base-uncased-finetuned-sst-2-english"
tokenizer = AutoTokenizer.from_pretrained(model_id)
# Load and convert the model to OpenVINO IR format on the fly
model = OVModelForSequenceClassification.from_pretrained(model_id, export=True)

# Run inference
classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)
results = classifier("Optimum Intel is great!")
print(results)

view raw JSON →