OpenVINO™ 2023.2 发布:让生成式 AI 在实际场景中更易用

点击蓝字

关注我们,让开发变得更有趣

作者:Yury Gorbachev

英特尔院士  OpenVINO™ 产品架构师

翻译:武卓 英特尔 AI 软件布道师

9b05ee59fe3e25b240afdcfb2e366c6a.png

在过去的一年里,人工智能正以越来越快的速度发展,这得益于生成式 AI 模型的引入和从中受益的场景的演变。我们承认这一点,并决定比平时更快地发布新版本的 OpenVINO™ ,以帮助您获得新功能!

与之前的版本一样,在提高性能、增加对新 AI 模型的支持以及构建基础设施和模型缓存等不同组件方面,我们做了大量工作。对于我们最新的 2023.2 版本,我们做出了一些重大改进,我们将在下面概述。

bae414f5896b9f44d2d6e3e9ec495c0d.png

边缘文本生成模型的附加性能

在我们的上一个版本 2023.1 中,我们引入了一些更改,以在英特尔 CPU 和 GPU 上运行大语言模型(LLM)。开发者们能够量化权重为 int8 格式,并将其作为初始步骤在 CPU 上运行。

在 2023.2 版本中,我们进一步优化此工作流程,并引入在 CPU 和集成显卡上运行权重量化为 int8 和 int4 精度的 LLM 的能力。权重量化直接影响内存带宽,并帮助模型更快、更高效地执行推理,因为模型消耗的内存更少了,所需的磁盘空间也更少,因此总体上需要的内存带宽也更少了!

此外,我们的模型转换和优化工具已经更新,可以帮助您处理模型准备流程。要压缩模型权重为 int8 和 int4 格式,您可以使用我们的神经网络压缩框架(NNCF)工具,该工具适用于 OpenVINO™ 格式或中间表示(IR)文件。此外,为了获得具有int4压缩权重的模型,您可以通过 GPTQ(生成预训练 transformers 量化)算法来优化转换模型。实现这一过程的一种方法是通过 Hugging Face AutoGPTQ 实现。

如果你将 Hugging Face 作为模型的来源,你可以使用我们的 optimum-Intel,它集成了 OpenVINO™ 的优势。此集成允许您自动压缩和转换模型,如我们在下面所示的这样:

要将模型压缩到 int8 精度:

#make use of optimum-intel
from optimum.intel import OVModelForCausalLM
#load pretrained model, convert to OpenVINO representation 
#and compress weights
model = OVModelForCausalLM.from_pretrained("meta-llama/Llama-2-7b", use_cache=True, export=True, load_in_8bit=True)
#store OpenVINO IR in a folder
model.save_pretrained("./Llama-2-7b")

左滑查看更多

请注意“load_in_8bit”选项,该选项指定应将原始模型压缩到 int8 精度。对于大于 1B 的模型,默认情况下会启用此选项。

要将模型压缩到 int4 精度:

#make use of optimum-intel
from optimum.intel import OVModelForCausalLM
#explicitly use NNCF for compression
from nncf import compress_weights, CompressWeightsMode
#load pretrained model, convert to OpenVINO representation
model = OVModelForCausalLM.from_pretrained("meta-llama/Llama-2-7b", use_cache=True, export=True, load_in_8bit=False)
#perform weights compression using NNCF
model.model = compress_weights(model.model, mode=CompressWeightsMode.INT4_SYM, group_size=128, ratio=0.8)
#store OpenVINO IR in a folder
model.save_pretrained("./Llama-2-7b")

左滑查看更多

请注意,这一次我们没有使用 HF API 功能,而是直接调用 NNCF 将权重压缩到 int4。根据模型的不同,您可以更改压缩参数以获得更准确的结果。在这种情况下,我们使用对称量化,组大小为 128 个元素,int4 与 int8 的权重之比为 0.8。您可以查看我们的权重压缩文档,以获得更多详细信息和压缩提示。

要转换使用 AutoGPTQ 优化为 int4 精度的模型,请执行以下操作:

#make use of optimum-intel
from optimum.intel import OVModelForCausalLM
#load pretrained model, convert to OpenVINO representation 
#with keeping weights in int4
model = OVModelForCausalLM.from_pretrained("TheBloke/Llama-2-7B-GPTQ", use_cache=True, export=True)
#store OpenVINO IR in a folder
model.save_pretrained("./Llama-2-7B-GPTQ")

左滑查看更多

优化模型就是这么简单。更详细的信息请查看:

https://docs.openvino.ai/2023.2/gen_ai_guide.html

(复制链接到浏览器打开)

da3f1cf37d02c3289ee6c1cdcb012f4c.png

新的生成式 AI 

以及更多的 Notebooks 代码示例!

