GITHUB HUGGING FACE MODELSCOPE DEMO DISCORD

Introduction

In recent months, our focus has been on developing a “good” model while optimizing the developer experience. As we progress towards Qwen1.5, the next iteration in our Qwen series, this update arrives just before the Chinese New Year.

With Qwen1.5, we are open-sourcing base and chat models across six sizes: 0.5B, 1.8B, 4B, 7B, 14B, 32B, 72B, and 110B, and also an MoE model (see blog for more information). In line with tradition, we’re also providing quantized models, including Int4 and Int8 GPTQ models, as well as AWQ and GGUF quantized models. To enhance the developer experience, we’ve merged Qwen1.5’s code into Hugging Face transformers, making it accessible with transformers>=4.37.0 without needing trust_remote_code.

We’ve collaborated with frameworks like vLLM, SGLang for deployment, AutoAWQ, AutoGPTQ for quantization, Axolotl, LLaMA-Factory for finetuning, and llama.cpp for local LLM inference, all of which now support Qwen1.5. The Qwen1.5 series is available on platforms such as Ollama and LMStudio. Additionally, API services are offered not only on DashScope but also on together.ai, with global accessibility. Visit here to get started, and we recommend trying out Qwen1.5-72B-chat.

This release brings substantial improvements to the alignment of chat models with human preferences and enhanced multilingual capabilities. All models now uniformly support a context length of up to 32768 tokens. There have also been minor improvements in the quality of base language models that may benefit your finetuning endeavors. This step represents a small stride toward our objective of creating a truly “good” model.

Performance

To provide a better understanding of the performance of Qwen1.5, we have conducted a comprehensive evaluation of both base and chat models on different capabilities, including basic capabilities such as language understanding, coding, reasoning, multilingual capabilities, human preference, agent, retrieval-augmented generation (RAG), etc.

Basic Capabilities

To assess the basic capabilities of language models, we have conducted evaluations on traditional benchmarks, including MMLU (5-shot), C-Eval, Humaneval, GS8K, BBH, etc.

ModelMMLUC-EvalGSM8KMATHHumanEvalMBPPBBHCMMLU
GPT-486.469.992.045.867.061.886.771.0
Llama2-7B46.832.516.73.312.820.838.231.8
Llama2-13B55.041.429.65.018.930.345.638.4
Llama2-34B62.6-42.26.222.633.044.1-
Llama2-70B69.850.154.410.623.737.758.453.6
Mistral-7B64.147.447.511.327.438.656.744.7
Mixtral-8x7B70.6-74.428.440.260.7--
Qwen1.5-7B61.074.162.520.336.037.440.273.1
Qwen1.5-14B67.678.770.129.237.844.053.777.6
Qwen1.5-32B73.483.577.436.137.249.466.882.3
Qwen1.5-72B77.584.179.534.141.553.465.583.5

At every model size, Qwen1.5 demonstrates strong performance across the diverse evaluation benchmarks. In particular, Qwen1.5-72B outperforms Llama2-70B across all benchmarks, showcasing its exceptional capabilities in language understanding, reasoning, and math.

In light of the recent surge in interest for small language models, we have compared Qwen1.5 with sizes smaller than 7 billion parameters, against the most outstanding small-scale models within the community. The results are shown below:

ModelNon-Emb ParamsMMLUC-EvalGSM8KMATHHumanEvalMBPPBBHCMMLU
Tinyllama-1.1B1.1B24.325.02.30.76.719.928.824.0
Gemini-Nano-3B---22.8--27.242.4-
StableLM-Zephyr-3B2.7B45.930.352.512.535.431.937.730.9
Phi-22.5B52.723.457.23.547.655.043.424.2
MiniCPM-2B2.4B53.551.153.810.250.047.336.951.1
Gemma-2B2.0B42.3-17.711.822.029.235.2-
Qwen1.5-0.5B0.3B39.250.522.03.112.26.818.346.6
Qwen1.5-1.8B1.2B46.859.738.410.120.118.024.257.8
Qwen1.5-4B3.1B56.167.657.010.025.629.232.566.7
Qwen1.5-MoE-A2.7B2.0B62.579.261.521.934.236.639.179.2

