Qwen3.5
在 Clore.ai 上运行阿里巴巴 Qwen3.5——最新的前沿模型(2026 年 2 月)
最后更新于
这有帮助吗?
这有帮助吗?
# 安装 Ollama
curl -fsSL https://ollama.com/install.sh | sh
# 9B — 在任何设备上运行(8GB 显存)
ollama run qwen3.5:9b
# 35B 量化版 — 需要 RTX 4090(24GB)
ollama run qwen3.5:35b
# 作为 API 服务器
ollama serve &
curl http://localhost:11434/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.5:35b",
"messages": [{"role": "user", "content": "Solve this: if f(x) = x^3 - 3x + 1, find all real roots"}]
}'pip install vllm
# 单 GPU 上的 35B
vllm serve Qwen/Qwen3.5-35B-Instruct \
--max-model-len 32768 \
--gpu-memory-utilization 0.90
# 具有长上下文的 9B
vllm serve Qwen/Qwen3.5-9B-Instruct \
--max-model-len 65536
# 在多 GPU 集群上的 397B
vllm serve Qwen/Qwen3.5-397B-A45B-Instruct \
--tensor-parallel-size 8 \
--max-model-len 32768import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "Qwen/Qwen3.5-35B-Instruct"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.bfloat16,
device_map="auto",
load_in_4bit=True # 在 24GB 上适配 35B
)
messages = [
{"role": "system", "content": "You are a helpful math tutor."},
{"role": "user", "content": "Prove that the square root of 2 is irrational."}
]
input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
output = model.generate(input_ids, max_new_tokens=2048, temperature=0.7, do_sample=True)
print(tokenizer.decode(output[0][input_ids.shape[-1]:], skip_special_tokens=True))import json
from openai import OpenAI
client = OpenAI(base_url="http://localhost:11434/v1", api_key="ollama")
tools = [{
"type": "function",
"function": {
"name": "get_gpu_price",
"description": "获取 Clore.ai 上某款 GPU 的当前租赁价格",
"parameters": {
"type": "object",
"properties": {
"gpu_model": {"type": "string", "description": "GPU 型号名称,例如 RTX 4090"}
},
"required": ["gpu_model"]
}
}
}]
response = client.chat.completions.create(
model="qwen3.5:35b",
messages=[{"role": "user", "content": "What's the cheapest GPU I can rent for running a 7B model?"}],
tools=tools,
tool_choice="auto"
)
# Qwen3.5 将使用适当参数调用 get_gpu_price
print(response.choices[0].message)