Text Generation
Transformers
GGUF
English
Chinese
llama
GGUF
Inference Endpoints
andrijdavid commited on
Commit
8f5811e
1 Parent(s): 63108cf

Upload folder using huggingface_hub

Browse files
Files changed (6) hide show
  1. README.md +284 -0
  2. config.json +27 -0
  3. special_tokens_map.json +23 -0
  4. teaser_a.jpg +0 -0
  5. tokenizer.model +3 -0
  6. tokenizer_config.json +37 -0
README.md ADDED
@@ -0,0 +1,284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - zh
5
+ license: apache-2.0
6
+ library_name: transformers
7
+ tags:
8
+ - GGUF
9
+ datasets:
10
+ - EleutherAI/pile
11
+ - togethercomputer/RedPajama-Data-1T
12
+ - p208p2002/wudao
13
+ widget:
14
+ - text: <s> 4 + 3 =
15
+ quantized_by: andrijdavid
16
+ ---
17
+ # MiniMA-2-3B-GGUF
18
+ - Original model: [MiniMA-2-3B](https://huggingface.co/GeneZC/MiniMA-2-3B)
19
+
20
+ <!-- description start -->
21
+ ## Description
22
+
23
+ This repo contains GGUF format model files for [MiniMA-2-3B](https://huggingface.co/GeneZC/MiniMA-2-3B).
24
+
25
+ <!-- description end -->
26
+ <!-- README_GGUF.md-about-gguf start -->
27
+ ### About GGUF
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
+ Here is an incomplete list of clients and libraries that are known to support GGUF:
30
+ * [llama.cpp](https://github.com/ggerganov/llama.cpp). This is the source project for GGUF, providing both a Command Line Interface (CLI) and a server option.
31
+ * [text-generation-webui](https://github.com/oobabooga/text-generation-webui), Known as the most widely used web UI, this project boasts numerous features and powerful extensions, and supports GPU acceleration.
32
+ * [Ollama](https://github.com/jmorganca/ollama) Ollama is a lightweight and extensible framework designed for building and running language models locally. It features a simple API for creating, managing, and executing models, along with a library of pre-built models for use in various applications​
33
+ * [KoboldCpp](https://github.com/LostRuins/koboldcpp), A comprehensive web UI offering GPU acceleration across all platforms and architectures, particularly renowned for storytelling.
34
+ * [GPT4All](https://gpt4all.io), This is a free and open source GUI that runs locally, supporting Windows, Linux, and macOS with full GPU acceleration.
35
+ * [LM Studio](https://lmstudio.ai/) An intuitive and powerful local GUI for Windows and macOS (Silicon), featuring GPU acceleration.
36
+ * [LoLLMS Web UI](https://github.com/ParisNeo/lollms-webui). A notable web UI with a variety of unique features, including a comprehensive model library for easy model selection.
37
+ * [Faraday.dev](https://faraday.dev/), An attractive, user-friendly character-based chat GUI for Windows and macOS (both Silicon and Intel), also offering GPU acceleration.
38
+ * [llama-cpp-python](https://github.com/abetlen/llama-cpp-python), A Python library equipped with GPU acceleration, LangChain support, and an OpenAI-compatible API server.
39
+ * [candle](https://github.com/huggingface/candle), A Rust-based ML framework focusing on performance, including GPU support, and designed for ease of use.
40
+ * [ctransformers](https://github.com/marella/ctransformers), A Python library featuring GPU acceleration, LangChain support, and an OpenAI-compatible AI server.
41
+ * [localGPT](https://github.com/PromtEngineer/localGPT) An open-source initiative enabling private conversations with documents.
42
+ <!-- README_GGUF.md-about-gguf end -->
43
+
44
+ <!-- compatibility_gguf start -->
45
+ ## Explanation of quantisation methods
46
+ <details>
47
+ <summary>Click to see details</summary>
48
+ The new methods available are:
49
+
50
+ * 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)
51
+ * 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.
52
+ * 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.
53
+ * GGML_TYPE_Q5_K - "type-1" 5-bit quantization. Same super-block structure as GGML_TYPE_Q4_K resulting in 5.5 bpw
54
+ * 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.
55
+ </details>
56
+ <!-- compatibility_gguf end -->
57
+
58
+ <!-- README_GGUF.md-how-to-download start -->
59
+ ## How to download GGUF files
60
+
61
+ **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.
62
+
63
+ The following clients/libraries will automatically download models for you, providing a list of available models to choose from:
64
+
65
+ * LM Studio
66
+ * LoLLMS Web UI
67
+ * Faraday.dev
68
+
69
+ ### In `text-generation-webui`
70
+
71
+ Under Download Model, you can enter the model repo: andrijdavid/MiniMA-2-3B-GGUF and below it, a specific filename to download, such as: MiniMA-2-3B-f16.gguf.
72
+
73
+ Then click Download.
74
+
75
+ ### On the command line, including multiple files at once
76
+
77
+ I recommend using the `huggingface-hub` Python library:
78
+
79
+ ```shell
80
+ pip3 install huggingface-hub
81
+ ```
82
+
83
+ Then you can download any individual model file to the current directory, at high speed, with a command like this:
84
+
85
+ ```shell
86
+ huggingface-cli download andrijdavid/MiniMA-2-3B-GGUF MiniMA-2-3B-f16.gguf --local-dir . --local-dir-use-symlinks False
87
+ ```
88
+
89
+ <details>
90
+ <summary>More advanced huggingface-cli download usage (click to read)</summary>
91
+
92
+ You can also download multiple files at once with a pattern:
93
+
94
+ ```shell
95
+ huggingface-cli download andrijdavid/MiniMA-2-3B-GGUF --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
96
+ ```
97
+
98
+ 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).
99
+
100
+ To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
101
+
102
+ ```shell
103
+ pip3 install hf_transfer
104
+ ```
105
+
106
+ And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
107
+
108
+ ```shell
109
+ HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download andrijdavid/MiniMA-2-3B-GGUF MiniMA-2-3B-f16.gguf --local-dir . --local-dir-use-symlinks False
110
+ ```
111
+
112
+ Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
113
+ </details>
114
+ <!-- README_GGUF.md-how-to-download end -->
115
+ <!-- README_GGUF.md-how-to-run start -->
116
+ ## Example `llama.cpp` command
117
+
118
+ Make sure you are using `llama.cpp` from commit [d0cee0d](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221) or later.
119
+
120
+ ```shell
121
+ ./main -ngl 35 -m MiniMA-2-3B-f16.gguf --color -c 4096 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "<PROMPT>"
122
+ ```
123
+
124
+ Change `-ngl 32` to the number of layers to offload to GPU. Remove it if you don't have GPU acceleration.
125
+
126
+ Change `-c 4096` 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.
127
+
128
+ If you want to have a chat-style conversation, replace the `-p <PROMPT>` argument with `-i -ins`
129
+
130
+ 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)
131
+
132
+ ## How to run in `text-generation-webui`
133
+
134
+ 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).
135
+
136
+ ## How to run from Python code
137
+
138
+ 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.
139
+
140
+ ### How to load this model in Python code, using llama-cpp-python
141
+
142
+ For full documentation, please see: [llama-cpp-python docs](https://abetlen.github.io/llama-cpp-python/).
143
+
144
+ #### First install the package
145
+
146
+ Run one of the following commands, according to your system:
147
+
148
+ ```shell
149
+ # Base ctransformers with no GPU acceleration
150
+ pip install llama-cpp-python
151
+ # With NVidia CUDA acceleration
152
+ CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python
153
+ # Or with OpenBLAS acceleration
154
+ CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
155
+ # Or with CLBLast acceleration
156
+ CMAKE_ARGS="-DLLAMA_CLBLAST=on" pip install llama-cpp-python
157
+ # Or with AMD ROCm GPU acceleration (Linux only)
158
+ CMAKE_ARGS="-DLLAMA_HIPBLAS=on" pip install llama-cpp-python
159
+ # Or with Metal GPU acceleration for macOS systems only
160
+ CMAKE_ARGS="-DLLAMA_METAL=on" pip install llama-cpp-python
161
+ # In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
162
+ $env:CMAKE_ARGS = "-DLLAMA_OPENBLAS=on"
163
+ pip install llama-cpp-python
164
+ ```
165
+
166
+ #### Simple llama-cpp-python example code
167
+
168
+ ```python
169
+ from llama_cpp import Llama
170
+ # Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
171
+ llm = Llama(
172
+ model_path="./MiniMA-2-3B-f16.gguf", # Download the model file first
173
+ n_ctx=32768, # The max sequence length to use - note that longer sequence lengths require much more resources
174
+ n_threads=8, # The number of CPU threads to use, tailor to your system and the resulting performance
175
+ n_gpu_layers=35 # The number of layers to offload to GPU, if you have GPU acceleration available
176
+ )
177
+ # Simple inference example
178
+ output = llm(
179
+ "<PROMPT>", # Prompt
180
+ max_tokens=512, # Generate up to 512 tokens
181
+ stop=["</s>"], # Example stop token - not necessarily correct for this specific model! Please check before using.
182
+ echo=True # Whether to echo the prompt
183
+ )
184
+ # Chat Completion API
185
+ llm = Llama(model_path="./MiniMA-2-3B-f16.gguf", chat_format="llama-2") # Set chat_format according to the model you are using
186
+ llm.create_chat_completion(
187
+ messages = [
188
+ {"role": "system", "content": "You are a story writing assistant."},
189
+ {
190
+ "role": "user",
191
+ "content": "Write a story about llamas."
192
+ }
193
+ ]
194
+ )
195
+ ```
196
+
197
+ ## How to use with LangChain
198
+
199
+ Here are guides on using llama-cpp-python and ctransformers with LangChain:
200
+
201
+ * [LangChain + llama-cpp-python](https://python.langchain.com/docs/integrations/llms/llamacpp)
202
+ * [LangChain + ctransformers](https://python.langchain.com/docs/integrations/providers/ctransformers)
203
+
204
+ <!-- README_GGUF.md-how-to-run end -->
205
+
206
+ <!-- footer end -->
207
+
208
+ <!-- original-model-card start -->
209
+ # Original model card: MiniMA-2-3B
210
+
211
+
212
+ ## MiniMA-2-3B
213
+
214
+ 📑 [arXiv](https://arxiv.org/abs/2311.07052) | 👻 [GitHub](https://github.com/GeneZC/MiniMA) | 🤗 [HuggingFace-MiniMA](https://huggingface.co/GeneZC/MiniMA-3B) | 🤗 [HuggingFace-MiniChat](https://huggingface.co/GeneZC/MiniChat-3B) | 🤖 [ModelScope-MiniMA](https://modelscope.cn/models/GeneZC/MiniMA-3B) | 🤖 [ModelScope-MiniChat](https://modelscope.cn/models/GeneZC/MiniChat-3B) | 🤗 [HuggingFace-MiniChat-1.5](https://huggingface.co/GeneZC/MiniChat-1.5-3B) | 🤗 [HuggingFace-MiniMA-2](https://huggingface.co/GeneZC/MiniMA-2-3B) | 🤗 [HuggingFace-MiniChat-2](https://huggingface.co/GeneZC/MiniChat-2-3B)
215
+
216
+ 🆕 **Updates from MiniMA-3B**:
217
+ - continued from MiniMA-3B without distillation;
218
+ - better data mixture;
219
+ - more trained tokens.
220
+
221
+ ❗ Must comply with LICENSE of LLaMA-2 since it is derived from LLaMA-2.
222
+
223
+ A language model continued from MiniMA-3B.
224
+
225
+ Completing the compute-performance pareto frontier together with MiniMA-3B and other arts.
226
+
227
+ <img src="./teaser_a.jpg" alt="teaser_a" width="700" />
228
+
229
+ **Standard Benchmarks**
230
+
231
+ |Method|TFLOPs|MMLU (5-shot)|CEval (5-shot)|DROP (3-shot)|HumanEval (0-shot)|BBH (3-shot)|GSM8K (8-shot)|
232
+ |--|--|--|--|--|--|--|--|
233
+ |Mamba-2.8B|4.6E9|25.58|24.74|15.72|7.32|29.37|3.49|
234
+ |ShearedLLaMA-2.7B|0.8E9|26.97|22.88|19.98|4.88|30.48|3.56|
235
+ |BTLM-3B|11.3E9|27.20|26.00|17.84|10.98|30.87|4.55|
236
+ |StableLM-3B|72.0E9|44.75|31.05|22.35|15.85|32.59|10.99|
237
+ |Qwen-1.8B|23.8E9|44.05|54.75|12.97|14.02|30.80|22.97|
238
+ |Phi-2-2.8B|159.9E9|56.74|34.03|30.74|46.95|44.13|55.42|
239
+ |LLaMA-2-7B|84.0E9|46.00|34.40|31.57|12.80|32.02|14.10|
240
+ ||
241
+ |MiniMA-3B|4.0E9|28.51|28.23|22.50|10.98|31.61|8.11|
242
+ |MiniChat-3B|4.0E9|38.40|36.48|22.58|18.29|31.36|29.72|
243
+ |MiniMA-2-3B|13.4E9|40.14|44.65|23.10|14.63|31.43|8.87|
244
+ |MiniChat-2-3B|13.4E9|46.17|43.91|30.26|22.56|34.95|38.13|
245
+
246
+ The following is an example code snippet to use MiniMA-2-3B:
247
+
248
+ ```python
249
+ import torch
250
+
251
+ from transformers import AutoModelForCausalLM, AutoTokenizer
252
+
253
+ # MiniMA
254
+ tokenizer = AutoTokenizer.from_pretrained("GeneZC/MiniMA-2-3B", use_fast=False)
255
+ # GPU.
256
+ model = AutoModelForCausalLM.from_pretrained("GeneZC/MiniMA-2-3B", use_cache=True, device_map="auto", torch_dtype=torch.float16).eval()
257
+ # CPU.
258
+ # model = AutoModelForCausalLM.from_pretrained("GeneZC/MiniMA-2-3B", use_cache=True, device_map="cpu", torch_dtype=torch.float16).eval()
259
+
260
+ prompt = "Question: Sherrie tells the truth. Vernell says Sherrie tells the truth. Alexis says Vernell lies. Michaela says Alexis tells the truth. Elanor says Michaela tells the truth. Does Elanor tell the truth?\nAnswer: No\n\nQuestion: Kristian lies. Sherrie says Kristian lies. Delbert says Sherrie lies. Jerry says Delbert tells the truth. Shalonda says Jerry tells the truth. Does Shalonda tell the truth?\nAnswer: No\n\nQuestion: Vina tells the truth. Helene says Vina lies. Kandi says Helene tells the truth. Jamey says Kandi lies. Ka says Jamey lies. Does Ka tell the truth?\nAnswer: No\n\nQuestion: Christie tells the truth. Ka says Christie tells the truth. Delbert says Ka lies. Leda says Delbert tells the truth. Lorine says Leda tells the truth. Does Lorine tell the truth?\nAnswer:"
261
+ input_ids = tokenizer([prompt]).input_ids
262
+ output_ids = model.generate(
263
+ torch.as_tensor(input_ids).cuda(),
264
+ do_sample=True,
265
+ temperature=0.7,
266
+ max_new_tokens=1024,
267
+ )
268
+ output_ids = output_ids[0][len(input_ids[0]):]
269
+ output = tokenizer.decode(output_ids, skip_special_tokens=True).strip()
270
+ # output: "No"
271
+ ```
272
+
273
+ ## Bibtex
274
+
275
+ ```bibtex
276
+ @article{zhang2023law,
277
+ title={Towards the Law of Capacity Gap in Distilling Language Models},
278
+ author={Zhang, Chen and Song, Dawei and Ye, Zheyu and Gao, Yan},
279
+ year={2023},
280
+ url={https://arxiv.org/abs/2311.07052}
281
+ }
282
+ ```
283
+
284
+ <!-- original-model-card end -->
config.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "MiniMA-2-3B",
3
+ "architectures": [
4
+ "LlamaForCausalLM"
5
+ ],
6
+ "bos_token_id": 1,
7
+ "eos_token_id": 2,
8
+ "hidden_act": "silu",
9
+ "hidden_size": 3072,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 8192,
12
+ "max_position_embeddings": 4096,
13
+ "model_type": "llama",
14
+ "num_attention_heads": 24,
15
+ "num_hidden_layers": 24,
16
+ "num_key_value_heads": 24,
17
+ "pad_token_id": 0,
18
+ "pretraining_tp": 1,
19
+ "rms_norm_eps": 1e-05,
20
+ "rope_scaling": null,
21
+ "rope_theta": 10000.0,
22
+ "tie_word_embeddings": false,
23
+ "torch_dtype": "float16",
24
+ "transformers_version": "4.33.2",
25
+ "use_cache": true,
26
+ "vocab_size": 49216
27
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": true,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "</s>",
11
+ "lstrip": false,
12
+ "normalized": true,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "unk_token": {
17
+ "content": "<unk>",
18
+ "lstrip": false,
19
+ "normalized": true,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ }
23
+ }
teaser_a.jpg ADDED
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ae87c0db2b21b0fa3fdc5e19d1f9cea94efb703cc7c6281d8718a6714b3cc2be
3
+ size 748869
tokenizer_config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "bos_token": {
5
+ "__type": "AddedToken",
6
+ "content": "<s>",
7
+ "lstrip": false,
8
+ "normalized": true,
9
+ "rstrip": false,
10
+ "single_word": false
11
+ },
12
+ "clean_up_tokenization_spaces": false,
13
+ "eos_token": {
14
+ "__type": "AddedToken",
15
+ "content": "</s>",
16
+ "lstrip": false,
17
+ "normalized": true,
18
+ "rstrip": false,
19
+ "single_word": false
20
+ },
21
+ "legacy": null,
22
+ "model_max_length": 1000000000000000019884624838656,
23
+ "pad_token": null,
24
+ "sp_model_kwargs": {},
25
+ "spaces_between_special_tokens": false,
26
+ "tokenizer_class": "LlamaTokenizer",
27
+ "unk_token": {
28
+ "__type": "AddedToken",
29
+ "content": "<unk>",
30
+ "lstrip": false,
31
+ "normalized": true,
32
+ "rstrip": false,
33
+ "single_word": false
34
+ },
35
+ "use_default_system_prompt": true,
36
+ "use_fast": true
37
+ }