We can confidently assert that Qwen1.5 base models under 7 billion parameters are highly competitive with the leading small-scale models in the community. In the future, we will continue to improve the quality of small models and exploring methods for effectively transferring the advanced capabilities inherent in larger models into the smaller ones.

Aligning with Human Preference

Alignment aims to enhance instruction-following capabilities of LLMs and help provide responses that are closely aligned with human preferences. Recognizing the significance of integrating human preferences into the learning process, we effectively employed techniques such as Direct Policy Optimization (DPO) and Proximal Policy Optimization (PPO) in aligning the latest Qwen series.

However, assessing the quality of such chat models poses a significant challenge. Admittedly, while comprehensive human evaluation is the optimal approach, it faces significant challenges pertaining to scalability and reproducibility. Therefore, we initially evaluate our models on two widely-used benchmarks, utilizing advanced LLMs as judges: MT-Bench and Alpaca-Eval. The results are presented below:

We notice there are non-negligible variance in the scores on MT-Bench. So we have three runs with different seeds in our results and we report the average score with standard deviation.

ModelsMT-BenchAlpacaEval 2.0
Avg. ScoreWin RateLength
Qwen1.5-72B-Chat8.610.04 (8.67/8.61/8.56)27.181.301600
Qwen1.5-14B-Chat7.910.11 (7.99/7.99/7.77)19.71.121608
Qwen1.5-7B-Chat7.600.05 (7.58/7.55/7.66)13.201.431606

Despite still significantly trailing behind GPT-4-Turbo, the largest open-source Qwen1.5 model, Qwen1.5-72B-Chat, exhibits superior performance, surpassing Claude-2.1, GPT-3.5-Turbo-0613, Mixtral-8x7b-instruct, and TULU 2 DPO 70B, being on par with Mistral Medium, on both MT-Bench and Alpaca-Eval v2.

Furthermore, although the scoring of LLM Judges may seemingly correlate with the lengths of responses, our observations indicate that our models do not generate lengthy responses to manipulate the bias of LLM judges. The average length of Qwen1.5-Chat on AlpacaEval 2.0 is only 1618, which aligns with the length of GPT-4 and is shorter than that of GPT-4-Turbo. Additionally, our experiments with our web service and app also reveal that users prefer the majority of responses from the new chat models.

Multilingual Understanding of Base Models

We have carefully selected a diverse set of 12 languages from Europe, East Asia, and Southeast Asia to thoroughly evaluate the multilingual capabilities of our foundational model. In order to accomplish this, we have curated test sets from the community’s open-source repositories, covering four distinct dimensions: Exams, Understanding, Translation, and Math. The table below provides detailed information about each test set, including evaluation settings, metrics, and the languages they encompass:

DatasetCategoryMethod/MetricLanguages
MMLU-multiExams5-shot/Accar, es, fr, pt, de, it, ru, ja, ko, id
M3ExamsExams5-shot/Accpt, it, vi, th
BELEBELEUnderstanding5-shot/Accar, es, fr, pt, de, it, ru, ja, ko, vi, th, id
XWinogradUnderstanding5-shot/Accfr, pt, ru, ja
XCOPAUnderstanding5-shot/Accvi, id, th
PAWS-XUnderstanding5-shot/Acces, fr, de, ja, ko
XStoryClozeUnderstanding0-shot/Accar, es, ru, id
Flores(zh/en↔xx)Translation5-shot/BLEUar, es, fr, pt, de, it, ru, ja, ko, vi, th, id
MGSMMath8-shot/Acces, fr, ru, de, ja, th

The detailed results are demonstrated below:

ModelsExamsUnderstandingMathTranslation
GPT-3.552.2471.8432.8031.85
GPT-471.6483.8280.1334.37
Llama2-7B34.0350.139.4022.19
Llama2-13B39.5557.2616.8025.89
Llama2-70B55.8873.1940.2031.56
Mistral-7B47.1263.3026.3323.33
Mixtral-8x7B56.0870.7045.0029.78
Qwen1.5-0.5B26.9844.083.139.17
Qwen1.5-1.8B33.5748.376.4716.19
Qwen1.5-4B41.4359.7621.3323.34
Qwen1.5-MoE-A2.7B44.5461.0830.2027.35
Qwen1.5-7B47.7067.6337.2728.36
Qwen1.5-14B55.7274.1049.9331.69
Qwen1.5-72B66.3578.1661.6735.57

