Skip to main content

Overview

ModelScope is an open-source platform for Model-as-a-Service (MaaS), providing flexible and cost-effective model services to AI developers. Qwen models are fully integrated with ModelScope, offering an alternative to Hugging Face for model hosting and inference.

Why ModelScope?

Network Optimization

Better download speeds in certain regions, especially Asia

Local Mirror

Alternative when Hugging Face is unavailable

MaaS Platform

Integrated model service infrastructure

Same API

Compatible interface with Transformers

Installation

Install ModelScope and required dependencies:

Direct ModelScope Usage

Use ModelScope’s API for loading and running Qwen models:
Note the model naming convention: ModelScope uses qwen/Qwen-7B-Chat while Hugging Face uses Qwen/Qwen-7B-Chat (capital Q).

Download and Use Locally

Download models from ModelScope and use them with Transformers:
1

Download Model

Use snapshot_download to fetch the model:
Available models:
  • qwen/Qwen-1_8B-Chat
  • qwen/Qwen-7B-Chat
  • qwen/Qwen-14B-Chat
  • qwen/Qwen-72B-Chat
2

Load with Transformers

Load the downloaded model using Transformers:
3

Run Inference

Use the model as normal:

Complete Example

Here’s a complete workflow downloading from ModelScope and using with Transformers:

Model Variants on ModelScope

All Qwen model variants are available on ModelScope:
Fine-tuned for conversation:
  • qwen/Qwen-1_8B-Chat
  • qwen/Qwen-7B-Chat
  • qwen/Qwen-14B-Chat
  • qwen/Qwen-72B-Chat

Precision Options

ModelScope supports the same precision options as Transformers:

Generation Configuration

Customize generation behavior with ModelScope’s GenerationConfig:

Caching and Resume

ModelScope supports resume download for interrupted transfers:

Comparing ModelScope and Hugging Face

Hybrid Approach

Download from ModelScope but load config from Hugging Face:

Troubleshooting

Try specifying a different mirror or check your network:
Ensure you’re using the correct naming convention:
  • ModelScope: qwen/Qwen-7B-Chat (lowercase q)
  • Hugging Face: Qwen/Qwen-7B-Chat (capital Q)
Always include trust_remote_code=True when loading Qwen models:

Next Steps

Batch Inference

Process multiple inputs efficiently

Streaming

Stream responses in real-time

Multi-GPU

Scale across multiple GPUs

Transformers Guide

Deep dive into Transformers usage