ManniX-ITA commited on
Commit
a79b89d
1 Parent(s): 707bc0d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +313 -0
README.md CHANGED
@@ -1,3 +1,316 @@
1
  ---
 
 
2
  license: cc-by-nc-4.0
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ base_model: cloudyu/Mixtral_7Bx2_MoE
3
+ inference: false
4
  license: cc-by-nc-4.0
5
+ model_creator: hai
6
+ model_name: Mixtral 7Bx2 MoE
7
+ model_type: mixtral
8
+ prompt_template: '{prompt}
9
+
10
+ '
11
+ quantized_by: ManniX-ITA
12
  ---
13
+ <!-- markdownlint-disable MD041 -->
14
+
15
+ # Mixtral 7Bx2 MoE - GGUF
16
+ - Model creator: [hai](https://huggingface.co/cloudyu)
17
+ - Original model: [Mixtral 7Bx2 MoE](https://huggingface.co/cloudyu/Mixtral_7Bx2_MoE)
18
+
19
+ <!-- description start -->
20
+ ## Description
21
+
22
+ This repo contains GGUF format model files for [hai's Mixtral 7Bx2 MoE](https://huggingface.co/cloudyu/Mixtral_7Bx2_MoE).
23
+
24
+ <!-- description end -->
25
+ <!-- README_GGUF.md-about-gguf start -->
26
+ ### About GGUF
27
+
28
+ 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.
29
+
30
+ Here is an incomplete list of clients and libraries that are known to support GGUF:
31
+
32
+ * [llama.cpp](https://github.com/ggerganov/llama.cpp). The source project for GGUF. Offers a CLI and a server option.
33
+ * [text-generation-webui](https://github.com/oobabooga/text-generation-webui), the most widely used web UI, with many features and powerful extensions. Supports GPU acceleration.
34
+ * [KoboldCpp](https://github.com/LostRuins/koboldcpp), a fully featured web UI, with GPU accel across all platforms and GPU architectures. Especially good for story telling.
35
+ * [GPT4All](https://gpt4all.io/index.html), a free and open source local running GUI, supporting Windows, Linux and macOS with full GPU accel.
36
+ * [LM Studio](https://lmstudio.ai/), an easy-to-use and powerful local GUI for Windows and macOS (Silicon), with GPU acceleration. Linux available, in beta as of 27/11/2023.
37
+ * [LoLLMS Web UI](https://github.com/ParisNeo/lollms-webui), a great web UI with many interesting and unique features, including a full model library for easy model selection.
38
+ * [Faraday.dev](https://faraday.dev/), an attractive and easy to use character-based chat GUI for Windows and macOS (both Silicon and Intel), with GPU acceleration.
39
+ * [llama-cpp-python](https://github.com/abetlen/llama-cpp-python), a Python library with GPU accel, LangChain support, and OpenAI-compatible API server.
40
+ * [candle](https://github.com/huggingface/candle), a Rust ML framework with a focus on performance, including GPU support, and ease of use.
41
+ * [ctransformers](https://github.com/marella/ctransformers), a Python library with GPU accel, LangChain support, and OpenAI-compatible AI server. Note, as of time of writing (November 27th 2023), ctransformers has not been updated in a long time and does not support many recent models.
42
+
43
+ <!-- README_GGUF.md-about-gguf end -->
44
+ <!-- repositories-available start -->
45
+ ## Repositories available
46
+
47
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/ManniX-ITA/Mixtral_7Bx2_MoE-GGUF)
48
+ * [hai's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/cloudyu/Mixtral_7Bx2_MoE)
49
+ <!-- repositories-available end -->
50
+
51
+ <!-- prompt-template start -->
52
+ ## Prompt template: Unknown
53
+
54
+ ```
55
+ {prompt}
56
+
57
+ ```
58
+
59
+ <!-- prompt-template end -->
60
+
61
+
62
+ <!-- compatibility_gguf start -->
63
+ ## Compatibility
64
+
65
+ These quantised GGUFv2 files are compatible with llama.cpp from August 27th onwards, as of commit [d0cee0d](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221)
66
+
67
+ They are also compatible with many third party UIs and libraries - please see the list at the top of this README.
68
+
69
+ ## Explanation of quantisation methods
70
+
71
+ <details>
72
+ <summary>Click to see details</summary>
73
+
74
+ * `q2_k`: Uses Q4_K for the attention.vw and feed_forward.w2 tensors, Q2_K for the other tensors.
75
+ * `q3_k_l`: Uses Q5_K for the attention.wv, attention.wo, and feed_forward.w2 tensors, else Q3_K
76
+ * `q3_k_m`: Uses Q4_K for the attention.wv, attention.wo, and feed_forward.w2 tensors, else Q3_K
77
+ * `q3_k_s`: Uses Q3_K for all tensors
78
+ * `q4_0`: Original quant method, 4-bit.
79
+ * `q4_1`: Higher accuracy than q4_0 but not as high as q5_0. However has quicker inference than q5 models.
80
+ * `q4_k_m`: Uses Q6_K for half of the attention.wv and feed_forward.w2 tensors, else Q4_K
81
+ * `q4_k_s`: Uses Q4_K for all tensors
82
+ * `q5_0`: Higher accuracy, higher resource usage and slower inference.
83
+ * `q5_1`: Even higher accuracy, resource usage and slower inference.
84
+ * `q5_k_m`: Uses Q6_K for half of the attention.wv and feed_forward.w2 tensors, else Q5_K
85
+ * `q5_k_s`: Uses Q5_K for all tensors
86
+ * `q6_k`: Uses Q8_K for all tensors
87
+ * `q8_0`: Almost indistinguishable from float16. High resource use and slow. Not recommended for most users.
88
+
89
+ </details>
90
+ <!-- compatibility_gguf end -->
91
+
92
+ <!-- README_GGUF.md-how-to-download start -->
93
+ ## How to download GGUF files
94
+
95
+ **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.
96
+
97
+ The following clients/libraries will automatically download models for you, providing a list of available models to choose from:
98
+
99
+ * LM Studio
100
+ * LoLLMS Web UI
101
+ * Faraday.dev
102
+
103
+ ### In `text-generation-webui`
104
+
105
+ Under Download Model, you can enter the model repo: ManniX-ITA/Mixtral_7Bx2_MoE-GGUF and below it, a specific filename to download, such as: mixtral_7bx2_moe.Q4_K_M.gguf.
106
+
107
+ Then click Download.
108
+
109
+ ### On the command line, including multiple files at once
110
+
111
+ I recommend using the `huggingface-hub` Python library:
112
+
113
+ ```shell
114
+ pip3 install huggingface-hub
115
+ ```
116
+
117
+ Then you can download any individual model file to the current directory, at high speed, with a command like this:
118
+
119
+ ```shell
120
+ huggingface-cli download ManniX-ITA/Mixtral_7Bx2_MoE-GGUF mixtral_7bx2_moe.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
121
+ ```
122
+
123
+ <details>
124
+ <summary>More advanced huggingface-cli download usage (click to read)</summary>
125
+
126
+ You can also download multiple files at once with a pattern:
127
+
128
+ ```shell
129
+ huggingface-cli download ManniX-ITA/Mixtral_7Bx2_MoE-GGUF --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
130
+ ```
131
+
132
+ 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).
133
+
134
+ To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
135
+
136
+ ```shell
137
+ pip3 install hf_transfer
138
+ ```
139
+
140
+ And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
141
+
142
+ ```shell
143
+ HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download ManniX-ITA/Mixtral_7Bx2_MoE-GGUF mixtral_7bx2_moe.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
144
+ ```
145
+
146
+ Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
147
+ </details>
148
+ <!-- README_GGUF.md-how-to-download end -->
149
+
150
+ <!-- README_GGUF.md-how-to-run start -->
151
+ ## Example `llama.cpp` command
152
+
153
+ Make sure you are using `llama.cpp` from commit [d0cee0d](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221) or later.
154
+
155
+ ```shell
156
+ ./main -ngl 35 -m mixtral_7bx2_moe.Q4_K_M.gguf --color -c 32768 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "{prompt}"
157
+ ```
158
+
159
+ Change `-ngl 32` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
160
+
161
+ 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.
162
+
163
+ If you want to have a chat-style conversation, replace the `-p <PROMPT>` argument with `-i -ins`
164
+
165
+ 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)
166
+
167
+ ## How to run in `text-generation-webui`
168
+
169
+ 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).
170
+
171
+ ## How to run from Python code
172
+
173
+ You can use GGUF models from Python using the [llama-cpp-python](https://github.com/abetlen/llama-cpp-python) or [ctransformers](https://github.com/marella/ctransformers) libraries. Note that at the time of writing (Nov 27th 2023), ctransformers has not been updated for some time and is not compatible with some recent models. Therefore I recommend you use llama-cpp-python.
174
+
175
+ ### How to load this model in Python code, using llama-cpp-python
176
+
177
+ For full documentation, please see: [llama-cpp-python docs](https://abetlen.github.io/llama-cpp-python/).
178
+
179
+ #### First install the package
180
+
181
+ Run one of the following commands, according to your system:
182
+
183
+ ```shell
184
+ # Base ctransformers with no GPU acceleration
185
+ pip install llama-cpp-python
186
+ # With NVidia CUDA acceleration
187
+ CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python
188
+ # Or with OpenBLAS acceleration
189
+ CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
190
+ # Or with CLBLast acceleration
191
+ CMAKE_ARGS="-DLLAMA_CLBLAST=on" pip install llama-cpp-python
192
+ # Or with AMD ROCm GPU acceleration (Linux only)
193
+ CMAKE_ARGS="-DLLAMA_HIPBLAS=on" pip install llama-cpp-python
194
+ # Or with Metal GPU acceleration for macOS systems only
195
+ CMAKE_ARGS="-DLLAMA_METAL=on" pip install llama-cpp-python
196
+
197
+ # In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
198
+ $env:CMAKE_ARGS = "-DLLAMA_OPENBLAS=on"
199
+ pip install llama-cpp-python
200
+ ```
201
+
202
+ #### Simple llama-cpp-python example code
203
+
204
+ ```python
205
+ from llama_cpp import Llama
206
+
207
+ # Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
208
+ llm = Llama(
209
+ model_path="./mixtral_7bx2_moe.Q4_K_M.gguf", # Download the model file first
210
+ n_ctx=32768, # The max sequence length to use - note that longer sequence lengths require much more resources
211
+ n_threads=8, # The number of CPU threads to use, tailor to your system and the resulting performance
212
+ n_gpu_layers=35 # The number of layers to offload to GPU, if you have GPU acceleration available
213
+ )
214
+
215
+ # Simple inference example
216
+ output = llm(
217
+ "{prompt}", # Prompt
218
+ max_tokens=512, # Generate up to 512 tokens
219
+ stop=["</s>"], # Example stop token - not necessarily correct for this specific model! Please check before using.
220
+ echo=True # Whether to echo the prompt
221
+ )
222
+
223
+ # Chat Completion API
224
+
225
+ llm = Llama(model_path="./mixtral_7bx2_moe.Q4_K_M.gguf", chat_format="llama-2") # Set chat_format according to the model you are using
226
+ llm.create_chat_completion(
227
+ messages = [
228
+ {"role": "system", "content": "You are a story writing assistant."},
229
+ {
230
+ "role": "user",
231
+ "content": "Write a story about llamas."
232
+ }
233
+ ]
234
+ )
235
+ ```
236
+
237
+ ## How to use with LangChain
238
+
239
+ Here are guides on using llama-cpp-python and ctransformers with LangChain:
240
+
241
+ * [LangChain + llama-cpp-python](https://python.langchain.com/docs/integrations/llms/llamacpp)
242
+ * [LangChain + ctransformers](https://python.langchain.com/docs/integrations/providers/ctransformers)
243
+
244
+ <!-- README_GGUF.md-how-to-run end -->
245
+
246
+ <!-- original-model-card start -->
247
+ # Original model card: hai's Mixtral 7Bx2 MoE
248
+
249
+
250
+ # Mixtral MOE 2x7B
251
+
252
+
253
+
254
+ MoE of the following models :
255
+
256
+ * [rwitz2/go-bruins-v2.1.1](https://huggingface.co/rwitz2/go-bruins-v2.1.1)
257
+ * [NurtureAI/neural-chat-7b-v3-16k](https://huggingface.co/NurtureAI/neural-chat-7b-v3-16k)
258
+ * [meta-math/mncai/mistral-7b-dpo-v6](https://huggingface.co/mncai/mistral-7b-dpo-v6)
259
+
260
+
261
+
262
+
263
+ gpu code example
264
+
265
+ ```
266
+ import torch
267
+ from transformers import AutoTokenizer, AutoModelForCausalLM
268
+ import math
269
+
270
+ ## v2 models
271
+ model_path = "cloudyu/Mixtral_7Bx2_MoE"
272
+
273
+ tokenizer = AutoTokenizer.from_pretrained(model_path, use_default_system_prompt=False)
274
+ model = AutoModelForCausalLM.from_pretrained(
275
+ model_path, torch_dtype=torch.float32, device_map='auto',local_files_only=False, load_in_4bit=True
276
+ )
277
+ print(model)
278
+ prompt = input("please input prompt:")
279
+ while len(prompt) > 0:
280
+ input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to("cuda")
281
+
282
+ generation_output = model.generate(
283
+ input_ids=input_ids, max_new_tokens=500,repetition_penalty=1.2
284
+ )
285
+ print(tokenizer.decode(generation_output[0]))
286
+ prompt = input("please input prompt:")
287
+ ```
288
+
289
+ CPU example
290
+
291
+ ```
292
+ import torch
293
+ from transformers import AutoTokenizer, AutoModelForCausalLM
294
+ import math
295
+
296
+ ## v2 models
297
+ model_path = "cloudyu/Mixtral_7Bx2_MoE"
298
+
299
+ tokenizer = AutoTokenizer.from_pretrained(model_path, use_default_system_prompt=False)
300
+ model = AutoModelForCausalLM.from_pretrained(
301
+ model_path, torch_dtype=torch.float32, device_map='cpu',local_files_only=False
302
+ )
303
+ print(model)
304
+ prompt = input("please input prompt:")
305
+ while len(prompt) > 0:
306
+ input_ids = tokenizer(prompt, return_tensors="pt").input_ids
307
+
308
+ generation_output = model.generate(
309
+ input_ids=input_ids, max_new_tokens=500,repetition_penalty=1.2
310
+ )
311
+ print(tokenizer.decode(generation_output[0]))
312
+ prompt = input("please input prompt:")
313
+
314
+ ```
315
+
316
+ <!-- original-model-card end -->