Views
No views yet
fp16 model and quantized models in the GGUF formats, including q2_k, q3_k_m, q4_0, q4_k_m, q5_0, q5_k_m, q6_k and q8_0.llama.cpp and install it following the official guide. We follow the latest version of llama.cpp.
In the following demonstration, we assume that you are running commands under the repository llama.cpp.huggingface-cli (pip install huggingface_hub) as shown below:huggingface-cli download Qwen/Qwen2-1.5B-Instruct-GGUF qwen2-1_5b-instruct-q5_k_m.gguf --local-dir . --local-dir-use-symlinks Falsellama-cli (the previous main) or llama-server (the previous server).
We recommend using the llama-server as it is simple and compatible with OpenAI API. For example:./llama-server -m qwen2-1_5b-instruct-q5_k_m.gguf -ngl 28 -fa-ngl 28 refers to offloading 28 layers to GPUs, and -fa refers to the use of flash attention.)1import openai
2
3client = openai.OpenAI(
4 base_url="http://localhost:8080/v1", # "http://<Your api-server IP>:port"
5 api_key = "sk-no-key-required"
6)
7
8completion = client.chat.completions.create(
9 model="qwen",
10 messages=[
11 {"role": "system", "content": "You are a helpful assistant."},
12 {"role": "user", "content": "tell me something about michael jordan"}
13 ]
14)
15print(completion.choices[0].message.content)llama-cli, pay attention to the removal of -cml for the ChatML template. Instead you should use --in-prefix and --in-suffix to tackle this problem.1./llama-cli -m qwen2-1_5b-instruct-q5_k_m.gguf \
2 -n 512 -co -i -if -f prompts/chat-with-qwen.txt \
3 --in-prefix "<|im_start|>user\n" \
4 --in-suffix "<|im_end|>\n<|im_start|>assistant\n" \
5 -ngl 28 -fallama.cpp with ./llama-perplexity (the previous ./perplexity).
In the following we report the PPL of GGUF models of different sizes and different quantization levels.| Size | fp16 | q8_0 | q6_k | q5_k_m | q5_0 | q4_k_m | q4_0 | q3_k_m | q2_k | iq1_m |
|---|---|---|---|---|---|---|---|---|---|---|
| 0.5B | 15.11 | 15.13 | 15.14 | 15.24 | 15.40 | 15.36 | 16.28 | 15.70 | 16.74 | - |
| 1.5B | 10.43 | 10.43 | 10.45 | 10.50 | 10.56 | 10.61 | 10.79 | 11.08 | 13.04 | - |
| 7B | 7.93 | 7.94 | 7.96 | 7.97 | 7.98 | 8.02 | 8.19 | 8.20 | 10.58 | - |
| 57B-A14B | 6.81 | 6.81 | 6.83 | 6.84 | 6.89 | 6.99 | 7.02 | 7.43 | - | - |
| 72B | 5.58 | 5.58 | 5.59 | 5.59 | 5.60 | 5.61 | 5.66 | 5.68 | 5.91 | 6.75 |
@article{qwen2,
title={Qwen2 Technical Report},
year={2024}
}