The base models of Qwen1.5 showcase impressive multilingual capabilities, as demonstrated by its performance across a diverse set of 12 languages. In evaluations covering various dimensions such as exams, understanding, translation, and math, Qwen1.5 consistently delivers strong results. From languages like Arabic, Spanish, and French to Japanese, Korean, and Thai, Qwen1.5 demonstrates its ability to comprehend and generate high-quality content across different linguistic contexts. We compared Qwen1.5-72B-Chat with GPT-3.5, and the results are shown below:

These results demonstrate the strong multilingual capabilities of Qwen1.5 chat models, which can serve downstream applications, such as translation, language understanding, and multilingual chat. Also, we believe that the improvements in multilingual capabilities can also level up the general capabilities.

Support of Long Context

With the increasing demand for long-context understanding, we have expanded the capability of all models to support contexts up to 32K tokens. We have evaluated the performance of Qwen1.5 models on the L-Eval benchmark, which measures the ability of models to generate responses based on long context. The results are shown below:

ModelsCourseraGSMQuALITYTOEFLSFictionAvg.
GPT3.5-turbo-16k63.5184.0061.3878.4364.8470.43
Claude1.3-100k60.0388.0073.7683.6472.6575.62
GPT4-32k75.5896.0082.1784.3874.9982.62
Qwen-72B-Chat58.1376.0077.2286.2469.5373.42
Qwen1.5-0.5B-Chat30.816.0034.1640.5249.2232.14
Qwen1.5-1.8B-Chat39.2437.0042.0855.7644.5343.72
Qwen1.5-4B-Chat54.9447.0057.9269.1556.2557.05
Qwen1.5-7B-Chat59.7460.0064.3679.1862.5065.16
Qwen1.5-14B-Chat69.0479.0074.7583.6475.7876.44
Qwen1.5-72B-Chat71.9582.0077.7285.5073.4478.12

In terms of the performance, even a small model like Qwen1.5-7B-Chat demonstrates competitive performance against GPT-3.5 on 4 out of 5 tasks. Our best model, Qwen1.5-72B-Chat, significantly outperforms GPT3.5-turbo-16k and only slightly falls behind GPT4-32k. These results highlight our outstanding performance within 32K tokens, yet they do not imply that our models are limited to supporting only 32K tokens. You can modify max_position_embedding and sliding_window in config.json to a larger value to see if the model performance is still satisfactory for your tasks.

Capabilities to Connect with External Systems

Large language models (LLMs) are popular in part due to their ability to integrate external knowledge and tools. Retrieval-Augmented Generation (RAG) has gained traction as it mitigates common LLM issues like hallucination, real-time data shortage, and private information handling. Additionally, strong LLMs typically excel at using APIs and tools via function calling, making them ideal for serving as AI agents.

We first assess the performance of Qwen1.5-Chat on RGB, an RAG benchmark for which we have not performed any specific optimization:

RGB English Benchmark for Retrieval-Augmented Generation
ModelsNoise 0.8 (Acc.↑)Rejection 1.0 (Acc.↑)Integration 0.4 (Acc.↑)Counterfactual (Acc.↑)
GPT4-Turbo85.6747.3360.0090.00
GPT3.5-Turbo74.3327.6747.0021.00
Llama2-70B-Chat82.0031.0056.0015.00
Mistral-7B-Instruct-v0.282.0031.0056.0015.00
Mixtral-8x7B-Instruct-v0.182.6737.0067.008.00
Qwen1.5-7B-Chat77.6725.0052.009.00
Qwen1.5-14B-Chat80.6724.0060.008.00
Qwen1.5-72B-Chat81.6748.6761.0028.00
RGB Chinese Benchmark for Retrieval-Augmented Generation
ModelsNoise 0.8 (Acc.↑)Rejection 1.0 (Acc.↑)Integration 0.4 (Acc.↑)Counterfactual (Acc.↑)
GPT4-Turbo75.0038.6763.0090.00
GPT3.5-Turbo69.0013.0055.0025.00
Llama2-70B-Chat28.0017.0032.008.00
Mistral-7B-Instruct-v0.254.6728.6737.004.00
Mixtral-8x7B-Instruct-v0.127.334.0024.004.00
Qwen1.5-7B-Chat71.0010.3354.0020.00
Qwen1.5-14B-Chat75.0016.6755.0022.00
Qwen1.5-72B-Chat76.0051.0066.0044.00

