Bojun-Feng commited on
Commit
3de7458
·
verified ·
1 Parent(s): db56ed5

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +193 -0
README.md ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ pipeline_tag: text-generation
5
+ tags:
6
+ - instruct
7
+ - chat
8
+ license: apache-2.0
9
+ base_model: Qwen/Qwen2-0.5B-Instruct
10
+ ---
11
+ <!-- markdownlint-disable MD041 -->
12
+
13
+ <!-- header start -->
14
+ <!-- 200823 -->
15
+ <div style="width: auto; margin-left: auto; margin-right: auto">
16
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/64a523ba1ed90082dafde3d3/kJrkxofwOp-89uYFe0EBb.png" alt="LlamaFile" style="width: 50%; min-width: 400px; display: block; margin: auto;">
17
+
18
+ <!-- markdownlint-disable MD041 -->
19
+
20
+ <!-- header start -->
21
+ <!-- 200823 -->
22
+
23
+ I am not the original creator of llamafile, all credit of llamafile goes to Jartine:
24
+ <!-- README_llamafile.md-about-llamafile end -->
25
+ <!-- repositories-available start -->
26
+ <div style="width: auto; margin-left: auto; margin-right: auto">
27
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/FwAVVu7eJ4">Chat & support: jartine's Discord server</a></p>
28
+ </div>
29
+ <div style="text-align:center; margin-top: 0em; margin-bottom: 0em"><p style="margin-top: 0.25em; margin-bottom: 0em;">jartine's LLM work is generously supported by a grant from <a href="https://mozilla.org">mozilla</a></p></div>
30
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
31
+ <!-- header end -->
32
+
33
+ # Qwen2 0.5B Instruct GGUF - llamafile
34
+
35
+ ## Run LLMs locally with a single file - No installation required!
36
+
37
+ All you need is download a file and run it.
38
+
39
+ Our goal is to make open source large language models much more
40
+ accessible to both developers and end users. We're doing that by
41
+ combining [llama.cpp](https://github.com/ggerganov/llama.cpp) with [Cosmopolitan Libc](https://github.com/jart/cosmopolitan) into one
42
+ framework that collapses all the complexity of LLMs down to
43
+ a single-file executable (called a "llamafile") that runs
44
+ locally on most computers, with no installation.
45
+
46
+ ## How to Use (Modified from [Git README](https://github.com/Mozilla-Ocho/llamafile/tree/8f73d39cf3a767897b8ade6dda45e5744c62356a?tab=readme-ov-file#quickstart))
47
+
48
+ The easiest way to try it for yourself is to download our example llamafile.
49
+ With llamafile, all inference happens locally; no data ever leaves your computer.
50
+
51
+ 1. Download the llamafile.
52
+
53
+ 2. Open your computer's terminal.
54
+
55
+ 3. If you're using macOS, Linux, or BSD, you'll need to grant permission
56
+ for your computer to execute this new file. (You only need to do this
57
+ once.)
58
+
59
+ ```sh
60
+ chmod +x qwen2-0_5b-instruct-q8_0.llamafile
61
+ ```
62
+
63
+ 4. If you're on Windows, rename the file by adding ".exe" on the end.
64
+
65
+ 5. Run the llamafile. e.g.:
66
+
67
+ ```sh
68
+ ./qwen2-0_5b-instruct-q8_0.llamafile
69
+ ```
70
+
71
+ 6. Your browser should open automatically and display a chat interface.
72
+ (If it doesn't, just open your browser and point it at http://localhost:8080.)
73
+
74
+ 7. When you're done chatting, return to your terminal and hit
75
+ `Control-C` to shut down llamafile.
76
+
77
+
78
+ Please note that LlamaFile is still under active development. Some methods may be not be compatible with the most recent documents.
79
+
80
+ ## Settings for Qwen2 0.5B Instruct GGUF Llamafiles
81
+
82
+ - Model creator: [Qwen](https://huggingface.co/Qwen)
83
+ - Quantized GGUF files used: [Qwen/Qwen2-0.5B-Instruct-GGUF](https://huggingface.co/Qwen/Qwen2-0.5B-Instruct-GGUF/tree/198f08841147e5196a6a69bd0053690fb1fd3857)
84
+ - Commit message "Update README.md"
85
+ - Commit hash 198f08841147e5196a6a69bd0053690fb1fd3857
86
+ - LlamaFile version used: [Mozilla-Ocho/llamafile](https://github.com/Mozilla-Ocho/llamafile/tree/29b5f27172306da39a9c70fe25173da1b1564f82)
87
+ - Commit message "Merge pull request #687 from Xydane/main Add Support for DeepSeek-R1 models"
88
+ - Commit hash 29b5f27172306da39a9c70fe25173da1b1564f82
89
+ - `.args` content format (example):
90
+
91
+ ```
92
+ -m
93
+ qwen2-0_5b-instruct-q8_0.gguf
94
+ ...
95
+ ```
96
+
97
+ ## (Following is original model card for Qwen2 0.5B Instruct GGUF)
98
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
99
+
100
+
101
+ # Qwen2-0.5B-Instruct-GGUF
102
+
103
+ ## Introduction
104
+
105
+ Qwen2 is the new series of Qwen large language models. For Qwen2, we release a number of base language models and instruction-tuned language models ranging from 0.5 to 72 billion parameters, including a Mixture-of-Experts model (57B-A14B). This repo contains the instruction-tuned 0.5B Qwen2 model.
106
+
107
+ Compared with the state-of-the-art opensource language models, including the previous released Qwen1.5, Qwen2 has generally surpassed most opensource models and demonstrated competitiveness against proprietary models across a series of benchmarks targeting for language understanding, language generation, multilingual capability, coding, mathematics, reasoning, etc.
108
+
109
+ For more details, please refer to our [blog](https://qwenlm.github.io/blog/qwen2/), [GitHub](https://github.com/QwenLM/Qwen2), and [Documentation](https://qwen.readthedocs.io/en/latest/).
110
+
111
+ In this repo, we provide 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`.
112
+
113
+
114
+ ## Model Details
115
+ 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.
116
+
117
+ ## Training details
118
+ We pretrained the models with a large amount of data, and we post-trained the models with both supervised finetuning and direct preference optimization.
119
+
120
+
121
+ ## Requirements
122
+ 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.
123
+ In the following demonstration, we assume that you are running commands under the repository `llama.cpp`.
124
+
125
+
126
+ ## How to use
127
+ 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:
128
+ ```shell
129
+ huggingface-cli download Qwen/Qwen2-0.5B-Instruct-GGUF qwen2-0_5b-instruct-q5_k_m.gguf --local-dir . --local-dir-use-symlinks False
130
+ ```
131
+
132
+ To run Qwen2, you can use `llama-cli` (the previous `main`) or `llama-server` (the previous `server`).
133
+ We recommend using the `llama-server` as it is simple and compatible with OpenAI API. For example:
134
+
135
+ ```bash
136
+ ./llama-server -m qwen2-0_5b-instruct-q5_k_m.gguf -ngl 24 -fa
137
+ ```
138
+
139
+ (Note: `-ngl 24` refers to offloading 24 layers to GPUs, and `-fa` refers to the use of flash attention.)
140
+
141
+ Then it is easy to access the deployed service with OpenAI API:
142
+
143
+ ```python
144
+ import openai
145
+
146
+ client = openai.OpenAI(
147
+ base_url="http://localhost:8080/v1", # "http://<Your api-server IP>:port"
148
+ api_key = "sk-no-key-required"
149
+ )
150
+
151
+ completion = client.chat.completions.create(
152
+ model="qwen",
153
+ messages=[
154
+ {"role": "system", "content": "You are a helpful assistant."},
155
+ {"role": "user", "content": "tell me something about michael jordan"}
156
+ ]
157
+ )
158
+ print(completion.choices[0].message.content)
159
+ ```
160
+
161
+ 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.
162
+
163
+ ```bash
164
+ ./llama-cli -m qwen2-0_5b-instruct-q5_k_m.gguf \
165
+ -n 512 -co -i -if -f prompts/chat-with-qwen.txt \
166
+ --in-prefix "<|im_start|>user\n" \
167
+ --in-suffix "<|im_end|>\n<|im_start|>assistant\n" \
168
+ -ngl 24 -fa
169
+ ```
170
+
171
+ ## Evaluation
172
+
173
+ We implement perplexity evaluation using wikitext following the practice of `llama.cpp` with `./llama-perplexity` (the previous `./perplexity`).
174
+ In the following we report the PPL of GGUF models of different sizes and different quantization levels.
175
+
176
+ |Size | fp16 | q8_0 | q6_k | q5_k_m | q5_0 | q4_k_m | q4_0 | q3_k_m | q2_k | iq1_m |
177
+ |--------|---------|---------|---------|---------|---------|---------|---------|---------|---------|---------|
178
+ |0.5B | 15.11 | 15.13 | 15.14 | 15.24 | 15.40 | 15.36 | 16.28 | 15.70 | 16.74 | - |
179
+ |1.5B | 10.43 | 10.43 | 10.45 | 10.50 | 10.56 | 10.61 | 10.79 | 11.08 | 13.04 | - |
180
+ |7B | 7.93 | 7.94 | 7.96 | 7.97 | 7.98 | 8.02 | 8.19 | 8.20 | 10.58 | - |
181
+ |57B-A14B| 6.81 | 6.81 | 6.83 | 6.84 | 6.89 | 6.99 | 7.02 | 7.43 | - | - |
182
+ |72B | 5.58 | 5.58 | 5.59 | 5.59 | 5.60 | 5.61 | 5.66 | 5.68 | 5.91 | 6.75 |
183
+
184
+ ## Citation
185
+
186
+ If you find our work helpful, feel free to give us a cite.
187
+
188
+ ```
189
+ @article{qwen2,
190
+ title={Qwen2 Technical Report},
191
+ year={2024}
192
+ }
193
+ ```