Skip to content

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

[DOCS] New NNCF article for user documentation - master (#25981)

Maciej Smyk5ba9884a0653
diff --git a/docs/articles_en/assets/images/nncf_workflow.svg b/docs/articles_en/assets/images/nncf_workflow.svg
index 3ae4448d391..5fe18c1a555 100644
--- a/docs/articles_en/assets/images/nncf_workflow.svg
+++ b/docs/articles_en/assets/images/nncf_workflow.svg
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:f4d354fb705b7b2c2f89935be13d3e53eb4977bbb5a027a6b66800ef4d4a42b9
-size 99232
+oid sha256:2a14fab3af30e7209879d9a453c320f94637125c68ffcab9695dcdb2ca444f76
+size 84747
diff --git a/docs/articles_en/openvino-workflow.rst b/docs/articles_en/openvino-workflow.rst
index 9c984b674a2..90101fd1fb3 100644
--- a/docs/articles_en/openvino-workflow.rst
+++ b/docs/articles_en/openvino-workflow.rst
@@ -1,9 +1,5 @@
-.. {#openvino_workflow}
-
OpenVINO Workflow
-=================
-
-
+================================================
.. meta::
:description: OpenVINO toolkit workflow usually involves preparation,
@@ -15,7 +11,7 @@ OpenVINO Workflow
:hidden:
Model Preparation <openvino-workflow/model-preparation>
- Model Optimization and Compression <openvino-workflow/model-optimization>
+ openvino-workflow/model-optimization
Running Inference <openvino-workflow/running-inference>
Deployment on a Local System <openvino-workflow/deployment-locally>
Deployment on a Model Server <ovms_what_is_openvino_model_server>
diff --git a/docs/articles_en/openvino-workflow/model-optimization-guide/compressing-models-during-training.rst b/docs/articles_en/openvino-workflow/model-optimization-guide/compressing-models-during-training.rst
index ec08b12894e..e8761bab85b 100644
--- a/docs/articles_en/openvino-workflow/model-optimization-guide/compressing-models-during-training.rst
+++ b/docs/articles_en/openvino-workflow/model-optimization-guide/compressing-models-during-training.rst
@@ -1,5 +1,3 @@
-.. {#tmo_introduction}
-
Compressing Models During Training
==================================
@@ -33,26 +31,8 @@ See the following Jupyter Notebooks for step-by-step examples showing how to add
- `Quantization Aware Training with NNCF and PyTorch <https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/pytorch-quantization-aware-training>`__.
- `Quantization Aware Training with NNCF and TensorFlow <https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/tensorflow-quantization-aware-training>`__.
-Installation
-####################
-
-NNCF is open-sourced on `GitHub <https://github.com/openvinotoolkit/nncf>`__ and distributed as a separate package from OpenVINO. It is also available on PyPI. Install it to the same Python environment where PyTorch or TensorFlow is installed.
-
-Install from PyPI
-++++++++++++++++++++
-
-To install the latest released version via pip manager run the following command:
-
-.. code-block:: sh
-
- pip install nncf
-
-
-To install the latest NNCF version from source, follow the instruction on `GitHub <https://github.com/openvinotoolkit/nncf#installation>`__.
-
-.. note::
-
- NNCF does not have OpenVINO as an installation requirement. To deploy optimized models you should install OpenVINO separately.
+More detailed information about NNCF (e.g. installation guide) is present in the dedicated
+:doc:`NNCF article <../model-optimization>`.
Working with NNCF
####################
@@ -60,7 +40,7 @@ Working with NNCF
The figure below shows a common workflow of applying training-time compressions with NNCF. The NNCF optimizations are added to the TensorFlow or PyTorch training script, and then the model undergoes fine-tuning. The optimized model can then be exported to OpenVINO IR format for accelerated performance with OpenVINO Runtime.
.. image:: ../../assets/images/nncf_workflow.svg
-
+ :align: center
Training-Time Compression Methods
+++++++++++++++++++++++++++++++++
@@ -104,6 +84,7 @@ Additional Resources
####################
- :doc:`Quantizing Models Post-training <quantizing-models-post-training>`
+- :doc:`Model Optimization - NNCF <../model-optimization>`
- `NNCF GitHub repository <https://github.com/openvinotoolkit/nncf>`__
- `NNCF FAQ <https://github.com/openvinotoolkit/nncf/blob/develop/docs/FAQ.md>`__
- `Quantization Aware Training with NNCF and PyTorch <https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/pytorch-quantization-aware-training>`__.
diff --git a/docs/articles_en/openvino-workflow/model-optimization-guide/quantizing-models-post-training.rst b/docs/articles_en/openvino-workflow/model-optimization-guide/quantizing-models-post-training.rst
index d34da0d615f..599c23f90c9 100644
--- a/docs/articles_en/openvino-workflow/model-optimization-guide/quantizing-models-post-training.rst
+++ b/docs/articles_en/openvino-workflow/model-optimization-guide/quantizing-models-post-training.rst
@@ -26,7 +26,7 @@ any training datasets or pipelines in the source DL framework.
.. image:: ../../assets/images/quantization_picture.svg
-`Neural Network Compression Framework (NNCF) <https://github.com/openvinotoolkit/nncf>`__
+:doc:`Neural Network Compression Framework (NNCF) <../model-optimization>`
provides a post-training quantization API, available in Python, that aims at reusing the code for
model training or validation that is usually available with the model in the source framework,
such as PyTorch or TensroFlow. The NNCF API is cross-framework and currently supports:
@@ -48,5 +48,6 @@ Additional Resources
####################
* :doc:`Optimizing Models at Training Time <compressing-models-during-training>`
+* :doc:`Model Optimization - NNCF <../model-optimization>`
* `NNCF GitHub <https://github.com/openvinotoolkit/nncf>`__
diff --git a/docs/articles_en/openvino-workflow/model-optimization.rst b/docs/articles_en/openvino-workflow/model-optimization.rst
index 17903c760e1..076a0ef8aad 100644
--- a/docs/articles_en/openvino-workflow/model-optimization.rst
+++ b/docs/articles_en/openvino-workflow/model-optimization.rst
@@ -1,69 +1,113 @@
-.. {#openvino_docs_model_optimization_guide}
-
-Model Optimization Guide
-========================
-
+Model Optimization - NNCF
+===============================================================================================
.. toctree::
:maxdepth: 1
:hidden:
+ model-optimization-guide/weight-compression
model-optimization-guide/quantizing-models-post-training
model-optimization-guide/compressing-models-during-training
- model-optimization-guide/weight-compression
-Model optimization is an optional offline step of improving the final model performance
-and reducing the model size by applying special optimization methods, such as 8-bit
-quantization, pruning, etc. OpenVINO offers three optimization paths implemented in
-`Neural Network Compression Framework (NNCF) <https://github.com/openvinotoolkit/nncf>`__:
+Model optimization means altering the model itself to improve its performance and reduce
+its size. It is an optional step, typically used only at the development stage, so that
+a pre-optimized model is used in the final AI application.
-- :doc:`Post-training Quantization <model-optimization-guide/quantizing-models-post-training>`
- is designed to optimize the inference of deep learning models by applying the
- post-training 8-bit integer quantization that does not require model retraining
- or fine-tuning.
+In OpenVINO, the default optimization tool is NNCF (Neural Network Compression Framework).
+It is a `set of compression algorithms <https://github.com/openvinotoolkit/nncf/blob/develop/README.md>`__,
+organized as a Python package, that make your models smaller and faster. Note that NNCF
+is **not part of the OpenVINO package**, so it needs to be installed separately. It supports
+models in **PyTorch**, **TensorFlow** , **ONNX**, and **OpenVINO IR** formats, offering
+the following optimizations:
-- :doc:`Training-time Optimization <model-optimization-guide/compressing-models-during-training>`
- , a suite of advanced methods for training-time model optimization within the DL
- framework, such as PyTorch and TensorFlow 2.x. It supports methods like
- Quantization-aware Training, Structured and Unstructured Pruning, etc.
+.. image:: ../assets/images/WHAT_TO_USE.svg
-- :doc:`Weight Compression <model-optimization-guide/weight-compression>`,
- an easy-to-use method for Large Language Models footprint reduction and inference acceleration.
-.. note::
+| :doc:`Weight Compression <model-optimization-guide/weight-compression>`:
+| an easy-to-use method for Large Language Model footprint reduction and inference
+ acceleration.
+
+| :doc:`Post-training Quantization <model-optimization-guide/quantizing-models-post-training>`:
+| designed to optimize deep learning models by applying 8-bit integer quantization. Being
+ the easiest way to optimize a model it does not require its retraining or fine-tuning
+ but may result in a drop in accuracy. If the accuracy-performance tradeoff is not
+ acceptable, Training-time Optimization may be a better option.
+
+| :doc:`Training-time Optimization <model-optimization-guide/compressing-models-during-training>`:
+| involves a suite of advanced methods such as Structured or Unstructured Pruning, as well
+ as Quantization-aware Training. This kind of optimization requires the use of the model's
+ original framework, for NNCF, it is either PyTorch or TensorFlow.
- OpenVINO also supports optimized models (for example, quantized) from source
- frameworks such as PyTorch, TensorFlow, and ONNX (in Q/DQ; Quantize/DeQuantize format).
- No special steps are required in this case and optimized models can be converted to
- the OpenVINO Intermediate Representation format (IR) right away.
-Post-training Quantization is the fastest way to optimize an arbitrary DL model and should
-be applied first, but it is limited in terms of achievable accuracy-performance trade-off.
-The recommended approach to obtain OpenVINO quantized model is to convert
-`a model from original framework <https://huggingface.co/models>`__ to ``ov.Model``
-and ensure that the model works correctly in OpenVINO, for example, by calculating the
-model metrics. Then, ``ov.Model`` can be used as input for the ``nncf.quantize()``
-method to get the quantized model or as input for the ``nncf.compress_weights()``
-method to compress weights of Large Language Models (see the diagram below).
+To learn about the full scope of the framework, its installation, and technical details, visit
+both `the NNCF repository <https://github.com/openvinotoolkit/nncf?tab=readme-ov-file>`__ and
+`NNCF API documentation <https://openvinotoolkit.github.io/nncf/autoapi/nncf/>`__.
+
-In case of unsatisfactory accuracy or performance after Post-training Quantization,
-Training-time Optimization can be used as an option.
.. image:: ../assets/images/DEVELOPMENT_FLOW_V3_crunch.svg
-Once the model is optimized using the aforementioned methods, it can be used for
-inference using the regular OpenVINO inference workflow. No changes to the inference
-code are required.
-.. image:: ../assets/images/WHAT_TO_USE.svg
+.. tab-set::
-Additional Resources
-####################
+ .. tab-item:: Installation
+ :sync: install
+
+ .. tab-set::
+
+ .. tab-item:: PyPI
+ :sync: pip
+
+ .. code-block::
+
+ pip install nncf
+
+ .. tab-item:: Conda
+ :sync: conda
-- :doc:`Post-training Quantization <model-optimization-guide/quantizing-models-post-training>`
-- :doc:`Training-time Optimization <model-optimization-guide/compressing-models-during-training>`
-- :doc:`Weight Compression <model-optimization-guide/weight-compression>`
-- :doc:`Deployment optimization <running-inference/optimize-inference>`
-- `Hugging Face Optimum Intel <https://huggingface.co/docs/optimum/intel/optimization_ov>`__
+ .. code-block::
+
+ conda install -c conda-forge nncf
+
+ For more installation details, see the page on
+ `NNCF Installation <https://github.com/openvinotoolkit/nncf/blob/develop/docs/Installation.md>`__.
+
+ .. tab-item:: System Requirements
+ :sync: sys-req
+
+ Full requirement listing is available in the
+ `NNCF GitHub Repository <https://github.com/openvinotoolkit/nncf?tab=readme-ov-file#system-requirements>`__
+
+ Note that to optimize a model, you will need to install this model's framework as well.
+ Install NNCF in the same Python environment as the framework. For a list of recommended
+ framework versions, see the
+ `framework compatibility table <https://github.com/openvinotoolkit/nncf/blob/develop/docs/Installation.md#corresponding-versions>`__.
+
+
+.. note::
+
+ Once optimized, models may be executed with the typical OpenVINO inference workflow,
+ no additional changes to the inference code are required.
+
+ This is true for models optimized using NNCF, as well as those pre-optimized in their source
+ frameworks, such as PyTorch, TensorFlow, and ONNX (in Q/DQ; Quantize/DeQuantize format).
+ The latter may be easily converted to the
+ :doc:`OpenVINO Intermediate Representation format (IR) <../../documentation/openvino-ir-format>`
+ right away.
+
+
+`Hugging Face Optimum Intel <https://huggingface.co/docs/optimum/intel/optimization_ov>`__
+offers OpenVINO integration with Hugging Face models and pipelines. NNCF serves as the compression
+backend within the Hugging Face Optimum Intel, integrating with the widely used transformers
+library to enhance model performance.
+
+
+Additional Resources
+#######################
+* `NNCF GitHub repository <https://github.com/openvinotoolkit/nncf>`__
+* `NNCF Architecture <https://github.com/openvinotoolkit/nncf/blob/develop/docs/NNCFArchitecture.md>`__
+* `NNCF Tutorials <https://github.com/openvinotoolkit/nncf?tab=readme-ov-file#demos-tutorials-and-samples>`__
+* `NNCF Compressed Model Zoo <https://github.com/openvinotoolkit/nncf/blob/develop/docs/ModelZoo.md>`__
+* :doc:`Deployment optimization <running-inference/optimize-inference>`
\ No newline at end of file