Models and labs

What is Qwen-7B, and why did Alibaba give its model away?

· By Robert Scales · 4 min read

Short answer

Qwen-7B is a 7-billion-parameter language model from Alibaba Cloud, released on August 3, 2023 together with a chat version, Qwen-7B-Chat, as downloadable weights that researchers and companies can use for free. It is the first time a big Chinese tech company has opened up its large language model this way, and it puts a strong, bilingual Chinese-English model in the same open space as Meta's Llama 2.

Yesterday, Thursday, August 3, Alibaba's cloud computing division published two language models that anyone can download: Qwen-7B and Qwen-7B-Chat. Both are small members of Tongyi Qianwen, the family of large language models Alibaba Cloud announced in April. "Qwen" is simply a short form of that name.

Reuters describes this as the first time a major Chinese technology company has made its large language model openly available. It comes two weeks after Meta did something similar with Llama 2, and it gives developers a new choice, especially anyone who works in Chinese.

What was released, and where

Alibaba Cloud, headquartered in Hangzhou, put the files on two model-sharing sites at once: ModelScope, its own platform, and Hugging Face, the most widely used international hub. A GitHub repository holds the instructions, example code and a link to a technical memo describing the training.

Two models came out together:

  • Qwen-7B is the base model. It was trained only to predict the next piece of text, so it is best at continuing whatever you give it.
  • Qwen-7B-Chat starts from the base model and adds alignment training, extra lessons that teach it to follow instructions and hold a conversation like an assistant.

Alibaba says larger versions of Tongyi Qianwen exist but are not being released, and it has not said how big its largest model is. According to Reuters, the company presents the two small models as a way for small and medium businesses to begin using AI.

How Qwen-7B works

Like ChatGPT and Llama 2, Qwen-7B is a Transformer, the network design behind nearly every recent language model. The "7B" is its size: about 7 billion parameters, the adjustable numbers the model tunes during training. For comparison, the largest Llama 2 model has 70 billion.

A few details from the project's documentation:

DetailQwen-7B
Training dataMore than 2.2 trillion tokens of web text, books and code, general and specialized
VocabularyOver 150,000 tokens, chosen to handle many languages efficiently
Context lengthAbout 8,000 tokens (the amount of text it can consider at once)
ToolsThe chat version is trained to call outside tools, such as APIs and databases

A token is a chunk of text, often a whole word or part of one. A larger vocabulary means common words in Chinese and other languages are more likely to be single tokens, which makes the model faster and cheaper to run in those languages.

The tool training is worth a closer look. Qwen-7B-Chat was taught with examples of choosing a tool, filling in its inputs and reading back the result. That makes it a candidate for agents, programs in which the model decides which action to take next, such as running a search or a calculation.

How it compares

The team reports results on common tests. These are the developers' own numbers, so treat them as claims to check, not final verdicts.

Test (what it measures)LLaMA 2-7BQwen-7B
MMLU (general knowledge, many subjects)45.356.7
GSM8K (grade-school math word problems)14.651.6
HumanEval (writing small Python programs)12.824.4

C-Eval, a Chinese-language exam benchmark, gives Qwen-7B 59.6. The team says its model also beats several models of around 13 billion parameters, almost twice its size.

There is a practical bonus for people with modest hardware. Through quantization, which stores each parameter with fewer bits, the model's memory needs drop from about 16 GB to about 7.4 GB in the 4-bit version, with some loss of accuracy (MMLU falls from 56.7 to 48.9).

Why it matters

Until now, the strongest freely downloadable models came mostly from American labs, with Meta's Llama family leading the way. Qwen-7B adds a well-documented option trained heavily on Chinese as well as English, from one of China's largest cloud companies.

The licence is generous but not unlimited. Researchers and developers may use the code and weights, and commercial use is allowed. But Reuters reports that any company whose services reach over 100 million monthly active users must ask Alibaba for a licence first, a similar idea to Llama 2's limit, which applies above 700 million users.

There is also a business logic. Analysts quoted by Reuters suggest open models could chip away at the lead of paid services from OpenAI and Google. Alibaba, which rents computing power, may well benefit if more companies build on a model that runs smoothly on its own cloud. Other Chinese tech giants, including Tencent and Huawei, are developing their own models, so many expect more releases like this one.

Try it: Write three short questions you care about, one in English, one about math and one asking for a tiny piece of code. Ask each to any chatbot you already use, then to Qwen-7B-Chat in an online demo. Note which answers are correct, not just which sound confident.

How can you try Qwen-7B yourself?

The simplest route is a web demo, linked from the project's GitHub page, where you type a question and read the answer with nothing to install. This is enough to get a feel for its style in English and Chinese.

If you are comfortable with Python, the repository gives a short example using the Hugging Face Transformers library: you load the tokenizer and the model by name, then call a chat function that keeps the conversation history. The full-precision model needs a graphics card with roughly 16 GB of memory; the 4-bit version fits in about half that.

Before building anything for customers, read the licence file in the repository, and keep the 100-million-user condition in mind if you work for a very large company. As with any model, test it on your own tasks, because benchmark scores rarely tell you how it will handle your particular questions.

Sources

  1. Qwen-7B (official repository README) — Alibaba Cloud (QwenLM on GitHub), August 3, 2023
  2. Alibaba rolls out open-sourced AI model to take on Meta's Llama 2 — Reuters, August 3, 2023

Get the free Guide to Artificial Intelligence

Sign up for the weekly newsletter and receive the free guide: what changed in AI this week, one lesson, one prompt to try. Unsubscribe in one click.

How we handle your address

Back to top

Display

Your choices are saved in this browser only. No data is sent.

Text size
100%
Colours
Reading
More settings
Accessibility statement