当前位置: 首页 > news >正文

Qwen3快速部署 Qwen3-0.6B、Qwen3-8B、Qwen3-14B,Think Deeper

文章目录

  • 0 Qwen3
  • 1 平台与环境安装
  • 1 模型下载
  • 2 模型测试

0 Qwen3

今天,通义千问Qwen团队正式开源推出 Qwen3,这是 Qwen 系列大型语言模型的最新成员。最新的Qwen3系列模型具备双模推理能力(深入思考/快速响应)、支持119种语言及方言,并强化了Agent功能与代码执行能力,全面满足复杂问题处理与全球化应用需求。

Github: https://github.com/QwenLM/Qwen3

Blog:https://qwenlm.github.io/zh/blog/qwen3/

模型合集:https://www.modelscope.cn/collections/Qwen3-9743180bdc6b48
在这里插入图片描述

b站视频:https://www.bilibili.com/video/BV1spG1zEEYR

1 平台与环境安装

使用GPU平台: https://www.autodl.com/home

在这里插入图片描述
PyTorch / 2.3.0 / 3.12(ubuntu22.04) / 12.1

安装transformers、accelerate

source /etc/network_turbopip install transformerspip install accelerate

1 模型下载

Qwen3 模型广场:https://bailian.console.aliyun.com/?tab=model#/model-market
在这里插入图片描述
通过魔塔社区下载模型:https://www.modelscope.cn/collections/Qwen3-9743180bdc6b48
在这里插入图片描述

选择一个模型Qwen3-0.6B:https://www.modelscope.cn/models/Qwen/Qwen3-0.6B/files
在这里插入图片描述

使用SDK下载下载:

开始前安装

source /etc/network_turbopip install modelscope
# source /etc/network_turbo
from modelscope import snapshot_download# 指定模型的下载路径
cache_dir = '/root/autodl-tmp'
# 调用 snapshot_download 函数下载模型
model_dir = snapshot_download('Qwen/Qwen3-0.6B', cache_dir=cache_dir)
# model_dir = snapshot_download('Qwen/Qwen3-8B', cache_dir=cache_dir)
# model_dir = snapshot_download('Qwen/Qwen3-14B', cache_dir=cache_dir)print(f"模型已下载到: {model_dir}")

或者:

modelscope download --model Qwen/Qwen3-0.6Bmv /root/.cache/modelscope/hub/models/Qwen/ /root/autodl-tmp/Qwen

2 模型测试

from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "Qwen/Qwen3-0.6B"
# model_name = "Qwen/Qwen3-8B"
# model_name = "Qwen/Qwen3-14B"# load the tokenizer and the model
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name,torch_dtype="auto",device_map="auto"
)# prepare the model input
prompt = "Give me a short introduction to large language models."
messages = [{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(messages,tokenize=False,add_generation_prompt=True,enable_thinking=True # Switches between thinking and non-thinking modes. Default is True.
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)# conduct text completion
generated_ids = model.generate(**model_inputs,max_new_tokens=32768
)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist() # the result will begin with thinking content in <think></think> tags, followed by the actual response
print(tokenizer.decode(output_ids, skip_special_tokens=True))

enable_thinking=True的结果
在这里插入图片描述
enable_thinking=False的结果
在这里插入图片描述

相关文章:

  • 制作JDK17 arm64基础镜像,解决字体安装问题
  • Fiddler抓取APP端,HTTPS报错全解析及解决方案(一篇解决常见问题)
  • 混淆矩阵(Confusion Matrix);归一化混淆矩阵(Confusion Matrix Normalized)
  • 《AI大模型应知应会100篇》【精华】第40篇:长文本处理技巧:克服大模型的上下文长度限制
  • 制作一款打飞机游戏33:碰撞体编辑
  • 推荐系统实验指标置信度:p值核心原理与工程应用指南
  • 李录谈卖出股票的时机:价值投资的动态决策框架
  • centos6.7安装完python3 找不到python3命令
  • DES与AES算法深度解析:原理、流程与实现细节
  • 【Yolo精读+实践+魔改系列】Yolov2论文超详细精讲(翻译+笔记)
  • 深度学习·经典模型·SwinTransformer
  • C语言教程(二十三):C 语言强制类型转换详解
  • C++核心编程 1.2 程序运行后
  • 【阿里云大模型高级工程师ACP习题集】2.7 通过微调增强模型能力 (上篇)(⭐️⭐️⭐️ 重点章节!!!)
  • 什么是缓冲区溢出?NGINX是如何防止缓冲区溢出攻击的?
  • LangChain4j +DeepSeek大模型应用开发——5 持久化聊天记忆 Persistence
  • Linux 命名管道+日志
  • 微信小程序开发,购物商城实现
  • 阿里通义Qwen3:双引擎混合推理,119语言破局全球AI竞赛
  • Golang 并发编程
  • 结婚这件事,年轻人到底怎么想的?
  • 初步结果显示加拿大自由党赢得大选,外交部回应
  • 黄晓丹:用“诗心”找到生存的意义
  • 普京发表声明感谢协助俄军收复库尔斯克州的朝鲜军人
  • 习近平:在庆祝中华全国总工会成立100周年暨全国劳动模范和先进工作者表彰大会上的讲话
  • 国家发改委:建立实施育儿补贴制度