经 AI Skill Hub 精选评估,神经网络压缩框架 获评「强烈推荐」。已获得 1.2k 颗 GitHub Star,这款AI工具在功能完整性、社区活跃度和易用性方面表现出色,AI 评分 8.0 分,适合有一定技术背景的用户使用。
神经网络压缩框架 是一款基于 Python 开发的开源工具,专注于 compression、deep-learning、python 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
神经网络压缩框架 是一款基于 Python 开发的开源工具,专注于 compression、deep-learning、python 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。
# 方式一:pip 安装(推荐)
pip install nncf
# 方式二:虚拟环境安装(推荐生产环境)
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install nncf
# 方式三:从源码安装(获取最新功能)
git clone https://github.com/openvinotoolkit/nncf
cd nncf
pip install -e .
# 验证安装
python -c "import nncf; print('安装成功')"
# 命令行使用
nncf --help
# 基本用法
nncf input_file -o output_file
# Python 代码中调用
import nncf
# 示例
result = nncf.process("input")
print(result)
# nncf 配置文件示例(config.yml) app: name: "nncf" debug: false log_level: "INFO" # 运行时指定配置文件 nncf --config config.yml # 或通过环境变量配置 export NNCF_API_KEY="your-key" export NNCF_OUTPUT_DIR="./output"
For detailed installation instructions, refer to the Installation guide.
NNCF can be installed as a regular PyPI package via pip:
pip install nncf
NNCF is also available via conda:
conda install -c conda-forge nncf
System requirements of NNCF correspond to the used backend. System requirements for each backend and the matrix of corresponding versions can be found in installation.md.
For a quicker start with NNCF-powered compression, try sample notebooks and scripts presented below.
Ready-to-run Jupyter* notebook tutorials and demos are available to explain and display NNCF compression algorithms for optimizing models for inference with the OpenVINO Toolkit:
| Notebook Tutorial Name | Compression Algorithm | Backend | Domain |
|---|---|---|---|
| [BERT Quantization](https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/language-quantize-bert)<br>[](https://colab.research.google.com/github/openvinotoolkit/openvino_notebooks/blob/latest/notebooks/language-quantize-bert/language-quantize-bert.ipynb) | Post-Training Quantization | OpenVINO | NLP |
| [MONAI Segmentation Model Quantization](https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/ct-segmentation-quantize)<br>[](https://mybinder.org/v2/gh/openvinotoolkit/openvino_notebooks/HEAD?filepath=notebooks%2Fct-segmentation-quantize%2Fct-scan-live-inference.ipynb) | Post-Training Quantization | OpenVINO | Segmentation |
| [PyTorch Model Quantization](https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/pytorch-post-training-quantization-nncf) | Post-Training Quantization | PyTorch | Image Classification |
| [YOLOv11 Quantization with Accuracy Control](https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/yolov11-quantization-with-accuracy-control) | Post-Training Quantization with Accuracy Control | OpenVINO | Speech-to-Text,<br>Object Detection |
A list of notebooks demonstrating OpenVINO conversion and inference together with NNCF compression for models from various domains:
| Demo Model | Compression Algorithm | Backend | Domain |
|---|---|---|---|
| [OneFormer](https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/oneformer-segmentation) | Post-Training Quantization | OpenVINO | Image Segmentation |
| [CLIP](https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/clip-zero-shot-image-classification) | Post-Training Quantization | OpenVINO | Image-to-Text |
| [BLIP](https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/blip-visual-language-processing) | Post-Training Quantization | OpenVINO | Image-to-Text |
| [Latent Consistency Model](https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/latent-consistency-models-image-generation) | Post-Training Quantization | OpenVINO | Text-to-Image |
| [Distil-Whisper](https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/distil-whisper-asr) | Post-Training Quantization | OpenVINO | Speech-to-Text |
| [Whisper](https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/whisper-subtitles-generation)<br>[](https://colab.research.google.com/github/openvinotoolkit/openvino_notebooks/blob/latest/notebooks/whisper-subtitles-generation/whisper-convert.ipynb) | Post-Training Quantization | OpenVINO | Speech-to-Text |
| [MMS Speech Recognition](https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/mms-massively-multilingual-speech) | Post-Training Quantization | OpenVINO | Speech-to-Text |
| [LLM Instruction Following](https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/llm-question-answering) | Weight Compression | OpenVINO | NLP, Instruction Following |
| [LLM Chat Bots](https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/llm-chatbot) | Weight Compression | OpenVINO | NLP, Chat Bot |
Compact scripts demonstrating quantization/weight compression and corresponding inference speed boost:
| Example Name | Compression Algorithm | Backend | Domain |
|---|---|---|---|
| [OpenVINO MobileNetV2](./examples/post_training_quantization/openvino/mobilenet_v2/README.md) | Post-Training Quantization | OpenVINO | Image Classification |
| [OpenVINO YOLO26](./examples/post_training_quantization/openvino/yolo26/README.md) | Post-Training Quantization | OpenVINO | Object Detection |
| [OpenVINO YOLOv8 QwAC](./examples/post_training_quantization/openvino/yolov8_quantize_with_accuracy_control/README.md) | Post-Training Quantization with Accuracy Control | OpenVINO | Object Detection |
| [OpenVINO Anomaly Classification](./examples/post_training_quantization/openvino/anomaly_stfpm_quantize_with_accuracy_control/README.md) | Post-Training Quantization with Accuracy Control | OpenVINO | Anomaly Classification |
| [PyTorch MobileNetV2](./examples/post_training_quantization/torch/mobilenet_v2/README.md) | Post-Training Quantization | PyTorch | Image Classification |
| [PyTorch SSD](./examples/post_training_quantization/torch/ssd300_vgg16/README.md) | Post-Training Quantization | PyTorch | Object Detection |
| [TorchFX Resnet18](./examples/post_training_quantization/torch_fx/resnet18/README.md) | Post-Training Quantization | TorchFX | Image Classification |
| [ONNX MobileNetV2](./examples/post_training_quantization/onnx/mobilenet_v2/README.md) | Post-Training Quantization | ONNX | Image Classification |
| [ONNX YOLOv8 QwAC](./examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control/README.md) | Post-Training Quantization with Accuracy Control | ONNX | Object Detection |
| [ONNX TinyLlama WC](./examples/llm_compression/onnx/tiny_llama/README.md) | Weight Compression | ONNX | LLM |
| [TorchFX TinyLlama WC](./examples/llm_compression/torch_fx/tiny_llama/README.md) | Weight Compression | TorchFX | LLM |
| [OpenVINO TinyLlama WC](./examples/llm_compression/openvino/tiny_llama/README.md) | Weight Compression | OpenVINO | LLM |
| [OpenVINO TinyLlama WC with HS](./examples/llm_compression/openvino/tiny_llama_find_hyperparams/README.md) | Weight Compression with Hyperparameters Search | OpenVINO | LLM |
| [ONNX TinyLlama WC with SE](./examples/llm_compression/onnx/tiny_llama_scale_estimation/README.md) | Weight Compression with Scale Estimation | ONNX | LLM |
| Example Name | Compression Algorithm | Backend | Domain |
|---|---|---|---|
| [PyTorch Resnet18](./examples/quantization_aware_training/torch/resnet18/README.md) | Quantization-Aware Training | PyTorch | Image Classification |
| [PyTorch Anomalib](./examples/quantization_aware_training/torch/anomalib/README.md) | Quantization-Aware Training | PyTorch | Anomaly Detection |
<a id="third-party-repository-integration"></a>
Refer to the CONTRIBUTING.md file for guidelines on contributions to the NNCF repository.
quantized_model = nncf.quantize(model, calibration_dataset)
</details>
<details><summary><b>PyTorch</b></summary>
python import nncf import torch from torchvision import datasets, models
quantized_model = nncf.quantize(model, calibration_dataset)
**NOTE** If the Post-Training Quantization algorithm does not meet quality requirements you can fine-tune the quantized pytorch model. You can find an example of the Quantization-Aware training pipeline for a pytorch model [here](examples/quantization_aware_training/torch/resnet18/README.md).
</details>
<details><summary><b>TorchFX</b></summary>
python import nncf import torch.fx from torchvision import datasets, models
quantized_fx_model = nncf.quantize(fx_model, calibration_dataset)
</details>
<details><summary><b>ONNX</b></summary>
python import onnx import nncf import torch from torchvision import datasets
quantized_model = nncf.quantize(onnx_model, calibration_dataset) ```
</details>
[//]: # (NNCF provides full [samples](#post-training-quantization-samples), which demonstrate Post-Training Quantization usage for PyTorch, ONNX, and OpenVINO.)
quantized_model = nncf.quantize(model, calibration_dataset)
checkpoint = { 'state_dict': model.state_dict(), 'nncf_config': nncf.torch.get_config(model), ... # the rest of the user-defined objects to save } torch.save(checkpoint, path_to_checkpoint)
resuming_checkpoint = torch.load(path_to_checkpoint) nncf_config = resuming_checkpoint['nncf_config'] state_dict = resuming_checkpoint['state_dict']
quantized_model = nncf.torch.load_from_config(model, nncf_config) quantized_model.load_state_dict(state_dict)
```
</details>
<a id="demos-tutorials-and-samples"></a>
NNCF may be easily integrated into training/evaluation pipelines of third-party repositories.
高质量的开源AI工具,易于使用
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ Apache 2.0 — 宽松开源协议,可商用,需保留版权声明和 NOTICE 文件,含专利授权条款。
AI Skill Hub 点评:神经网络压缩框架 的核心功能完整,质量优秀。对于AI 技术爱好者来说,这是一个值得纳入个人工具库的选择。建议先在非生产环境试用,再逐步推广。
| 原始名称 | nncf |
| Topics | compressiondeep-learningpython |
| GitHub | https://github.com/openvinotoolkit/nncf |
| License | Apache-2.0 |
| 语言 | Python |
收录时间:2026-06-24 · 更新时间:2026-06-24 · License:Apache-2.0 · AI Skill Hub 不对第三方内容的准确性作法律背书。