阿里大模型:Qwen2.5

诸神缄默不语-个人CSDN博文目录

还没有上过手,等我上过手了会来补更多内容。

中文文档:https://qwen.readthedocs.io/zh-cn/latest/

Qwen现在最新出到2.5版。由于Qwen 2+和Qwen之间并不兼容,所以本文仅包括Qwen2.5的相关实操内容,对于Qwen的技术报告解读等相关内容会另写博文。

Qwen是类GPT的decoder-only架构,自回归模型,分词方式也是BPE。
提供 0.5B 、1.5B 、3B 、7B 、14B 、32B 和 72B 共7种参数规模的模型,并且有基模型和指令微调模型两种变体。
可以处理 32K 或 128K token 长的文本,其中 8K 长度可作为输出。(可以用YaRN进行扩展)
有纯文本、视觉、音频模型,有专门针对代码和数学进行优化的模型。

没开源的模型可以用API:https://www.alibabacloud.com/help/zh/model-studio/developer-reference/use-qwen-by-calling-api
或者从网页端访问:https://chat.qwenlm.ai/

已开源的模型可以本地部署,也可以架API,transformers格式和OpenAI API格式都支持,教程:
https://qwen.readthedocs.io/zh-cn/latest/getting_started/quickstart.html
transformers版详细教程:https://qwen.readthedocs.io/zh-cn/latest/inference/chat.html
Ollama:https://qwen.readthedocs.io/zh-cn/latest/run_locally/ollama.html
llama.cpp:https://qwen.readthedocs.io/zh-cn/latest/run_locally/llama.cpp.html
LM Studio
Web UI:https://qwen.readthedocs.io/zh-cn/latest/web_ui/text_generation_webui.html
vLLM:https://qwen.readthedocs.io/zh-cn/latest/deployment/vllm.html
TGI:https://qwen.readthedocs.io/zh-cn/latest/deployment/tgi.html
SkiPilot:https://qwen.readthedocs.io/zh-cn/latest/deployment/skypilot.html
OpenLLM:https://qwen.readthedocs.io/zh-cn/latest/deployment/openllm.html(这个还会显示required GPU RAM 和支持的操作系统,看起来挺智能的)
(方便使用RAG)LlamaIndex:https://qwen.readthedocs.io/zh-cn/latest/framework/LlamaIndex.html
(方便使用RAG)Langchain:https://qwen.readthedocs.io/zh-cn/latest/framework/Langchain.html
具体的我自己还没试,等试了再写。

官方文档还给出了推荐量化方式,略。

用LLaMA Factory进行SFT:https://qwen.readthedocs.io/zh-cn/latest/training/SFT/llama_factory.html

函数调用:https://qwen.readthedocs.io/zh-cn/latest/framework/function_call.html

官方智能体开发库:https://qwen.readthedocs.io/zh-cn/latest/framework/qwen_agent.html

### 如何调用阿里Qwen 2.5-VL API 对于希望利用阿里Qwen 2.5-VL模型执行特定任务的应用开发者而言,了解API的调用方式至关重要。通过HTTP请求的方式可以轻松实现这一目标。 #### 准备工作 确保已获取访密钥(AccessKey ID 和 AccessKey Secret),这是向阿里云发送任何请求所必需的身份验证凭证[^1]。 #### 构建 HTTP 请求 构建针对Qwen 2.5-VL API的有效HTTP POST请求时,需指定如下参数: - **URL**: `https://api.qwen.damo.ac.cn/v1/completions` 是用于提交文本生成请求的目标端点。 - **Headers**: - `Content-Type`: 设置为`application/json`以表明正文采用JSON格式。 - `Authorization`: 使用Bearer Token形式提供身份验证信息,即`Bearer {your_access_token}`。 - **Body (Payload)**: JSON对象内含提示词(prompt),以及可选配置项如最大长度(max_tokens)等。 ```json { "prompt": "你好世界", "max_tokens": 64, "temperature": 0.7, "top_p": 0.9 } ``` 此结构化数据作为POST请求体的一部分被发送给服务器处理并返回响应结果[^2]。 #### Python 示例代码 下面给出一段Python脚本示范如何发起上述描述中的API调用过程: ```python import requests import json url = 'https://api.qwen.damo.ac.cn/v1/completions' headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_ACCESS_TOKEN' # 替换成自己的token } data = { "prompt": "编写一首关于秋天的小诗。", "max_tokens": 100, # 输出的最大字符数 "temperature": 0.8, # 控制随机性的温度值 "top_p": 0.9 # 核采样概率阈值 } response = requests.post(url=url, headers=headers, data=json.dumps(data)) print(response.json()) ``` 该片段展示了完整的流程——从定义必要的头部信息到组装实际要传递的数据包直至最终解析来自远程服务的回答内容[^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

诸神缄默不语

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值