This is a new series that explains, in their own words, the new Models and tools that are avaiable in the world of Artificial Inellegence!
This is the first one, about the new Qwen relese. I will always start with the prompt that I used to generate the output of the model.
Prompt - Generate a how to article about setting up the latest qwen models and their uses.
Qwen3-235B-A22B9:59 pm
How to Set Up and Use the Latest Qwen Models
Qwen, developed by Alibaba Cloud, is a powerful series of large language models designed for various tasks, including natural language understanding, code generation, multi-modal reasoning, and more. The latest versions—such as Qwen3 , Qwen-Audio , Qwen-VL , and Qwen-Coder —offer state-of-the-art performance across different domains.
This article will guide you through setting up the latest Qwen models and provide practical use cases to help you get started with integrating them into your applications.
๐งฉ Prerequisites
Before you begin, ensure you have the following:
- A computer with Python 3.8 or higher installed.
- Access to Hugging Face (if using HF models) or ModelScope (Alibaba's model hub).
- An API key if using the hosted version on Alibaba Cloud (e.g., via DashScope).
- For local setups: GPU support is recommended for faster inference (CUDA-compatible NVIDIA GPU).
๐ฆ Step 1: Choose Your Deployment Method
You can deploy Qwen models in several ways:
Method Description Best For
Cloud API
|
Use Qwen via Alibaba's DashScope API
|
Quick integration, no setup needed
|
ModelScope
|
Download and run models locally using Alibaba’s framework
|
Linux/Mac users, AI developers
|
Hugging Face Transformers
|
Load Qwen via HuggingFace if available
|
General-purpose NLP tasks
|
Custom Training/Deployment
|
Fine-tune and deploy using training frameworks like DeepSpeed
|
Advanced users
|
We’ll walk through ModelScope and API-based methods since they are currently the most common deployment paths for the latest Qwen versions.
โ๏ธ Option 1: Using Qwen via Alibaba Cloud API (DashScope)
๐ Step 1.1: Get an API Key
Go to https://help.aliyun.com/en/dashscope/developer-reference/quick-start
Sign up or log in to your Alibaba Cloud account.
Create an API key under the API Keys section.
๐ Step 1.2: Install the SDK
pip install dashscope
๐งช Step 1.3: Make an API Call
Here's a basic example using Python:
import dashscope
from dashscope import Generation
dashscope.api_key = 'YOUR_API_KEY'
response = Generation.call(
model='qwen-max', # Or try qwen-plus, qwen-turbo
prompt='Write a short story about a robot learning to paint.'
)
print(response.output.text)
Qwen3-235B-A22B
9:59 PM
How to Set Up and Use the Latest Qwen Models
Qwen, developed by Alibaba Cloud, is a powerful series of large language models designed for various tasks, including natural language understanding, code generation, multi-modal reasoning, and more. The latest versions—such as Qwen3 , Qwen-Audio , Qwen-VL , and Qwen-Coder —offer state-of-the-art performance across different domains.
This article will guide you through setting up the latest Qwen models and provide practical use cases to help you get started with integrating them into your applications.
๐งฉ Prerequisites
Before you begin, ensure you have the following:
A computer with Python 3.8 or higher installed.
Access to Hugging Face (if using HF models) or ModelScope (Alibaba's model hub).
An API key if using the hosted version on Alibaba Cloud (e.g., via DashScope).
For local setups: GPU support is recommended for faster inference (CUDA-compatible NVIDIA GPU).
๐ฆ Step 1: Choose Your Deployment Method
You can deploy Qwen models in several ways:
DEPLOYMENT METHOD
DESCRIPTION
BEST FOR
Cloud API
Use Qwen via Alibaba's DashScope API
Quick integration, no setup needed
ModelScope
Download and run models locally using Alibaba’s framework
Linux/Mac users, AI developers
Hugging Face Transformers
Load Qwen via HuggingFace if available
General-purpose NLP tasks
Custom Training/Deployment
Fine-tune and deploy using training frameworks like DeepSpeed
Advanced users
We’ll walk through ModelScope and API-based methods since they are currently the most common deployment paths for the latest Qwen versions.
โ๏ธ Option 1: Using Qwen via Alibaba Cloud API (DashScope)
๐ Step 1.1: Get an API Key
Go to https://help.aliyun.com/en/dashscope/developer-reference/quick-start
Sign up or log in to your Alibaba Cloud account.
Create an API key under the API Keys section.
๐ Step 1.2: Install the SDK
bash
1
pip install dashscope
๐งช Step 1.3: Make an API Call
Here's a basic example using Python:
python
import dashscope
from dashscope import Generation
dashscope.api_key = 'YOUR_API_KEY'
response = Generation.call(
model='qwen-max', # Or try qwen-plus, qwen-turbo
prompt='Write a short story about a robot learning to paint.'
)
print(response.output.text)
โ
Models Available :
qwen-turbo – Fast and cost-effective for simple tasks.
qwen-plus – Balanced performance for most general tasks.
qwen-max – Most capable for complex reasoning.
qwen-coder – Specialized for code generation.
qwen-audio – Audio transcription & understanding.
qwen-vl – Multi-modal tasks (image + text).
๐ฅ๏ธ Option 2: Running Qwen Locally Using ModelScope
๐ฅ Step 2.1: Install ModelScope
pip install modelscope
๐ Step 2.2: Download a Qwen Model
Example for Qwen3:
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
# Download and load the model
model_id = 'qwen/Qwen3-8B' # Replace with desired model version
pt_pipeline = pipeline(task=Tasks.text_generation, model=model_id, model_revision='v1.0.0')
)
๐ You can find all available models at https://modelscope.cn/models
๐งช Step 2.3: Run Inference
input_text = "Explain quantum computing in simple terms."
result = pt_pipeline(input_text)
print(result['text']) # Outputs the generated response
๐ค Supported Models and Their Uses
Qwen3
|
Language Model
|
Chatbots, content generation, summarization
|
Qwen-Coder
|
Code Generation
|
Writing code, debugging, documentation
|
Qwen-Audio
|
Audio Understanding
|
Transcription, voice commands, audio QA
|
Qwen-VL
|
Vision-Language
|
Image captioning, visual question answering, doc analysis
|
Qwen-Max
|
Large Language Model
|
Complex reasoning, planning, agent workflows
|
๐ฏ Example: Using Qwen-VL for Image Captioning
python
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
vl_pipeline = pipeline(task=Tasks.image_captioning, model='qwen/Qwen-VL')
result = vl_pipeline('path/to/image.jpg')
print(result['caption'])
โ๏ธ Tips for Optimization and Customization
- Quantization : Reduce model size using 4-bit or 8-bit quantization for faster inference on lower-end hardware.
- Fine-Tuning : Use LoRA or full fine-tuning to adapt Qwen models to domain-specific tasks.
- Batching : Improve throughput by batching multiple prompts together during inference.
- Caching : Cache frequent responses to reduce latency and cost (especially with API-based usage).
๐ก๏ธ Security and Privacy Considerations
- When using cloud APIs, ensure sensitive data complies with privacy policies.
- For local deployments, secure your infrastructure and protect model weights from unauthorized access.
- Always sanitize user inputs to prevent prompt injection attacks.
๐ง Conclusion
Setting up the latest Qwen models opens up a wide range of possibilities—from building intelligent agents and code assistants to handling multi-modal data in creative ways. Whether you're using the hosted API via DashScope or running Qwen locally with ModelScope, these models are flexible enough to suit both beginners and advanced developers.
With this guide, you should now be able to integrate Qwen into your tools, services, or research projects effectively.
Notes from Rod
The video that I watched on YouTube was from Mattew Berman - https://www.youtube.com/watch?v=MYINFYKyfc4, his videos are always very good!