Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

Update GenAI NPU doc (#26060)

Anatoliy Talamanovd84c2b53d1cd
diff --git a/docs/articles_en/learn-openvino/llm_inference_guide/genai-guide-npu.rst b/docs/articles_en/learn-openvino/llm_inference_guide/genai-guide-npu.rst
index 516adc22524..8a07b0dc05e 100644
--- a/docs/articles_en/learn-openvino/llm_inference_guide/genai-guide-npu.rst
+++ b/docs/articles_en/learn-openvino/llm_inference_guide/genai-guide-npu.rst
@@ -8,60 +8,56 @@ This guide will give you extra details on how to utilize NPU with the GenAI flav
:doc:`See the installation guide <../../get-started/install-openvino/install-openvino-genai>`
for information on how to start.
-Export an LLM model via Hugging Face Optimum-Intel
-##################################################
+Prerequisites
+#############
-1. Create a python virtual environment and install the correct components for exporting a model:
+Install required dependencies:
- .. code-block:: console
+.. code-block:: console
- python -m venv export-npu-env
- export-npu-env\Scripts\activate
- pip install transformers>=4.42.4 openvino==2024.2.0 openvino-tokenizers==2024.2.0 nncf==2.11.0 onnx==1.16.1 optimum-intel@git+https://github.com/huggingface/optimum-intel.git
+ python -m venv npu-env
+ npu-env\Scripts\activate
+ pip install optimum-intel nncf==2.11 onnx==1.16.1
+ pip install --pre openvino openvino-tokenizers openvino-genai --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly
+
+Export an LLM model via Hugging Face Optimum-Intel
+##################################################
-2. A chat-tuned TinyLlama model is used in this example. The following conversion & optimization settings are recommended when using the NPU:
+A chat-tuned TinyLlama model is used in this example. The following conversion & optimization settings are recommended when using the NPU:
- .. code-block:: python
+.. code-block:: python
- optimum-cli export openvino -m TinyLlama/TinyLlama-1.1B-Chat-v1.0 --weight-format int4 --sym --group-size 128 --ratio 1.0 TinyLlama
+ optimum-cli export openvino -m TinyLlama/TinyLlama-1.1B-Chat-v1.0 --weight-format int4 --sym --group-size 128 --ratio 1.0 TinyLlama
Run generation using OpenVINO GenAI
-##########################################
-
-1. Create a python virtual environment and install the correct components for running the model on the NPU via OpenVINO GenAI:
-
- .. code-block:: console
-
- python -m venv run-npu-env
- run-npu-env\Scripts\activate
- pip install openvino>=2024.3.1 openvino-tokenizers>=2024.3.1 openvino-genai>=2024.3.1
+###################################
-2. Perform generation using the new GenAI API
+Use the following code snippet to perform generation with OpenVINO GenAI API:
- .. tab-set::
+.. tab-set::
- .. tab-item:: Python
- :sync: py
+ .. tab-item:: Python
+ :sync: py
- .. code-block:: python
+ .. code-block:: python
- import openvino_genai as ov_genai
- pipe = ov_genai.LLMPipeline(model_path, "NPU")
- print(pipe.generate("The Sun is yellow because", max_new_tokens=100))
+ import openvino_genai as ov_genai
+ pipe = ov_genai.LLMPipeline(model_path, "NPU")
+ print(pipe.generate("The Sun is yellow because", max_new_tokens=100))
- .. tab-item:: C++
- :sync: cpp
+ .. tab-item:: C++
+ :sync: cpp
- .. code-block:: cpp
+ .. code-block:: cpp
- #include "openvino/genai/llm_pipeline.hpp"
- #include <iostream>
+ #include "openvino/genai/llm_pipeline.hpp"
+ #include <iostream>
- int main(int argc, char* argv[]) {
- std::string model_path = argv[1];
- ov::genai::LLMPipeline pipe(model_path, "NPU");
- std::cout << pipe.generate("The Sun is yellow because", ov::genai::max_new_tokens(100));
- }
+ int main(int argc, char* argv[]) {
+ std::string model_path = argv[1];
+ ov::genai::LLMPipeline pipe(model_path, "NPU");
+ std::cout << pipe.generate("The Sun is yellow because", ov::genai::max_new_tokens(100));
+ }
Additional configuration options
################################