我们知道,亲身体验最新功能和最先进模型是最好的学习方式。因此,我们的 OpenVINO™ 团队非常专注于为 OpenVINO™ Notebooks 代码示例带来新的及备受关注的模型。我们希望展示并鼓励您立即在您的设备上进行本地实验,以获得您所需的性能。以下是我们最近更新或新发布的一些 Notebooks 代码示例,以帮助您更快地将想法付诸生产。

一些 Jupyter Notebooks 已经更新,以演示 PyTorch 模型在没有 ONNX 转换的情况下的转换和优化,包括以下内容:

PyTorch to OpenVINO™

(https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/102-pytorch-to-openvino ) 

—— 转换格式为 torch.nn.Module 以及 torch.jit.ScriptModule 的 PyTorch 模型为 OpenVINO™ IR 格式

Post-Training Quantization of PyTorch models with NNCF

(https://github.com/openvinotoolkit/openvino_notebooks/blob/main/notebooks/112-pytorch-post-training-quantization-nncf/112-pytorch-post-training-quantization-nncf.ipynb ) 

—— 将 int8 量化应用于 PyTorch 模型

Quantization of Image Classification Models

(https://github.com/openvinotoolkit/openvino_notebooks/blob/main/notebooks/113-image-classification-quantization/113-image-classification-quantization.ipynb ) 

—— 将 int8 量化应用于 MobileNet V2 PyTorch 模型

Visual Question Answering and Image Captioning using BLIP and OpenVINO™

(https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/233-blip-visual-language-processing )

—— 优化 BLIP PyTorch 模型

Text-to-Image Generation and Infinite Zoom with Stable Diffusion v2 and OpenVINO™

(https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/236-stable-diffusion-v2 )

—— 在 Stable Diffusion 2.0 流水线中优化模型

Object masks from prompts with SAM and OpenVINO™

(https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/237-segment-anything#object-masks-from-prompts-with-sam--and-openvino )

—— 优化基于 PyTorch 的 Segment Anything Model (SAM) 模型

Optimizing PyTorch models with Neural Network Compression Framework of OpenVINO™ by 8-bit quantization

(https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/302-pytorch-quantization-aware-training )

—— PyTorch 模型量化感知训练(QAT)

我们还加入了一些 notebooks 代码示例,展示如何转换和优化模型,包括来自 TensorFlow Hub, TorchVision, and Hugging Face Hub 的模型。

TorchaVision Zoo with OpenVINO™

(https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/125-torchvision-zoo-to-openvino )

—— 下载和直接优化基于 PyTorch 的预训练模型

Hugging Face Model Hub with OpenVINO™

(https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/124-hugging-face-hub )

—— 学习如何下载和优化 Hugging Face hub 的预训练模型

TensorFlow Hub models + OpenVINO™

(https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/126-tensorflow-hub )

—— 学习如何下载和优化 TensorFlow Hub 的预训练模型

Convert Detectron2 Models to OpenVINO™

(https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/123-detectron2-to-openvino )

—— 优化来自 Facebook Research 流行的目标检测和分割模型

Convert TensorFlow Object Detection and Instance Segmentation Models to OpenVINO™

(https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/120-tensorflow-object-detection-to-openvino)

—— 优化来自于 TensorFlow Hub 的使用 Resnet-50 V1 的 Faster R-CNN

Visual-language assistant with LLaVA and OpenVINO™

(https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/257-llava-multimodal-chatbot )

—— 使用 LLaVA (Large Language and Vision Assistant) 的端到端多模态演示

Subject-driven image generation and editing using BLIP Diffusion and OpenVINO ™

(https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/258-blip-diffusion-subject-generation )

—— 优化用于零样本主题驱动的图像生成的 BLIP 扩散模型

SoftVC VITS Singing Voice Conversion and OpenVINO™

(https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/262-softvc-voice-conversion#softvc-vits-singing-voice-conversion-and-openvino )

—— 优化以音频作为输入的声音转换模型 SoftVC 及 VITS

Object segmentations with FastSAM and OpenVINO™

(https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/261-fast-segment-anything ) 

—— 优化用于目标分割的 Fast Segment Anything Model (FastSAM) 模型

Image Generation with DeciDiffusion

(https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/259-decidiffusion-image-generation )

—— 优化用于文生图的 DeciDiffusion 1.0 模型

Document Visual Question Answering Using Pix2Struct and OpenVINO™

(https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/260-pix2struct-docvqa )

—— 利用 OCR 和语言模型进行多模态问答的演示

db85036870aaf7d4533d36a12ebcdee4.png

图 1: 文档视觉问答

最后,我们还提供了几个具有开箱即用、优化性能的流行的生成式 AI 的 notebooks 代码示例:

Create an LLM-powered Chatbot using OpenVINO™

(https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/254-llm-chatbot#create-llm-powered-chatbot-using-openvino ) 

—— 在 CPU 和 GPU 上运行具有 int8 权重压缩的 Llama2 等聊天机器人,令人印象深刻的是,它将在只有 24GB RAM 的笔记本电脑上运行。

Image generation with Latent Consistency Model and OpenVINO™

(https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/263-latent-consistency-models-image-generation )

—— 用低得多的计算机资源实现卓越的图像生成

Generate creative QR codes with ControlNet QR Code Monster and OpenVINO™

(https://github.com/openvinotoolkit/openvino_notebooks/tree/main/notebooks/264-qrcode-monster )

—— 使用 ControlNet 和 Stable Diffusion 创建您自己的图形二维码。

cd3ac66533a91b2263eed3e448d696c1.png

图2: 使用 OpenVINO™ 优化基于大语言模型的聊天机器人

1d3aed0df5e1e34e34b30363b33bb553.png

图3: ControlNet 二维码 Monster 以及 OpenVINO™

53feba36178aa51b84f11c94c21b56b8.png

新的分发渠道

在这个版本中,我们继续改进您访问和使用 OpenVINO™ 进行 AI 应用程序开发的方式,我们已经开发了一个 Conan(https://conan.io)软件包管理器。Conan 允许您为大型项目执行包管理,我们很高兴看到已经有开发者对此做出的积极回应。

有关如何使用 OpenVINO™ Conan 软件包的更多详细信息,请参阅此处:

https://docs.openvino.ai/2023.1/openvino_docs_install_guides_installing_openvino_conan.html

(复制链接到浏览器打开)

OpenVINO™ 是在开源中开发的,一旦在我们的初步测试中验证了这些功能,我们的最新功能就可以在我们的主分支上获得。因此,如果您想尝试新功能,您可以随时从源代码构建我们的包。对于 pip 用户,我们通过引入 openvino-nightly 包来简化这一点。你可以使用这个每日构建的包来尝试最新的功能,并在我们的下一个官方版本中预览一下!

78718307e378fe198f33905f4de1bcfe.png

开源贡献对我们来说很重要!

OpenVINO™ 已经是一个超过 5 年的开源项目了。最近,我们准备了一系列贡献任务,通过向  OpenVINO™ 贡献,可以更好地帮助社区围绕人工智能生态系统和开源项目构建知识。这包括支持新的编译选项和添加更多需要注意的操作等任务。

查看我们在 GitHub 上的链接,看看有没有你感兴趣的任务!

https://github.com/openvinotoolkit/openvino/issues/17502

(复制链接到浏览器打开)

如上所述,我们非常感谢迄今为止我们看到的所有被合并进来的开源贡献。我们还要公开感谢我们最近的一些贡献者!他们是 Siddhant Chauhan、rsa-10、Santhosh Mamidisetti 和 Mahimai Raja J.。由于您的帮助,产品变得更好!

362d45f2eaa539cb4782a9d12bb074c5.png

其它资源

[1] OpenVINO™ 文档

http://docs.openvino.ai/

[2] OpenVINO™ Notebooks

https://github.com/openvinotoolkit/openvino_notebooks

[3] 提供反馈及上报问题

https://github.com/openvinotoolkit/openvino/issues/new/choose

OpenVINO™

--END--

你也许想了解(点击蓝字查看)⬇️➡️ 开发者实战 | 介绍OpenVINO™ 2023.1:在边缘端赋能生成式AI➡️ 基于 ChatGLM2 和 OpenVINO™ 打造中文聊天助手➡️ 基于 Llama2 和 OpenVINO™ 打造聊天机器人➡️ OpenVINO™ DevCon 2023重磅回归!英特尔以创新产品激发开发者无限潜能➡️ 5周年更新 | OpenVINO™  2023.0,让AI部署和加速更容易➡️ OpenVINO™5周年重头戏!2023.0版本持续升级AI部署和加速性能➡️ OpenVINO™2023.0实战 | 在 LabVIEW 中部署 YOLOv8 目标检测模型➡️ 开发者实战系列资源包来啦!➡️ 以AI作画,祝她节日快乐;简单三步,OpenVINO™ 助你轻松体验AIGC
➡️ 还不知道如何用OpenVINO™作画?点击了解教程。➡️ 几行代码轻松实现对于PaddleOCR的实时推理,快来get!➡️ 使用OpenVINO 在“端—边—云”快速实现高性能人工智能推理
扫描下方二维码立即体验 
OpenVINO™ 工具套件 2023.2

点击 阅读原文 立即体验OpenVINO 2023.2

7530faf46dce9879ac5f8bf33f16a2d6.png

文章这么精彩,你有没有“在看”?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值