女人自慰AV免费观看内涵网,日韩国产剧情在线观看网址,神马电影网特片网,最新一级电影欧美,在线观看亚洲欧美日韩,黄色视频在线播放免费观看,ABO涨奶期羡澄,第一导航fulione,美女主播操b

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
會員中心
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

Intel OpenVINO? Day0 實現阿里通義 Qwen3 快速部署

英特爾物聯網 ? 來源: 英特爾物聯網 ? 2025-05-11 11:36 ? 次閱讀

前言

Qwen3 是阿里通義團隊近期最新發布的文本生成系列模型,提供完整覆蓋全參數和混合專家(MoE)架構的模型體系。經過海量數據訓練,Qwen3 在邏輯推理、指令遵循、智能體能力及多語言支持等維度實現突破性提升。而 OpenVINO 工具套件則可以幫助開發者快速構建基于 LLM 的應用,充分利用 AI PC 異構算力,實現高效推理。

本文將以Qwen3-8B為例,介紹如何利用 OpenVINO 的 Python API英特爾平臺(GPU, NPU)Qwen3 系列模型。

內容列表

01 環境準備

02 模型下載和轉換

03 模型部署

01 Environment Preparation

02 Model Download and Conversion

03 Model Deployment

環境準備

Environment Preparation

基于以下命令可以完成模型部署任務在 Python 上的環境安裝。

Use the following commands to set up the Python environment for model deployment:

python-m venv py-venv
./py_venv/Scripts/activate.bat


pip install--pre-U openvino openvino-tokenizers--extra-index-url
http://sstorage.openvinotoolkit.org/simple/wheels/hightly


pip intall nncf


pip intall
git+https://github.com/openvino-dev-samples/optimum-intel.git@2aebd4441023d3c003b27c87fff5312254ae


pip install transformers>=4.51.3

模型下載和轉換

Model Download and Conversion

在部署模型之前,我們首先需要將原始的 PyTorch 模型轉換為 OpenVINO 的 IR 靜態圖格式,并對其進行壓縮,以實現更輕量化的部署和最佳的性能表現。通過 Optimum 提供的命令行工具 optimum-cli,我們可以一鍵完成模型的格式轉換和權重量化任務:

Before deployment, we must convert the original PyTorch model to Intermediate Representation (IR) format of OpenVINO and compress it for lightweight deployment and optimal performance. Use the optimum-cli tool to perform model conversion and weight quantization in one step:

optimum-cli export openvino --model Qwen/Qwen3-8B --task text-generation-with-past --weight-format int4 --group-size128--ratio0.8 Qwen3-8B-int4-ov

開發者可以根據模型的輸出結果,調整其中的量化參數,包括:

--model:為模型在 HuggingFace 上的 model id,這里我們也提前下載原始模型,并將 model id 替換為原始模型的本地路徑,針對國內開發者,推薦使用 ModelScope 魔搭社區作為原始模型的下載渠道,具體加載方式可以參考 ModelScope 官方指南:https://www.modelscope.cn/docs/models/download

--weight-format:量化精度,可以選擇fp32,fp16,int8,int4,int4_sym_g128,int4_asym_g128,int4_sym_g64,int4_asym_g64

--group-size:權重里共享量化參數的通道數量

--ratio:int4/int8 權重比例,默認為1.0,0.6表示60%的權重以 int4 表,40%以 int8 表示

--sym:是否開啟對稱量化

此外我們建議使用以下參數對運行在NPU上的模型進行量化,以達到性能和精度的平衡。

Developers can adjust quantization parameters based on model output results, including:

--model:The model ID on HuggingFace. For local models, replace it with the local path. For Chinese developers, ModelScope is recommended for model downloads.s

--weight-format:Quantization precision (options: fp32, fp16, int8, int4, etc.).

--group-size:Number of channels sharing quantization parameters.

--ratio:int4/int8 weight ratio (default: 1.0).

--sym:Enable symmetric quantization.

For NPU-optimized quantization, use following command:

optimum-cli export openvino--modelQwen/Qwen3-8B --tasktext-generation-with-past--weight-formatnf4--sym--group-size-1Qwen3-8B-nf4-ov--backup-precisionint8_sym

模型部署

Model Deployment

OpenVINO 目前提供兩種針對大語言模型的部署方案,如果您習慣于 Transformers 庫的接口來部署模型,并想體驗相對更豐富的功能,推薦使用基于 Python 接口的 Optimum-intel 工具來進行任務搭建。如果您想嘗試更極致的性能或是輕量化的部署方式,GenAI API 則是不二的選擇,它同時支持 Python 和 C++ 兩種編程語言,安裝容量不到200MB。

OpenVINO currently offers two deployment methods for large language models (LLMs). If you are accustomed to deploying models via the Transformers library interface and seek richer functionality, it is recommended to use the Python-based Optimum-intel tool for task implementation. For those aiming for peak performance or lightweight deployment, the GenAI API is the optimal choice. It supports both Python and C++ programming languages, with an installation footprint of less than 200MB.

