Bojun-Feng commited on
Commit
0338005
·
verified ·
1 Parent(s): 8374fc0

Upload README.md with huggingface_hub

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