Qwen2.5

不活跃
GitHub Python No License

简介

阿里巴巴 Qwen 团队开源的大语言模型系列,提供从 0.6B 到 110B 的密集和混合专家(MoE)模型,支持 100+ 语言、工具调用和推理能力,是性能最强的开源模型之一。

核心特性

  • 全尺寸覆盖 — 密集模型 0.6B-72B + MoE 模型 30B-A3B、235B-A22B,适应从边缘到超算的全场景
  • 深度思考切换 — 可在深度推理模式和高效对话模式间无缝切换
  • 百万 token 上下文 — 原生支持 256K token 上下文,扩展至 100 万 token
  • Agent 能力 — 内置工具调用和函数调用能力,支持复杂 Agent 任务
  • 多模态支持 — Qwen2.5-VL 系列支持图像、视频理解与 OCR 识别
  • 多语言 100+ — 覆盖中文、英文及 100+ 种语言和方言

适用场景

💡 企业知识库问答:结合 RAG 框架构建企业私有知识库问答系统
💡 代码生成与审查:基于 Qwen2.5-Coder 进行高精度代码生成和 Bug 修复
💡 多轮 Agent 对话:构建具备工具调用和复杂推理能力的 AI Agent
💡 多模态内容理解:处理图片、视频、PDF 等文档进行智能分析和提取

快速开始

# 安装 Transformers
pip install transformers torch

# 加载 Qwen2.5-7B-Instruct
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-7B-Instruct")
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-7B-Instruct", torch_dtype="auto", device_map="auto")

messages = [{"role": "user", "content": "你好,请介绍一下自己"}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
generated_ids = model.generate(**model_inputs, max_new_tokens=512)
print(tokenizer.decode(generated_ids[0][len(model_inputs.input_ids[0]):], skip_special_tokens=True))

相关项目