Convert Models to OpenVINO Format
This page explains how to convert various generative AI models from Hugging Face and ModelScope to OpenVINO IR format. Refer to the Supported Models for a list of available models.
For downloading pre-converted models, see Download Pre-Converted OpenVINO Models.
Models are converted with the optimum-cli tool of Optimum Intel.
OpenVINO GenAI also provides its own export tool, genai-cli (preview), as an additional option:
it takes the same options as optimum-cli export openvino and converts models that optimum-cli does not support yet.
Converting Models from Hugging Face
-
Install
optimum-intelpackage to download, convert and optimize models:NoteSome models may require additional dependencies. To convert models with
optimum-cliand to run the examples, install the dependencies from./samples/export-requirements.txt.pip install --requirement ./samples/export-requirements.txt -
Download and convert a model to the OpenVINO IR format using
optimum-clitool from Hugging Face:optimum-cli export openvino --model <model_id_or_path> <output_dir>tipFor better performance with minimal accuracy impact, convert the model to lower precision by using
--weight-formatargument:- INT4
- INT8
- FP16
optimum-cli export openvino --model <model_id_or_path> --weight-format int4 <output_dir>optimum-cli export openvino --model <model_id_or_path> --weight-format int8 <output_dir>optimum-cli export openvino --model <model_id_or_path> --weight-format fp16 <output_dir>infoThe
--trust-remote-codeflag is required for some models that use custom code.Check a full list of conversion options here.
Converting Models with genai-cli (Preview)
genai-cli is in preview. Its options, the list of natively converted models and the layout of the exported files
may change in future releases.
genai-cli is the export tool shipped with OpenVINO GenAI. It accepts the same options as optimum-cli export openvino
and works in two modes:
- Native export. The models listed in the table below are converted by
genai-cliitself, withoutoptimum-intel. Some of them, such as Molmo2, are converted only bygenai-clibecauseoptimum-clidoes not support them yet. - Fallback export. Every other model is exported through
optimum-intelwith the same command line, sogenai-clican be used instead ofoptimum-clifor any supported model.
-
Install OpenVINO GenAI with the export dependencies (
torch,torchvision,transformers,nncfanduv):pip install openvino-genai[export] -
Export a model. For example, Molmo2 (
allenai/MolmoWeb-4B) compressed to INT4:genai-cli export -m allenai/MolmoWeb-4B --trust-remote-code --weight-format int4 MolmoWeb-4B-ov-int4The output directory contains the OpenVINO IRs, the converted tokenizer and detokenizer, and the configuration files the GenAI pipelines read, so it can be passed to
VLMPipelinedirectly.A model without a native exporter is exported the same way, through
optimum-intel:genai-cli export -m TinyLlama/TinyLlama-1.1B-Chat-v1.0 --weight-format int4 TinyLlama_1_1b_v1_ovRun
genai-cli export --helpfor the full list of options. A local model directory, for example one downloaded from ModelScope, can be passed to-mas well.
| Model type | Architecture | Converted by | transformers version |
|---|---|---|---|
molmo2 | Molmo2ForConditionalGeneration | genai-cli only (native) | 4.57.6 |
| Any other | optimum-intel (fallback) | Supported by optimum-intel for the model |
- transformers version overlays. Every model is exported with the
transformersversion it is known to work with. If the installed version differs,genai-cliruns the export again in an ephemeral environment created byuvon top of the active one (uv run --with transformers==<version>). The active virtual environment is never modified; the overlays are cached byuv. - Fallback exports. For models without a native exporter,
genai-clirunsoptimum-cli export openvinowith the same arguments, switching to atransformersversion supported byoptimum-intelfor the model if needed. Ifoptimum-intelis not installed, it is downloaded (without dependencies) to~/.cache/openvino_genai/genai-cli, andtorch,openvinoandnncfare taken from the active environment. SetGENAI_CLI_OPTIMUM_INTEL_SPECto export with anotheroptimum-intelversion, for exampleoptimum-intel @ git+https://github.com/huggingface/optimum-intel.git. - Native exporters support FP32, FP16 and data-free weight compression (
int8,int4,mxfp4,nf4,cb4, with--ratio,--group-size,--sym,--awqand the other data-free options). Data-aware compression (--dataset), full quantization (--quant-mode),--disable-statefuland--model-kwargsare rejected for them.
Converting Models from ModelScope
ModelScope models need to be downloaded first, then converted to OpenVINO IR format.
- Install
modelscopeandoptimum-intelpackages to download, convert and optimize models:pip install modelscope --requirement ./samples/export-requirements.txt - Download the required model (e.g.
Qwen/Qwen2-7b) to a local directory usingmodelscopetool:modelscope download --model 'Qwen/Qwen2-7b' --local_dir <model_path> - Convert the model (and optionally compress weights) using
optimum-clitool:optimum-cli export openvino --model <model_path> --weight-format int4 <output_dir>
Refer to the Use Cases for detailed instructions on using models with OpenVINO GenAI.