We then assess Qwen’s capacity to function as a general-purpose agent by testing it on the T-Eval benchmark. None of the Qwen models have undergone any optimization tailored specifically for this benchmark:

Agent Performance on T-Eval English
ModelsOverallInstructPlanReasonRetrieveUnderstandReview
GPT4-Turbo86.496.387.865.388.985.894.5
Llama-2-70B-Chat58.5977.8063.7539.0751.3550.3469.20
Mistral-7B-Instruct-v0.246.6863.5760.8832.5917.5838.0867.35
Mixtral-8x7B-Instruct-v0.162.1542.3946.4860.3576.6973.7073.31
Qwen1.5-7B-Chat59.6771.1262.9537.6061.1753.7571.46
Qwen1.5-14B-Chat71.7786.1673.0949.5172.0766.0383.78
Qwen1.5-72B-Chat76.6980.9683.1256.8980.1776.6882.34
Agent Performance on T-Eval Chinese
ModelsOverallInstructPlanReasonRetrieveUnderstandReview
GPT4-Turbo85.997.687.068.489.286.886.0
Llama-2-70B-Chat51.1553.7856.6534.2748.2450.4963.45
Mistral-7B-Instruct-v0.246.2649.6461.8236.1720.2647.2562.42
Mixtral-8x7B-Instruct-v0.162.7726.3860.7962.0276.6077.7473.10
Qwen1.5-7B-Chat53.1560.5662.3142.0755.2855.7642.92
Qwen1.5-14B-Chat64.8584.2564.7754.6872.3568.8844.15
Qwen1.5-72B-Chat72.8897.5080.8358.1176.1471.9452.77

To test the capabilities of tool using, also known as function calling, we follow our previous practice and use our opensourced evaluation benchmark for assessing the models’ ability to appropriately select and use tools:

Tool-Use Benchmark
ModelsTool Selection (Acc.↑)Tool Input (Rouge-L↑)False Positive (Acc.↑)
GPT-498.095.376.1
GPT-3.574.580.719.4
Llama-2-70B-Chat88.5470.360.37
Mistral-7B-Instruct-v0.294.7982.816.34
Mixtral-8x7B-Instruct-v0.199.3194.4631.34
Qwen1.5-7B-Chat95.8389.4892.54
Qwen1.5-14B-Chat93.0688.7492.91
Qwen1.5-72B-Chat95.1491.1498.51

Finally, since the Python code interpreter has emerged as an increasingly powerful tool for advanced LLMs, we also evaluate our models’ capability in utilizing this tool on our previously open-sourced benchmark:

Code Interpreter Benchmark
ModelsAccuracy of Code Execution Results (%)Executable Rate of Code (%)
Math↑Visualization-Hard↑Visualization-Easy↑General↑
GPT-482.866.760.882.8
GPT-3.547.333.355.774.1
Mistral-7B-Instruct-v0.225.519.144.362.1
Mixtral-8x7B-Instruct-v0.147.833.354.460.3
Qwen1.5-7B-Chat54.035.736.765.5
Qwen1.5-14B-Chat62.146.448.170.6
Qwen1.5-72B-Chat73.152.350.687.9

Larger Qwen1.5-Chat models generally outperform smaller ones, nearing GPT-4’s tool-use performance. However, in code interpreter tasks like math problem-solving and visualization, even the largest Qwen1.5-72B-Chat model lags significantly behind GPT-4 due to coding capabilities. We aim in future versions to enhance the coding capabilities of all Qwen models during both pre-training and alignment.

Develop with Qwen1.5

The biggest difference in Qwen1.5 is the integration of Qwen1.5 to Hugging Face transformers. Since 4.37.0, you can use Qwen1.5 without our custom code, which means that you can load the model like the following:

from transformers import AutoModelForCausalLM
# This is what we previously used
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen-7B-Chat", device_map="auto", trust_remote_code=True)
# This is what you can use now
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen1.5-7B-Chat", device_map="auto")