OpenVINO 為大語言模型提供了兩種部署方法:

OpenVINO offers two deployment approaches for large language models:

Optimum-intel 部署實例

Optimum-intel Deployment Example

from optimum.intel.openvino import OVModelForCausalLM
from transformers import AutoConfig, AutoTokenizer


ov_model = OVModelForCausalLM.from_pretrained(
 
llm_model_path,
  device='GPU',
)
tokenizer = AutoTokenizer.from_pretrained(llm_model_path)
prompt ="Give me a short introduction to
large language model."
messages = [{"role":"user","content": prompt}]
text = tokenizer.apply_chat_template(
  messages,
  tokenize=False,
  add_generation_prompt=True,
  enable_thinking=True
)
model_inputs = tokenizer([text], return_tensors="pt")
generated_ids = ov_model.generate(**model_inputs, max_new_tokens=1024)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
try:
  index = len(output_ids) - output_ids[::-1].index(151668)
except ValueError:
  index = 0


thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("
")
content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("
")


print("thinking content:", thinking_content)
print("content:", content)

GenAI API 部署示例

GenAI API Deployment Example

importopenvino_genai asov_genai


generation_config=ov_genai.GenerationConfig()
generation_config.max_new_tokens =128
generation_config.apply_chat_template =False


pipe=ov_genai.LLMPipeline(llm_model_path,"GPU")
result = pipe.generate(prompt, generation_config)

這里可以修改 device name 的方式將模型輕松部署到NPU上。

To deploy the model on NPU, you can replace the device name from “GPU” to “NPU”.

pipe= ov_genai.LLMPipeline(llm_model_path,"NPU")

當然你也可以通過以下方式實現流式輸出。

To enable streaming mode, you can customize a streamer for OpenVINO GenAI pipeline.

defstreamer(subword):
print(subword, end='', flush=True)
  sys.stdout.flush()

returnFalse
pipe.generate(prompt, generation_config, streamer=streamer)

此外,GenAI API 提供了 chat 模式的構建方法,通過聲明 pipe.start_chat()以及pipe.finish_chat(),多輪聊天中的歷史數據將被以 kvcache 的形態,在內存中進行管理,從而提升運行效率。

Additionally, the GenAI API provides a chat mode implementation. By invoking pipe.start_chat() and pipe.finish_chat(), history data from multi-turn conversations is managed in memory as kvcache, which can significantly boost inference efficiency.

pipe.start_chat()
whileTrue:
 try:
  
 prompt =input('question:
')
 exceptEOFError:
  
break
  pipe.generate(prompt, generation, streamer)
 print('
----------')
pipe.finish_chat()

Chat模式輸出結果示例:

Output of Chat mode:

08fac0ea-2cbf-11f0-9310-92fbcf53809c.png

總結

Conclusion

如果你對性能基準感興趣,可以訪問全新上線的 OpenVINO 模型中心(Model Hub)。這里提供了在 Intel CPU、集成 GPU、NPU 及其他加速器上的模型性能數據,幫助你找到最適合自己解決方案的硬件平臺。

Whether using Optimum-intel or OpenVINO GenAI API, developers can effortlessly deploy the converted Qwen3 model on Intel hardware platforms, enabling the creation of diverse LLM-based services and applications locally.

參考資料

Reference

llm-chatbot notebook:

https://github.com/openvinotoolkit/openvino_notebooks/tree/latest/notebooks/llm-chatbot

GenAI API:

https://github.com/openvinotoolkit/openvino.genai

聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。 舉報投訴
  • intel
    +關注

    關注

    19

    文章

    3493

    瀏覽量

    187697
  • 阿里
    +關注

    關注

    6

    文章

    453

    瀏覽量

    33172
  • 大模型
    +關注

    關注

    2

    文章

    2962

    瀏覽量

    3716
  • 通義千問
    +關注

    關注

    1

    文章

    34

    瀏覽量

    377
  • OpenVINO
    +關注

    關注

    0

    文章

    113

    瀏覽量

    392

原文標題:Intel OpenVINO? Day0 實現 Qwen3 快速部署

文章出處:【微信號:英特爾物聯網,微信公眾號:英特爾物聯網】歡迎添加關注!文章轉載請注明出處。

收藏 人收藏

    評論

    相關推薦
    熱點推薦

    在openEuler上基于vLLM Ascend部署Qwen3

    近日,阿里巴巴正式發布新一代Qwen大語言模型系列(Qwen3Qwen3-MoE),在模型規模與性能上實現多方面升級。openEuler社
    的頭像 發表于 05-07 14:44 ?261次閱讀
    在openEuler上基于vLLM Ascend<b class='flag-5'>部署</b><b class='flag-5'>Qwen3</b>

    NVIDIA使用Qwen3系列模型的最佳實踐

    阿里巴巴近期發布了其開源的混合推理大語言模型 (LLM) 通義千問 Qwen3,此次 Qwen3 開源模型系列包含兩款混合專家模型 (MoE),235B-A22B(總參數 2,350
    的頭像 發表于 05-08 11:45 ?438次閱讀
    NVIDIA使用<b class='flag-5'>Qwen3</b>系列模型的最佳實踐

    阿里通義千問Qwen2大模型發布

    阿里巴巴最近發布了其通義千問系列的新成員——Qwen2大模型,并在Hugging Face和ModelScope兩大平臺上實現了同步開源。這一舉措無疑為人工智能領域的研究者和開發者們提
    的頭像 發表于 06-07 15:59 ?994次閱讀

    阿里通義開源長文本新模型Qwen2.5-1M

    Qwen2.5-1M模型提供了7B和14B兩種尺寸供用戶選擇,以滿足不同場景下的需求。在處理長文本輸入時,該模型能夠保持穩定的性能,為用戶提供更加準確、可靠的輸出結果。 除了推出新模型外,阿里通義還同時開源了推理框架。這一
    的頭像 發表于 02-05 14:01 ?413次閱讀

    阿里通義Qwen2.5-Max模型全新升級

    近期,阿里通義團隊為用戶帶來了一個振奮人心的好消息:其旗艦版模型Qwen2.5-Max迎來了全新升級發布。 Qwen2.5-Max模型是阿里
    的頭像 發表于 02-05 14:07 ?583次閱讀

    利用英特爾OpenVINO在本地運行Qwen2.5-VL系列模型

    近期阿里通義實驗室在 Hugging Face 和 ModelScope 上開源了 Qwen2.5-VL 的 Base 和 Instruct 模型,包含 3B、7B 和 72B 在內的
    的頭像 發表于 03-12 13:42 ?674次閱讀
    利用英特爾<b class='flag-5'>OpenVINO</b>在本地運行<b class='flag-5'>Qwen</b>2.5-VL系列模型

    壁仞科技完成阿里巴巴通義千問Qwen3全系列模型支持

    4月29日,阿里巴巴通義千問發布并開源8款新版Qwen3系列“混合推理模型”(簡稱“Qwen3”)。Qwen3發布后數小時內,壁仞科技完成全
    的頭像 發表于 04-30 15:19 ?428次閱讀

    上新:小米首個推理大模型開源 馬斯克:下周推出Grok 3.5

    似乎國內外AI競爭日趨白熱化,就在阿里巴巴發布Qwen3通義千問3)之后,引發業界廣泛關注;很多大廠在跟進,大模型不斷上新: 阿里巴巴開源
    的頭像 發表于 04-30 16:08 ?592次閱讀

    幾B都有!BM1684X一鍵適配全系列Qwen3

    體驗最新的大模型能力。來看下Qwen3各個模型的benchmark得分:這些年看多了大模型的迭代,各家都在玩參數競賽和架構魔術,但阿里這次Qwen3的設計有點意思—
    的頭像 發表于 04-30 18:37 ?143次閱讀
    幾B都有!BM1684X一鍵適配全系列<b class='flag-5'>Qwen3</b>

    中科曙光DeepAI深算智能引擎全面支持Qwen3

    日前,Qwen3正式發布并全部開源8款混合推理模型。作為Qwen系列中的最新一代大型語言模型,Qwen3在推理、指令遵循、工具調用、多語言能力等方面實現全面增強。
    的頭像 發表于 05-06 15:17 ?197次閱讀

    摩爾線程GPU率先支持Qwen3全系列模型

    近日,阿里云正式發布Qwen3系列的8款開源混合推理模型。摩爾線程團隊在模型發布當天,率先完成了Qwen3全系列模型在全功能GPU上的高效支持。這一成果充分展現了MUSA架構及全功能GPU在生
    的頭像 發表于 05-07 15:24 ?213次閱讀

    寒武紀率先支持Qwen3全系列模型

    近日,阿里Qwen團隊一口氣上新8大模型,Qwen3正式發布并全部開源。
    的頭像 發表于 05-07 15:51 ?163次閱讀

    后摩智能NPU適配通義千問Qwen3系列模型

    近日,阿里云重磅推出Qwen3 系列開源混合推理模型。用時不到1天,后摩智能自研NPU迅速實現Qwen3 系列模型(Qwen3 0.6B-1
    的頭像 發表于 05-07 16:46 ?221次閱讀

    MediaTek天璣9400率先完成阿里Qwen3模型部署

    通義大模型團隊在天璣 9400 旗艦移動平臺上率先完成 Qwen3(千問 3)的端側部署。未來,搭載天璣 9400 移動平臺的設備可充分發揮端側 AI 性能潛力,運行千問
    的頭像 發表于 05-08 10:11 ?233次閱讀

    NVIDIA RTX 5880 Ada與Qwen3系列模型實測報告

    近日,阿里巴巴通義千問團隊正式推出新一代開源大語言模型——Qwen3 系列,該系列包含 6 款 Dense 稠密模型和 2 款 MoE 混合專家模型,參數規模覆蓋 0.6B 至 235B,構建了覆蓋
    的頭像 發表于 05-09 15:05 ?255次閱讀
    NVIDIA RTX 5880 Ada與<b class='flag-5'>Qwen3</b>系列模型實測報告