OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
Update GenAI NPU documentation (#26612)
Anatoliy Talamanove062d5c37201
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.rstindex 8a07b0dc05e..4315bc15419 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@@ -29,9 +29,17 @@ A chat-tuned TinyLlama model is used in this example. The following conversion &optimum-cli export openvino -m TinyLlama/TinyLlama-1.1B-Chat-v1.0 --weight-format int4 --sym --group-size 128 --ratio 1.0 TinyLlama+**For models exceeding 1 billion parameters, it is recommended to use remarkably effective channel-wise quantization.** For example, you can try the approach with the llama-2-7b-chat-hf model:++.. code-block:: python++ optimum-cli export openvino -m meta-llama/Llama-2-7b-chat-hf --weight-format int4 --sym --group-size -1 --ratio 1.0 Llama-2-7b-chat-hf+Run generation using OpenVINO GenAI###################################+It is recommended to install the latest available `driver <https://www.intel.com/content/www/us/en/download/794734/intel-npu-driver-windows.html>`__.+Use the following code snippet to perform generation with OpenVINO GenAI API:.. tab-set::@@ -42,6 +50,7 @@ Use the following code snippet to perform generation with OpenVINO GenAI API:.. code-block:: pythonimport openvino_genai as ov_genai+ model_path = "TinyLlama"pipe = ov_genai.LLMPipeline(model_path, "NPU")print(pipe.generate("The Sun is yellow because", max_new_tokens=100))@@ -54,7 +63,7 @@ Use the following code snippet to perform generation with OpenVINO GenAI API:#include <iostream>int main(int argc, char* argv[]) {- std::string model_path = argv[1];+ std::string model_path = "TinyLlama";ov::genai::LLMPipeline pipe(model_path, "NPU");std::cout << pipe.generate("The Sun is yellow because", ov::genai::max_new_tokens(100));}@@ -62,9 +71,17 @@ Use the following code snippet to perform generation with OpenVINO GenAI API:Additional configuration options################################-Compiling models for NPU may take a while. By default, the LLMPipeline for the NPU-is configured for faster compilation, but it may result in lower performance.-To achieve better performance at the expense of compilation time, you may try these settings:+Prompt and response length options+++++++++++++++++++++++++++++++++++++The LLM pipeline for NPUs leverages the static shape approach, optimizing execution performance, while potentially introducing certain usage limitations. By default, the LLM pipeline supports input prompts up to 1024 tokens in length. It also ensures that the generated response contains at least 150 tokens, unless the generation encounters the end-of-sequence (EOS) token or the user explicitly sets a lower length limit for the response.++You may configure both the 'maximum input prompt length' and 'minimum response length' using the following parameters:++- ``MAX_PROMPT_LEN``: Defines the maximum number of tokens that the LLM pipeline can process for the input prompt (default: 1024).+- ``MIN_RESPONSE_LEN``: Defines the minimum number of tokens that the LLM pipeline will generate in its response (default: 150).++Use the following code snippet to change the default settings:.. tab-set::@@ -73,8 +90,7 @@ To achieve better performance at the expense of compilation time, you may try th.. code-block:: python- plugin_config = { "NPU_COMPILATION_MODE_PARAMS": "compute-layers-with-higher-precision=Sqrt,Power,ReduceMean,Add_RMSNorm" }- pipeline_config = { "PREFILL_CONFIG": plugin_config, "GENERATE_CONFIG": plugin_config }+ pipeline_config = { "MAX_PROMPT_LEN": 1500, "MIN_RESPONSE_LEN": 500 }pipe = ov_genai.LLMPipeline(model_path, "NPU", pipeline_config).. tab-item:: C++@@ -82,8 +98,7 @@ To achieve better performance at the expense of compilation time, you may try th.. code-block:: cpp- ov::AnyMap plugin_config = { { "NPU_COMPILATION_MODE_PARAMS", "compute-layers-with-higher-precision=Sqrt,Power,ReduceMean,Add_RMSNorm" } };- ov::AnyMap pipeline_config = { { "PREFILL_CONFIG", plugin_config }, { "GENERATE_CONFIG", plugin_config } };+ ov::AnyMap pipeline_config = { { "MAX_PROMPT_LEN", 1500 }, { "MIN_RESPONSE_LEN", 500 } };ov::genai::LLMPipeline pipe(model_path, "NPU", pipeline_config);