The usage of Qwen1.5 for chat is different from the previous version. You can use the following code to chat with Qwen1.5:

from transformers import AutoModelForCausalLM, AutoTokenizer
device = "cuda" # the device to load the model onto

model = AutoModelForCausalLM.from_pretrained(
    "Qwen/Qwen1.5-14B-Chat-AWQ",
    device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen1.5-14B-Chat-AWQ")

prompt = "Give me a short introduction to large language model."
messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(device)

generated_ids = model.generate(
    model_inputs.input_ids,
    max_new_tokens=512
)
generated_ids = [
    output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]

response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]

For chat models, we no longer use a specific model.chat() method, but instead we use model.generate() with the chat template written in tokenizer_config.json so that we can use tokenizer.apply_chat_template() to generate the input, and we use eos_token to control when to stop the generation.

We also provide AWQ models and GPTQ models (including Int4 and Int8 models) for you to use Qwen1.5 in low-resource or deployment scenarios. As Huggingface transformers supports AWQ and GPTQ, you can use them in the same way above only with the corresponding model names.

Furthermore, we have integrated our code to popular inference frameworks so that you can deploy your model easily. Now vLLM>=0.3.0 and SGLang>=0.1.11 officially support Qwen1.5. Check their official github repos and docs to learn about the detailed usage. Here we demonstrate an example to show how to use vLLM to build an OpenAI-API compatible interface for our model:

python -m vllm.entrypoints.openai.api_server --model Qwen/Qwen1.5-7B-Chat
curl http://localhost:8000/v1/chat/completions \
    -H "Content-Type: application/json" \
    -d '{
    "model": "Qwen/Qwen1.5-7B-Chat",
    "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Tell me something about large language models."}
    ]
    }'

For users to run LLM locally, llama.cpp also provides support to Qwen1.5, and we officially provide quantized models in the GGUF format in our HF model hub. You can use the following code to run Qwen1.5 in llama.cpp:

./main -m qwen1.5-7b-chat-q2_k.gguf -n 512 --color -i -cml -f prompts/chat-with-qwen.txt

Besides, you can use the GGUF file with Ollama. Thanks to the support of Ollama, you can now directly use one line of command:

ollama run qwen

Or you can use the GGUF file to play with llamafile to run our models with a single file.

To make a web demo locally, we advise you to use Text generation web UI which is very easy to use.

For advanced developers that hope to train better or more suitable models for themselves, such as post-training, Qwen1.5 is supported by Hugging face trainer and Peft. Also, there are easy-to-use frameworks that support both supervised finetuning (SFT) and alignment (PPO, DPO, etc.). Now, both LLaMA-Factory and Axolotl have supported the training of Qwen1.5. We advise you to turn to their official github repos and docs for more advanced usages.

If you would like to use Qwen1.5 for downstream applications, such as RAG, tool use, agent, you can now build OpenAI-API compatible API or run local models for famous frameworks, e.g., LlamaIndex, LangChain, CrewAI.

Overall, as we care about your developing experience, we not only have tried our best to provide good models to the community but also have made efforts to make things easier for all of you. We hope that you can enjoy using Qwen1.5 and that it can help you with your tasks of either research or applications.

Conclusion

We are excited to introduce Qwen1.5, the next version of our Qwen series. In this release, we have opensourced both base and chat models of 6 sizes, including 0.5B, 1.8B, 4B, 7B, 14B, and 72B, and we have also provided quantized models. We have merged our code of Qwen1.5 to Hugging face transformers, and you can directly use it with transformers>=4.37.0 without trust_remote_code. Additionally, we have had frameworks, e.g., vLLM, SGLang, AutoGPTQ, etc., supported Qwen1.5. We believe from now on, using our models will be much easier. We believe that this release is though a small step towards model quality, but it is a big step towards developer experience. Hope you like it and enjoy using it. Join our Discord or WeChat to share your experience, comments, or whatever you like with us. We are looking forward to hearing from you.

Citation

@misc{qwen1.5,
    title = {Introducing Qwen1.5},
    url = {https://qwenlm.github.io/blog/qwen1.5/},
    author = {Qwen Team},
    month = {February},
    year = {2024}
}