TheBloke commited on
Commit
b9006b3
1 Parent(s): 80c0fd3

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +365 -0
README.md ADDED
@@ -0,0 +1,365 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: YeungNLP/firefly-mixtral-8x7b
3
+ inference: false
4
+ language:
5
+ - en
6
+ license: apache-2.0
7
+ model_creator: YeungNLP
8
+ model_name: Firefly Mixtral 8X7B
9
+ model_type: mixtral
10
+ prompt_template: '{prompt}
11
+
12
+ '
13
+ quantized_by: TheBloke
14
+ ---
15
+ <!-- markdownlint-disable MD041 -->
16
+
17
+ <!-- header start -->
18
+ <!-- 200823 -->
19
+ <div style="width: auto; margin-left: auto; margin-right: auto">
20
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
21
+ </div>
22
+ <div style="display: flex; justify-content: space-between; width: 100%;">
23
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
24
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
25
+ </div>
26
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
27
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://www.patreon.com/TheBlokeAI">Want to contribute? TheBloke's Patreon page</a></p>
28
+ </div>
29
+ </div>
30
+ <div style="text-align:center; margin-top: 0em; margin-bottom: 0em"><p style="margin-top: 0.25em; margin-bottom: 0em;">TheBloke's LLM work is generously supported by a grant from <a href="https://a16z.com">andreessen horowitz (a16z)</a></p></div>
31
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
32
+ <!-- header end -->
33
+
34
+ # Firefly Mixtral 8X7B - GGUF
35
+ - Model creator: [YeungNLP](https://huggingface.co/YeungNLP)
36
+ - Original model: [Firefly Mixtral 8X7B](https://huggingface.co/YeungNLP/firefly-mixtral-8x7b)
37
+
38
+ <!-- description start -->
39
+ ## Description
40
+
41
+ This repo contains GGUF format model files for [YeungNLP's Firefly Mixtral 8X7B](https://huggingface.co/YeungNLP/firefly-mixtral-8x7b).
42
+
43
+ <!-- description end -->
44
+ <!-- README_GGUF.md-about-gguf start -->
45
+ ### About GGUF
46
+
47
+ GGUF is a new format introduced by the llama.cpp team on August 21st 2023. It is a replacement for GGML, which is no longer supported by llama.cpp.
48
+
49
+ ### Mixtral GGUF
50
+
51
+ Support for Mixtral was merged into Llama.cpp on December 13th.
52
+
53
+ These Mixtral GGUFs are known to work in:
54
+
55
+ * llama.cpp as of December 13th
56
+ * KoboldCpp 1.52 as later
57
+ * LM Studio 0.2.9 and later
58
+ * llama-cpp-python 0.2.23 and later
59
+
60
+ Other clients/libraries, not listed above, may not yet work.
61
+
62
+ <!-- README_GGUF.md-about-gguf end -->
63
+ <!-- repositories-available start -->
64
+ ## Repositories available
65
+
66
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/firefly-mixtral-8x7b-GPTQ)
67
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/firefly-mixtral-8x7b-GGUF)
68
+ * [YeungNLP's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/YeungNLP/firefly-mixtral-8x7b)
69
+ <!-- repositories-available end -->
70
+
71
+ <!-- prompt-template start -->
72
+ ## Prompt template: None
73
+
74
+ ```
75
+ {prompt}
76
+
77
+ ```
78
+
79
+ <!-- prompt-template end -->
80
+
81
+
82
+ <!-- compatibility_gguf start -->
83
+ ## Compatibility
84
+
85
+ These Mixtral GGUFs are compatible with llama.cpp from December 13th onwards. Other clients/libraries may not work yet.
86
+
87
+ ## Explanation of quantisation methods
88
+
89
+ <details>
90
+ <summary>Click to see details</summary>
91
+
92
+ The new methods available are:
93
+
94
+ * GGML_TYPE_Q2_K - "type-1" 2-bit quantization in super-blocks containing 16 blocks, each block having 16 weight. Block scales and mins are quantized with 4 bits. This ends up effectively using 2.5625 bits per weight (bpw)
95
+ * GGML_TYPE_Q3_K - "type-0" 3-bit quantization in super-blocks containing 16 blocks, each block having 16 weights. Scales are quantized with 6 bits. This end up using 3.4375 bpw.
96
+ * GGML_TYPE_Q4_K - "type-1" 4-bit quantization in super-blocks containing 8 blocks, each block having 32 weights. Scales and mins are quantized with 6 bits. This ends up using 4.5 bpw.
97
+ * GGML_TYPE_Q5_K - "type-1" 5-bit quantization. Same super-block structure as GGML_TYPE_Q4_K resulting in 5.5 bpw
98
+ * GGML_TYPE_Q6_K - "type-0" 6-bit quantization. Super-blocks with 16 blocks, each block having 16 weights. Scales are quantized with 8 bits. This ends up using 6.5625 bpw
99
+
100
+ Refer to the Provided Files table below to see what files use which methods, and how.
101
+ </details>
102
+ <!-- compatibility_gguf end -->
103
+
104
+ <!-- README_GGUF.md-provided-files start -->
105
+ ## Provided files
106
+
107
+ | Name | Quant method | Bits | Size | Max RAM required | Use case |
108
+ | ---- | ---- | ---- | ---- | ---- | ----- |
109
+ | [firefly-mixtral-8x7b.Q2_K.gguf](https://huggingface.co/TheBloke/firefly-mixtral-8x7b-GGUF/blob/main/firefly-mixtral-8x7b.Q2_K.gguf) | Q2_K | 2 | 15.64 GB| 18.14 GB | smallest, significant quality loss - not recommended for most purposes |
110
+ | [firefly-mixtral-8x7b.Q3_K_M.gguf](https://huggingface.co/TheBloke/firefly-mixtral-8x7b-GGUF/blob/main/firefly-mixtral-8x7b.Q3_K_M.gguf) | Q3_K_M | 3 | 20.36 GB| 22.86 GB | very small, high quality loss |
111
+ | [firefly-mixtral-8x7b.Q4_0.gguf](https://huggingface.co/TheBloke/firefly-mixtral-8x7b-GGUF/blob/main/firefly-mixtral-8x7b.Q4_0.gguf) | Q4_0 | 4 | 26.44 GB| 28.94 GB | legacy; small, very high quality loss - prefer using Q3_K_M |
112
+ | [firefly-mixtral-8x7b.Q4_K_M.gguf](https://huggingface.co/TheBloke/firefly-mixtral-8x7b-GGUF/blob/main/firefly-mixtral-8x7b.Q4_K_M.gguf) | Q4_K_M | 4 | 26.44 GB| 28.94 GB | medium, balanced quality - recommended |
113
+ | [firefly-mixtral-8x7b.Q5_0.gguf](https://huggingface.co/TheBloke/firefly-mixtral-8x7b-GGUF/blob/main/firefly-mixtral-8x7b.Q5_0.gguf) | Q5_0 | 5 | 32.23 GB| 34.73 GB | legacy; medium, balanced quality - prefer using Q4_K_M |
114
+ | [firefly-mixtral-8x7b.Q5_K_M.gguf](https://huggingface.co/TheBloke/firefly-mixtral-8x7b-GGUF/blob/main/firefly-mixtral-8x7b.Q5_K_M.gguf) | Q5_K_M | 5 | 32.23 GB| 34.73 GB | large, very low quality loss - recommended |
115
+ | [firefly-mixtral-8x7b.Q6_K.gguf](https://huggingface.co/TheBloke/firefly-mixtral-8x7b-GGUF/blob/main/firefly-mixtral-8x7b.Q6_K.gguf) | Q6_K | 6 | 38.38 GB| 40.88 GB | very large, extremely low quality loss |
116
+ | [firefly-mixtral-8x7b.Q8_0.gguf](https://huggingface.co/TheBloke/firefly-mixtral-8x7b-GGUF/blob/main/firefly-mixtral-8x7b.Q8_0.gguf) | Q8_0 | 8 | 49.63 GB| 52.13 GB | very large, extremely low quality loss - not recommended |
117
+
118
+ **Note**: the above RAM figures assume no GPU offloading. If layers are offloaded to the GPU, this will reduce RAM usage and use VRAM instead.
119
+
120
+
121
+
122
+ <!-- README_GGUF.md-provided-files end -->
123
+
124
+ <!-- README_GGUF.md-how-to-download start -->
125
+ ## How to download GGUF files
126
+
127
+ **Note for manual downloaders:** You almost never want to clone the entire repo! Multiple different quantisation formats are provided, and most users only want to pick and download a single file.
128
+
129
+ The following clients/libraries will automatically download models for you, providing a list of available models to choose from:
130
+
131
+ * LM Studio
132
+ * LoLLMS Web UI
133
+ * Faraday.dev
134
+
135
+ ### In `text-generation-webui`
136
+
137
+ Under Download Model, you can enter the model repo: TheBloke/firefly-mixtral-8x7b-GGUF and below it, a specific filename to download, such as: firefly-mixtral-8x7b.Q4_K_M.gguf.
138
+
139
+ Then click Download.
140
+
141
+ ### On the command line, including multiple files at once
142
+
143
+ I recommend using the `huggingface-hub` Python library:
144
+
145
+ ```shell
146
+ pip3 install huggingface-hub
147
+ ```
148
+
149
+ Then you can download any individual model file to the current directory, at high speed, with a command like this:
150
+
151
+ ```shell
152
+ huggingface-cli download TheBloke/firefly-mixtral-8x7b-GGUF firefly-mixtral-8x7b.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
153
+ ```
154
+
155
+ <details>
156
+ <summary>More advanced huggingface-cli download usage (click to read)</summary>
157
+
158
+ You can also download multiple files at once with a pattern:
159
+
160
+ ```shell
161
+ huggingface-cli download TheBloke/firefly-mixtral-8x7b-GGUF --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
162
+ ```
163
+
164
+ For more documentation on downloading with `huggingface-cli`, please see: [HF -> Hub Python Library -> Download files -> Download from the CLI](https://huggingface.co/docs/huggingface_hub/guides/download#download-from-the-cli).
165
+
166
+ To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
167
+
168
+ ```shell
169
+ pip3 install hf_transfer
170
+ ```
171
+
172
+ And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
173
+
174
+ ```shell
175
+ HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download TheBloke/firefly-mixtral-8x7b-GGUF firefly-mixtral-8x7b.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
176
+ ```
177
+
178
+ Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
179
+ </details>
180
+ <!-- README_GGUF.md-how-to-download end -->
181
+
182
+ <!-- README_GGUF.md-how-to-run start -->
183
+ ## Example `llama.cpp` command
184
+
185
+ Make sure you are using `llama.cpp` from commit [d0cee0d](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221) or later.
186
+
187
+ ```shell
188
+ ./main -ngl 35 -m firefly-mixtral-8x7b.Q4_K_M.gguf --color -c 32768 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "{prompt}"
189
+ ```
190
+
191
+ Change `-ngl 32` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
192
+
193
+ Change `-c 32768` to the desired sequence length. For extended sequence models - eg 8K, 16K, 32K - the necessary RoPE scaling parameters are read from the GGUF file and set by llama.cpp automatically. Note that longer sequence lengths require much more resources, so you may need to reduce this value.
194
+
195
+ If you want to have a chat-style conversation, replace the `-p <PROMPT>` argument with `-i -ins`
196
+
197
+ For other parameters and how to use them, please refer to [the llama.cpp documentation](https://github.com/ggerganov/llama.cpp/blob/master/examples/main/README.md)
198
+
199
+ ## How to run in `text-generation-webui`
200
+
201
+ Note that text-generation-webui may not yet be compatible with Mixtral GGUFs. Please check compatibility first.
202
+
203
+ Further instructions can be found in the text-generation-webui documentation, here: [text-generation-webui/docs/04 ‐ Model Tab.md](https://github.com/oobabooga/text-generation-webui/blob/main/docs/04%20%E2%80%90%20Model%20Tab.md#llamacpp).
204
+
205
+ ## How to run from Python code
206
+
207
+ You can use GGUF models from Python using the [llama-cpp-python](https://github.com/abetlen/llama-cpp-python) version 0.2.23 and later.
208
+
209
+ ### How to load this model in Python code, using llama-cpp-python
210
+
211
+ For full documentation, please see: [llama-cpp-python docs](https://abetlen.github.io/llama-cpp-python/).
212
+
213
+ #### First install the package
214
+
215
+ Run one of the following commands, according to your system:
216
+
217
+ ```shell
218
+ # Base ctransformers with no GPU acceleration
219
+ pip install llama-cpp-python
220
+ # With NVidia CUDA acceleration
221
+ CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python
222
+ # Or with OpenBLAS acceleration
223
+ CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
224
+ # Or with CLBLast acceleration
225
+ CMAKE_ARGS="-DLLAMA_CLBLAST=on" pip install llama-cpp-python
226
+ # Or with AMD ROCm GPU acceleration (Linux only)
227
+ CMAKE_ARGS="-DLLAMA_HIPBLAS=on" pip install llama-cpp-python
228
+ # Or with Metal GPU acceleration for macOS systems only
229
+ CMAKE_ARGS="-DLLAMA_METAL=on" pip install llama-cpp-python
230
+
231
+ # In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
232
+ $env:CMAKE_ARGS = "-DLLAMA_OPENBLAS=on"
233
+ pip install llama-cpp-python
234
+ ```
235
+
236
+ #### Simple llama-cpp-python example code
237
+
238
+ ```python
239
+ from llama_cpp import Llama
240
+
241
+ # Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
242
+ llm = Llama(
243
+ model_path="./firefly-mixtral-8x7b.Q4_K_M.gguf", # Download the model file first
244
+ n_ctx=32768, # The max sequence length to use - note that longer sequence lengths require much more resources
245
+ n_threads=8, # The number of CPU threads to use, tailor to your system and the resulting performance
246
+ n_gpu_layers=35 # The number of layers to offload to GPU, if you have GPU acceleration available
247
+ )
248
+
249
+ # Simple inference example
250
+ output = llm(
251
+ "{prompt}", # Prompt
252
+ max_tokens=512, # Generate up to 512 tokens
253
+ stop=["</s>"], # Example stop token - not necessarily correct for this specific model! Please check before using.
254
+ echo=True # Whether to echo the prompt
255
+ )
256
+
257
+ # Chat Completion API
258
+
259
+ llm = Llama(model_path="./firefly-mixtral-8x7b.Q4_K_M.gguf", chat_format="llama-2") # Set chat_format according to the model you are using
260
+ llm.create_chat_completion(
261
+ messages = [
262
+ {"role": "system", "content": "You are a story writing assistant."},
263
+ {
264
+ "role": "user",
265
+ "content": "Write a story about llamas."
266
+ }
267
+ ]
268
+ )
269
+ ```
270
+
271
+ ## How to use with LangChain
272
+
273
+ Here are guides on using llama-cpp-python and ctransformers with LangChain:
274
+
275
+ * [LangChain + llama-cpp-python](https://python.langchain.com/docs/integrations/llms/llamacpp)
276
+
277
+ <!-- README_GGUF.md-how-to-run end -->
278
+
279
+ <!-- footer start -->
280
+ <!-- 200823 -->
281
+ ## Discord
282
+
283
+ For further support, and discussions on these models and AI in general, join us at:
284
+
285
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
286
+
287
+ ## Thanks, and how to contribute
288
+
289
+ Thanks to the [chirper.ai](https://chirper.ai) team!
290
+
291
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
292
+
293
+ I've had a lot of people ask if they can contribute. I enjoy providing models and helping people, and would love to be able to spend even more time doing it, as well as expanding into new projects like fine tuning/training.
294
+
295
+ If you're able and willing to contribute it will be most gratefully received and will help me to keep providing more models, and to start work on new AI projects.
296
+
297
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
298
+
299
+ * Patreon: https://patreon.com/TheBlokeAI
300
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
301
+
302
+ **Special thanks to**: Aemon Algiz.
303
+
304
+ **Patreon special mentions**: Michael Levine, 阿明, Trailburnt, Nikolai Manek, John Detwiler, Randy H, Will Dee, Sebastain Graf, NimbleBox.ai, Eugene Pentland, Emad Mostaque, Ai Maven, Jim Angel, Jeff Scroggin, Michael Davis, Manuel Alberto Morcote, Stephen Murray, Robert, Justin Joy, Luke @flexchar, Brandon Frisco, Elijah Stavena, S_X, Dan Guido, Undi ., Komninos Chatzipapas, Shadi, theTransient, Lone Striker, Raven Klaugh, jjj, Cap'n Zoog, Michel-Marie MAUDET (LINAGORA), Matthew Berman, David, Fen Risland, Omer Bin Jawed, Luke Pendergrass, Kalila, OG, Erik Bjäreholt, Rooh Singh, Joseph William Delisle, Dan Lewis, TL, John Villwock, AzureBlack, Brad, Pedro Madruga, Caitlyn Gatomon, K, jinyuan sun, Mano Prime, Alex, Jeffrey Morgan, Alicia Loh, Illia Dulskyi, Chadd, transmissions 11, fincy, Rainer Wilmers, ReadyPlayerEmma, knownsqashed, Mandus, biorpg, Deo Leter, Brandon Phillips, SuperWojo, Sean Connelly, Iucharbius, Jack West, Harry Royden McLaughlin, Nicholas, terasurfer, Vitor Caleffi, Duane Dunston, Johann-Peter Hartmann, David Ziegler, Olakabola, Ken Nordquist, Trenton Dambrowitz, Tom X Nguyen, Vadim, Ajan Kanaga, Leonard Tan, Clay Pascal, Alexandros Triantafyllidis, JM33133, Xule, vamX, ya boyyy, subjectnull, Talal Aujan, Alps Aficionado, wassieverse, Ari Malik, James Bentley, Woland, Spencer Kim, Michael Dempsey, Fred von Graf, Elle, zynix, William Richards, Stanislav Ovsiannikov, Edmond Seymore, Jonathan Leane, Martin Kemka, usrbinkat, Enrico Ros
305
+
306
+
307
+ Thank you to all my generous patrons and donaters!
308
+
309
+ And thank you again to a16z for their generous grant.
310
+
311
+ <!-- footer end -->
312
+
313
+ <!-- original-model-card start -->
314
+ # Original model card: YeungNLP's Firefly Mixtral 8X7B
315
+
316
+
317
+ This model is finetuend on "mistralai/Mixtral-8x7B-v0.1" with Firefly
318
+
319
+ ## Run the model
320
+
321
+ ```python
322
+ from transformers import AutoModelForCausalLM, AutoTokenizer
323
+ import torch
324
+
325
+ model_name_or_path = 'YeungNLP/firefly-mixtral-8x7b'
326
+ max_new_tokens = 500
327
+ top_p = 0.9
328
+ temperature = 0.35
329
+ repetition_penalty = 1.0
330
+
331
+ model = AutoModelForCausalLM.from_pretrained(
332
+ model_name_or_path,
333
+ trust_remote_code=True,
334
+ low_cpu_mem_usage=True,
335
+ torch_dtype=torch.float16,
336
+ device_map='auto'
337
+ )
338
+ model = model.eval()
339
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
340
+
341
+ text = "Compose an engaging travel blog post about a recent trip to Hawaii, highlighting cultural experiences and must-see attractions."
342
+
343
+ inst_begin_tokens = tokenizer.encode('[INST]', add_special_tokens=False)
344
+ inst_end_tokens = tokenizer.encode('[/INST]', add_special_tokens=False)
345
+ human_tokens = tokenizer.encode(text, add_special_tokens=False)
346
+ input_ids = [tokenizer.bos_token_id] + inst_begin_tokens + human_tokens + inst_end_tokens
347
+
348
+ # input_ids = human_tokens
349
+ input_ids = torch.tensor([input_ids], dtype=torch.long).cuda()
350
+
351
+ with torch.no_grad():
352
+ outputs = model.generate(
353
+ input_ids=input_ids, max_new_tokens=max_new_tokens, do_sample=True,
354
+ top_p=top_p, temperature=temperature, repetition_penalty=repetition_penalty,
355
+ eos_token_id=tokenizer.eos_token_id
356
+ )
357
+ outputs = outputs.tolist()[0][len(input_ids[0]):]
358
+ response = tokenizer.decode(outputs)
359
+ response = response.strip().replace(tokenizer.eos_token, "").strip()
360
+ print("Chatbot:{}".format(response))
361
+
362
+ ```
363
+
364
+
365
+ <!-- original-model-card end -->