G
GenAI Hub
🧠
🧠 LLMs & Chatbots

Qwen (Tongyi Qianwen)

by Alibaba Cloud

Qwen is Alibaba's open-weight large language model family — including Qwen2.5 and QwQ reasoning models — widely used by developers for multilingual reasoning, coding, and agentic applications.

llmopen-weightmultilingualreasoningalibabaapi

Quick Start

  1. Choose your access path — Use Alibaba Cloud DashScope API for hosted inference, or download model weights from Hugging Face / ModelScope for self-hosting.
  2. Install dependencies — For local use: pip install transformers accelerate. For API: pip install dashscope.
  3. Load or authenticate — Local: load via AutoModelForCausalLM.from_pretrained('Qwen/Qwen2.5-72B-Instruct'). API: set DASHSCOPE_API_KEY env var.
  4. Run inference — Construct a messages list and call the chat completions endpoint (DashScope) or use the transformers pipeline locally.
  5. Explore advanced models — Try QwQ-32B for chain-of-thought reasoning tasks or Qwen2.5-Coder for code generation workloads.
Full quickstart guide

How-To Guides

2
1. Install dependencies: pip install transformers accelerate torch. 2. In Python, import AutoModelForCausalLM and AutoTokenizer from transformers. 3. Load the model: model = AutoModelForCausalLM.from_pretrained('Qwen/Qwen2.5-7B-Instruct', torch_dtype='auto', device_map='auto'). 4. Load tokenizer: tokenizer = AutoTokenizer.from_pretrained('Qwen/Qwen2.5-7B-Instruct'). 5. Build the prompt using tokenizer.apply_chat_template with a messages list. 6. Run model.generate() and decode the output with tokenizer.decode(). 7. For GPU-constrained setups, use the 1.5B or 3B variants, or enable 4-bit quantisation with bitsandbytes.

Tool Info

Company
Alibaba Cloud
Category
🧠 LLMs & Chatbots
How-to Guides
2

Tags

llmopen-weightmultilingualreasoningalibabaapi