JustinLin610 commited on
Commit
d084ded
1 Parent(s): 166ad99

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +38 -8
README.md CHANGED
@@ -5,6 +5,7 @@ language:
5
  pipeline_tag: text-generation
6
  tags:
7
  - chat
 
8
  ---
9
 
10
  # Qwen2-1.5B-Instruct-GGUF
@@ -17,7 +18,7 @@ Compared with the state-of-the-art opensource language models, including the pre
17
 
18
  For more details, please refer to our [blog](https://qwenlm.github.io/blog/qwen2/) and [GitHub](https://github.com/QwenLM/Qwen2).
19
 
20
- In this repo, we provide `fp16` model and quantized models in the GGUF formats, including `q5_0`, `q5_k_m`, `q6_k` and `q8_0`.
21
 
22
  ## Model Details
23
  Qwen2 is a language model series including decoder language models of different model sizes. For each size, we release the base language model and the aligned chat model. It is based on the Transformer architecture with SwiGLU activation, attention QKV bias, group query attention, etc. Additionally, we have an improved tokenizer adaptive to multiple natural languages and codes.
@@ -25,22 +26,51 @@ Qwen2 is a language model series including decoder language models of different
25
  ## Training details
26
  We pretrained the models with a large amount of data, and we post-trained the models with both supervised finetuning and direct preference optimization.
27
 
28
-
29
  ## Requirements
30
- We advise you to clone [`llama.cpp`](https://github.com/ggerganov/llama.cpp) and install it following the official guide.
 
31
 
32
 
33
  ## How to use
34
  Cloning the repo may be inefficient, and thus you can manually download the GGUF file that you need or use `huggingface-cli` (`pip install huggingface_hub`) as shown below:
35
  ```shell
36
- huggingface-cli download Qwen/Qwen2-1.5B-Instruct-GGUF qwen2-1_5b-instruct-q8_0.gguf --local-dir . --local-dir-use-symlinks False
37
  ```
38
 
39
- We demonstrate how to use `llama.cpp` to run Qwen2:
40
- ```shell
41
- ./main -m qwen2-1_5b-instruct-q8_0.gguf -n 512 --color -i -cml -f prompts/chat-with-qwen.txt
 
 
42
  ```
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  ## Citation
45
 
46
  If you find our work helpful, feel free to give us a cite.
@@ -50,4 +80,4 @@ If you find our work helpful, feel free to give us a cite.
50
  title={Qwen2 Technical Report},
51
  year={2024}
52
  }
53
- ```
 
5
  pipeline_tag: text-generation
6
  tags:
7
  - chat
8
+ - instruct
9
  ---
10
 
11
  # Qwen2-1.5B-Instruct-GGUF
 
18
 
19
  For more details, please refer to our [blog](https://qwenlm.github.io/blog/qwen2/) and [GitHub](https://github.com/QwenLM/Qwen2).
20
 
21
+ In this repo, we provide `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`.
22
 
23
  ## Model Details
24
  Qwen2 is a language model series including decoder language models of different model sizes. For each size, we release the base language model and the aligned chat model. It is based on the Transformer architecture with SwiGLU activation, attention QKV bias, group query attention, etc. Additionally, we have an improved tokenizer adaptive to multiple natural languages and codes.
 
26
  ## Training details
27
  We pretrained the models with a large amount of data, and we post-trained the models with both supervised finetuning and direct preference optimization.
28
 
 
29
  ## Requirements
30
+ We advise you to clone [`llama.cpp`](https://github.com/ggerganov/llama.cpp) and install it following the official guide. We follow the latest version of llama.cpp.
31
+ In the following demonstration, we assume that you are running commands under the repository `llama.cpp`.
32
 
33
 
34
  ## How to use
35
  Cloning the repo may be inefficient, and thus you can manually download the GGUF file that you need or use `huggingface-cli` (`pip install huggingface_hub`) as shown below:
36
  ```shell
37
+ huggingface-cli download Qwen/Qwen2-1.5B-Instruct-GGUF qwen2-1.5b-instruct-q5_k_m.gguf --local-dir . --local-dir-use-symlinks False
38
  ```
39
 
40
+ To run Qwen2, you can use `llama-cli` (the previous `main`) or `llama-server` (the previous `server`).
41
+ We recommend using the `llama-server` as it is simple and compatible with OpenAI API. For example:
42
+
43
+ ```bash
44
+ ./llama-server -m qwen2-1.5b-instruct-q5_k_m.gguf
45
  ```
46
 
47
+ Then it is easy to access the deployed service with OpenAI API:
48
+
49
+ ```python
50
+ import openai
51
+
52
+ client = openai.OpenAI(
53
+ base_url="http://localhost:8080/v1", # "http://<Your api-server IP>:port"
54
+ api_key = "sk-no-key-required"
55
+ )
56
+
57
+ completion = client.chat.completions.create(
58
+ model="qwen",
59
+ messages=[
60
+ {"role": "system", "content": "You are a helpful assistant."},
61
+ {"role": "user", "content": "tell me something about michael jordan"}
62
+ ]
63
+ )
64
+ print(completion.choices[0].message.content)
65
+ ```
66
+
67
+ If you choose to use `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.
68
+
69
+ ```bash
70
+ ./llama-cli -m qwen2-1.5b-instruct-q5_k_m.gguf -n 512 -co -i -if -f prompts/chat-with-qwen.txt --in-prefix "<|im_start|>user\n" --in-suffix "<|im_end|>\n<|im_start|>assistant\n"
71
+ ```
72
+
73
+
74
  ## Citation
75
 
76
  If you find our work helpful, feel free to give us a cite.
 
80
  title={Qwen2 Technical Report},
81
  year={2024}
82
  }
83
+ ```