TheBloke commited on
Commit
164d9e7
1 Parent(s): ba33a1b

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +584 -0
README.md ADDED
@@ -0,0 +1,584 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: OpenNLPLab/TransNormerLLM-7B
3
+ inference: false
4
+ language:
5
+ - en
6
+ - zh
7
+ license: other
8
+ model_creator: OpenNLPLab
9
+ model_name: TransnormerLLM 7B
10
+ model_type: transnormer
11
+ pipeline_tag: text-generation
12
+ prompt_template: '{prompt}
13
+
14
+ '
15
+ quantized_by: TheBloke
16
+ tags:
17
+ - ' TransNormerLLM'
18
+ ---
19
+ <!-- markdownlint-disable MD041 -->
20
+
21
+ <!-- header start -->
22
+ <!-- 200823 -->
23
+ <div style="width: auto; margin-left: auto; margin-right: auto">
24
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
25
+ </div>
26
+ <div style="display: flex; justify-content: space-between; width: 100%;">
27
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
28
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
29
+ </div>
30
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
31
+ <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>
32
+ </div>
33
+ </div>
34
+ <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>
35
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
36
+ <!-- header end -->
37
+
38
+ # TransnormerLLM 7B - GPTQ
39
+ - Model creator: [OpenNLPLab](https://huggingface.co/OpenNLPLab)
40
+ - Original model: [TransnormerLLM 7B](https://huggingface.co/OpenNLPLab/TransNormerLLM-7B)
41
+
42
+ <!-- description start -->
43
+ # Description
44
+
45
+ This repo contains GPTQ model files for [OpenNLPLab's TransnormerLLM 7B](https://huggingface.co/OpenNLPLab/TransNormerLLM-7B).
46
+
47
+ Multiple GPTQ parameter permutations are provided; see Provided Files below for details of the options provided, their parameters, and the software used to create them.
48
+
49
+ These files were quantised using hardware kindly provided by [Massed Compute](https://massedcompute.com/).
50
+
51
+ <!-- description end -->
52
+ <!-- repositories-available start -->
53
+ ## Repositories available
54
+
55
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/TransNormerLLM-7B-GPTQ)
56
+ * [OpenNLPLab's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/OpenNLPLab/TransNormerLLM-7B)
57
+ <!-- repositories-available end -->
58
+
59
+ <!-- prompt-template start -->
60
+ ## Prompt template: None
61
+
62
+ ```
63
+ {prompt}
64
+
65
+ ```
66
+
67
+ <!-- prompt-template end -->
68
+
69
+
70
+
71
+ <!-- README_GPTQ.md-compatible clients start -->
72
+ ## Known compatible clients / servers
73
+
74
+ These GPTQ models are known to work in the following inference servers/webuis.
75
+
76
+ - [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
77
+ - [KoboldAI United](https://github.com/henk717/koboldai)
78
+ - [LoLLMS Web UI](https://github.com/ParisNeo/lollms-webui)
79
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
80
+
81
+ This may not be a complete list; if you know of others, please let me know!
82
+ <!-- README_GPTQ.md-compatible clients end -->
83
+
84
+ <!-- README_GPTQ.md-provided-files start -->
85
+ ## Provided files, and GPTQ parameters
86
+
87
+ Multiple quantisation parameters are provided, to allow you to choose the best one for your hardware and requirements.
88
+
89
+ Each separate quant is in a different branch. See below for instructions on fetching from different branches.
90
+
91
+ Most GPTQ files are made with AutoGPTQ. Mistral models are currently made with Transformers.
92
+
93
+ <details>
94
+ <summary>Explanation of GPTQ parameters</summary>
95
+
96
+ - Bits: The bit size of the quantised model.
97
+ - GS: GPTQ group size. Higher numbers use less VRAM, but have lower quantisation accuracy. "None" is the lowest possible value.
98
+ - Act Order: True or False. Also known as `desc_act`. True results in better quantisation accuracy. Some GPTQ clients have had issues with models that use Act Order plus Group Size, but this is generally resolved now.
99
+ - Damp %: A GPTQ parameter that affects how samples are processed for quantisation. 0.01 is default, but 0.1 results in slightly better accuracy.
100
+ - GPTQ dataset: The calibration dataset used during quantisation. Using a dataset more appropriate to the model's training can improve quantisation accuracy. Note that the GPTQ calibration dataset is not the same as the dataset used to train the model - please refer to the original model repo for details of the training dataset(s).
101
+ - Sequence Length: The length of the dataset sequences used for quantisation. Ideally this is the same as the model sequence length. For some very long sequence models (16+K), a lower sequence length may have to be used. Note that a lower sequence length does not limit the sequence length of the quantised model. It only impacts the quantisation accuracy on longer inference sequences.
102
+ - ExLlama Compatibility: Whether this file can be loaded with ExLlama, which currently only supports Llama and Mistral models in 4-bit.
103
+
104
+ </details>
105
+
106
+ | Branch | Bits | GS | Act Order | Damp % | GPTQ Dataset | Seq Len | Size | ExLlama | Desc |
107
+ | ------ | ---- | -- | --------- | ------ | ------------ | ------- | ---- | ------- | ---- |
108
+ | [main](https://huggingface.co/TheBloke/TransNormerLLM-7B-GPTQ/tree/main) | 4 | 128 | Yes | 0.1 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-raw-v1) | 8192 | 3.95 GB | No | 4-bit, with Act Order and group size 128g. Uses even less VRAM than 64g, but with slightly lower accuracy. |
109
+ | [gptq-4bit-32g-actorder_True](https://huggingface.co/TheBloke/TransNormerLLM-7B-GPTQ/tree/gptq-4bit-32g-actorder_True) | 4 | 32 | Yes | 0.1 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-raw-v1) | 8192 | 4.33 GB | No | 4-bit, with Act Order and group size 32g. Gives highest possible inference quality, with maximum VRAM usage. |
110
+ | [gptq-8bit--1g-actorder_True](https://huggingface.co/TheBloke/TransNormerLLM-7B-GPTQ/tree/gptq-8bit--1g-actorder_True) | 8 | None | Yes | 0.1 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-raw-v1) | 8192 | 5.00 GB | No | 8-bit, with Act Order. No group size, to lower VRAM requirements. |
111
+ | [gptq-8bit-128g-actorder_True](https://huggingface.co/TheBloke/TransNormerLLM-7B-GPTQ/tree/gptq-8bit-128g-actorder_True) | 8 | 128 | Yes | 0.1 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-raw-v1) | 8192 | 4.97 GB | No | 8-bit, with group size 128g for higher inference quality and with Act Order for even higher accuracy. |
112
+ | [gptq-8bit-32g-actorder_True](https://huggingface.co/TheBloke/TransNormerLLM-7B-GPTQ/tree/gptq-8bit-32g-actorder_True) | 8 | 32 | Yes | 0.1 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-raw-v1) | 8192 | 4.98 GB | No | 8-bit, with group size 32g and Act Order for maximum inference quality. |
113
+ | [gptq-4bit-64g-actorder_True](https://huggingface.co/TheBloke/TransNormerLLM-7B-GPTQ/tree/gptq-4bit-64g-actorder_True) | 4 | 64 | Yes | 0.1 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-raw-v1) | 8192 | 4.07 GB | No | 4-bit, with Act Order and group size 64g. Uses less VRAM than 32g, but with slightly lower accuracy. |
114
+
115
+ <!-- README_GPTQ.md-provided-files end -->
116
+
117
+ <!-- README_GPTQ.md-download-from-branches start -->
118
+ ## How to download, including from branches
119
+
120
+ ### In text-generation-webui
121
+
122
+ To download from the `main` branch, enter `TheBloke/TransNormerLLM-7B-GPTQ` in the "Download model" box.
123
+
124
+ To download from another branch, add `:branchname` to the end of the download name, eg `TheBloke/TransNormerLLM-7B-GPTQ:gptq-4bit-32g-actorder_True`
125
+
126
+ ### From the command line
127
+
128
+ I recommend using the `huggingface-hub` Python library:
129
+
130
+ ```shell
131
+ pip3 install huggingface-hub
132
+ ```
133
+
134
+ To download the `main` branch to a folder called `TransNormerLLM-7B-GPTQ`:
135
+
136
+ ```shell
137
+ mkdir TransNormerLLM-7B-GPTQ
138
+ huggingface-cli download TheBloke/TransNormerLLM-7B-GPTQ --local-dir TransNormerLLM-7B-GPTQ --local-dir-use-symlinks False
139
+ ```
140
+
141
+ To download from a different branch, add the `--revision` parameter:
142
+
143
+ ```shell
144
+ mkdir TransNormerLLM-7B-GPTQ
145
+ huggingface-cli download TheBloke/TransNormerLLM-7B-GPTQ --revision gptq-4bit-32g-actorder_True --local-dir TransNormerLLM-7B-GPTQ --local-dir-use-symlinks False
146
+ ```
147
+
148
+ <details>
149
+ <summary>More advanced huggingface-cli download usage</summary>
150
+
151
+ If you remove the `--local-dir-use-symlinks False` parameter, the files will instead be stored in the central Hugging Face cache directory (default location on Linux is: `~/.cache/huggingface`), and symlinks will be added to the specified `--local-dir`, pointing to their real location in the cache. This allows for interrupted downloads to be resumed, and allows you to quickly clone the repo to multiple places on disk without triggering a download again. The downside, and the reason why I don't list that as the default option, is that the files are then hidden away in a cache folder and it's harder to know where your disk space is being used, and to clear it up if/when you want to remove a download model.
152
+
153
+ The cache location can be changed with the `HF_HOME` environment variable, and/or the `--cache-dir` parameter to `huggingface-cli`.
154
+
155
+ 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).
156
+
157
+ To accelerate downloads on fast connections (1Gbit/s or higher), install `hf_transfer`:
158
+
159
+ ```shell
160
+ pip3 install hf_transfer
161
+ ```
162
+
163
+ And set environment variable `HF_HUB_ENABLE_HF_TRANSFER` to `1`:
164
+
165
+ ```shell
166
+ mkdir TransNormerLLM-7B-GPTQ
167
+ HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download TheBloke/TransNormerLLM-7B-GPTQ --local-dir TransNormerLLM-7B-GPTQ --local-dir-use-symlinks False
168
+ ```
169
+
170
+ Windows Command Line users: You can set the environment variable by running `set HF_HUB_ENABLE_HF_TRANSFER=1` before the download command.
171
+ </details>
172
+
173
+ ### With `git` (**not** recommended)
174
+
175
+ To clone a specific branch with `git`, use a command like this:
176
+
177
+ ```shell
178
+ git clone --single-branch --branch gptq-4bit-32g-actorder_True https://huggingface.co/TheBloke/TransNormerLLM-7B-GPTQ
179
+ ```
180
+
181
+ Note that using Git with HF repos is strongly discouraged. It will be much slower than using `huggingface-hub`, and will use twice as much disk space as it has to store the model files twice (it stores every byte both in the intended target folder, and again in the `.git` folder as a blob.)
182
+
183
+ <!-- README_GPTQ.md-download-from-branches end -->
184
+ <!-- README_GPTQ.md-text-generation-webui start -->
185
+ ## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
186
+
187
+ Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
188
+
189
+ It is strongly recommended to use the text-generation-webui one-click-installers unless you're sure you know how to make a manual install.
190
+
191
+ 1. Click the **Model tab**.
192
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/TransNormerLLM-7B-GPTQ`.
193
+
194
+ - To download from a specific branch, enter for example `TheBloke/TransNormerLLM-7B-GPTQ:gptq-4bit-32g-actorder_True`
195
+ - see Provided Files above for the list of branches for each option.
196
+
197
+ 3. Click **Download**.
198
+ 4. The model will start downloading. Once it's finished it will say "Done".
199
+ 5. In the top left, click the refresh icon next to **Model**.
200
+ 6. In the **Model** dropdown, choose the model you just downloaded: `TransNormerLLM-7B-GPTQ`
201
+ 7. The model will automatically load, and is now ready for use!
202
+ 8. If you want any custom settings, set them and then click **Save settings for this model** followed by **Reload the Model** in the top right.
203
+
204
+ - Note that you do not need to and should not set manual GPTQ parameters any more. These are set automatically from the file `quantize_config.json`.
205
+
206
+ 9. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
207
+
208
+ <!-- README_GPTQ.md-text-generation-webui end -->
209
+
210
+ <!-- README_GPTQ.md-use-from-tgi start -->
211
+ ## Serving this model from Text Generation Inference (TGI)
212
+
213
+ It's recommended to use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
214
+
215
+ Example Docker parameters:
216
+
217
+ ```shell
218
+ --model-id TheBloke/TransNormerLLM-7B-GPTQ --port 3000 --quantize gptq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
219
+ ```
220
+
221
+ Example Python code for interfacing with TGI (requires huggingface-hub 0.17.0 or later):
222
+
223
+ ```shell
224
+ pip3 install huggingface-hub
225
+ ```
226
+
227
+ ```python
228
+ from huggingface_hub import InferenceClient
229
+
230
+ endpoint_url = "https://your-endpoint-url-here"
231
+
232
+ prompt = "Tell me about AI"
233
+ prompt_template=f'''{prompt}
234
+ '''
235
+
236
+ client = InferenceClient(endpoint_url)
237
+ response = client.text_generation(prompt,
238
+ max_new_tokens=128,
239
+ do_sample=True,
240
+ temperature=0.7,
241
+ top_p=0.95,
242
+ top_k=40,
243
+ repetition_penalty=1.1)
244
+
245
+ print(f"Model output: {response}")
246
+ ```
247
+ <!-- README_GPTQ.md-use-from-tgi end -->
248
+ <!-- README_GPTQ.md-use-from-python start -->
249
+ ## Python code example: inference from this GPTQ model
250
+
251
+ ### Install the necessary packages
252
+
253
+ Requires: Transformers 4.33.0 or later, Optimum 1.12.0 or later, and AutoGPTQ 0.4.2 or later.
254
+
255
+ ```shell
256
+ pip3 install --upgrade transformers optimum
257
+ # If using PyTorch 2.1 + CUDA 12.x:
258
+ pip3 install --upgrade auto-gptq
259
+ # or, if using PyTorch 2.1 + CUDA 11.x:
260
+ pip3 install --upgrade auto-gptq --extra-index-url https://huggingface.github.io/autogptq-index/whl/cu118/
261
+ ```
262
+
263
+ If you are using PyTorch 2.0, you will need to install AutoGPTQ from source. Likewise if you have problems with the pre-built wheels, you should try building from source:
264
+
265
+ ```shell
266
+ pip3 uninstall -y auto-gptq
267
+ git clone https://github.com/PanQiWei/AutoGPTQ
268
+ cd AutoGPTQ
269
+ git checkout v0.5.1
270
+ pip3 install .
271
+ ```
272
+
273
+ ### Example Python code
274
+
275
+ ```python
276
+ from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
277
+
278
+ model_name_or_path = "TheBloke/TransNormerLLM-7B-GPTQ"
279
+ # To use a different branch, change revision
280
+ # For example: revision="gptq-4bit-32g-actorder_True"
281
+ model = AutoModelForCausalLM.from_pretrained(model_name_or_path,
282
+ device_map="auto",
283
+ trust_remote_code=True,
284
+ revision="main")
285
+
286
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
287
+
288
+ prompt = "Tell me about AI"
289
+ prompt_template=f'''{prompt}
290
+ '''
291
+
292
+ print("\n\n*** Generate:")
293
+
294
+ input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()
295
+ output = model.generate(inputs=input_ids, temperature=0.7, do_sample=True, top_p=0.95, top_k=40, max_new_tokens=512)
296
+ print(tokenizer.decode(output[0]))
297
+
298
+ # Inference can also be done using transformers' pipeline
299
+
300
+ print("*** Pipeline:")
301
+ pipe = pipeline(
302
+ "text-generation",
303
+ model=model,
304
+ tokenizer=tokenizer,
305
+ max_new_tokens=512,
306
+ do_sample=True,
307
+ temperature=0.7,
308
+ top_p=0.95,
309
+ top_k=40,
310
+ repetition_penalty=1.1
311
+ )
312
+
313
+ print(pipe(prompt_template)[0]['generated_text'])
314
+ ```
315
+ <!-- README_GPTQ.md-use-from-python end -->
316
+
317
+ <!-- README_GPTQ.md-compatibility start -->
318
+ ## Compatibility
319
+
320
+ The files provided are tested to work with Transformers. For non-Mistral models, AutoGPTQ can also be used directly.
321
+
322
+ [ExLlama](https://github.com/turboderp/exllama) is compatible with Llama and Mistral models in 4-bit. Please see the Provided Files table above for per-file compatibility.
323
+
324
+ For a list of clients/servers, please see "Known compatible clients / servers", above.
325
+ <!-- README_GPTQ.md-compatibility end -->
326
+
327
+ <!-- footer start -->
328
+ <!-- 200823 -->
329
+ ## Discord
330
+
331
+ For further support, and discussions on these models and AI in general, join us at:
332
+
333
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
334
+
335
+ ## Thanks, and how to contribute
336
+
337
+ Thanks to the [chirper.ai](https://chirper.ai) team!
338
+
339
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
340
+
341
+ 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.
342
+
343
+ 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.
344
+
345
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
346
+
347
+ * Patreon: https://patreon.com/TheBlokeAI
348
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
349
+
350
+ **Special thanks to**: Aemon Algiz.
351
+
352
+ **Patreon special mentions**: Brandon Frisco, LangChain4j, Spiking Neurons AB, transmissions 11, Joseph William Delisle, Nitin Borwankar, Willem Michiel, Michael Dempsey, vamX, Jeffrey Morgan, zynix, jjj, Omer Bin Jawed, Sean Connelly, jinyuan sun, Jeromy Smith, Shadi, Pawan Osman, Chadd, Elijah Stavena, Illia Dulskyi, Sebastain Graf, Stephen Murray, terasurfer, Edmond Seymore, Celu Ramasamy, Mandus, Alex, biorpg, Ajan Kanaga, Clay Pascal, Raven Klaugh, 阿明, K, ya boyyy, usrbinkat, Alicia Loh, John Villwock, ReadyPlayerEmma, Chris Smitley, Cap'n Zoog, fincy, GodLy, S_X, sidney chen, Cory Kujawski, OG, Mano Prime, AzureBlack, Pieter, Kalila, Spencer Kim, Tom X Nguyen, Stanislav Ovsiannikov, Michael Levine, Andrey, Trailburnt, Vadim, Enrico Ros, Talal Aujan, Brandon Phillips, Jack West, Eugene Pentland, Michael Davis, Will Dee, webtim, Jonathan Leane, Alps Aficionado, Rooh Singh, Tiffany J. Kim, theTransient, Luke @flexchar, Elle, Caitlyn Gatomon, Ari Malik, subjectnull, Johann-Peter Hartmann, Trenton Dambrowitz, Imad Khwaja, Asp the Wyvern, Emad Mostaque, Rainer Wilmers, Alexandros Triantafyllidis, Nicholas, Pedro Madruga, SuperWojo, Harry Royden McLaughlin, James Bentley, Olakabola, David Ziegler, Ai Maven, Jeff Scroggin, Nikolai Manek, Deo Leter, Matthew Berman, Fen Risland, Ken Nordquist, Manuel Alberto Morcote, Luke Pendergrass, TL, Fred von Graf, Randy H, Dan Guido, NimbleBox.ai, Vitor Caleffi, Gabriel Tamborski, knownsqashed, Lone Striker, Erik Bjäreholt, John Detwiler, Leonard Tan, Iucharbius
353
+
354
+
355
+ Thank you to all my generous patrons and donaters!
356
+
357
+ And thank you again to a16z for their generous grant.
358
+
359
+ <!-- footer end -->
360
+
361
+ # Original model card: OpenNLPLab's TransnormerLLM 7B
362
+
363
+
364
+ <div align="center">
365
+ <h1>
366
+ TransNormerLLM -- A Faster and Better LLM
367
+ </h1>
368
+ </div>
369
+
370
+ <p align="center">
371
+ 💻 <a href="https://github.com/OpenNLPLab/TransnormerLLM" target="_blank">GitHub </a> • 💬 <a href="https://discord.gg/W4Vr7AKW" target="_blank">Discord</a> • 💬 <a href="./images/contact_me_qr.png" target="_blank">Wechat</a>
372
+ </p>
373
+
374
+
375
+ # Table of Contents
376
+
377
+ - [Introduction](#introduction)
378
+ - [Released Weights](#released-weights)
379
+ - [Benchmark Results](#benchmark-results)
380
+ - [General Domain](#general-domain)
381
+ - [Model Results](#model-results)
382
+ - [Inference and Deployment](#inference-and-deployment)
383
+ - [Dependency Installation](#dependency-installation)
384
+ - [Notice](#notice)
385
+ - [Python Code Inference](#python-code-inference)
386
+ - [Demonstration of Base Model Inference](#demonstration-of-base-model-inference)
387
+ - [Fine-tuning the Model](#fine-tuning-the-model)
388
+ - [Dependency Installation](#dependency-installation-1)
389
+ - [Training](#training)
390
+ - [Community and Ecosystem](#community-and-ecosystem)
391
+ - [Disclaimer, License and Citation](#disclaimer-license-and-citation)
392
+ - [Disclaimer](#disclaimer)
393
+ - [License](#license)
394
+ - [Acknowledgments](#acknowledgments)
395
+ - [Citation](#citation)
396
+
397
+ # Introduction
398
+
399
+ We are re-inventing the Large Language Model (LLM). This is the official implementation of TransNormerLLM in [link](https://arxiv.org/pdf/2307.14995.pdf). Our opened weights of TransNormerLLM are now accessible to individuals, creators, researchers and businesses of all sizes so that they can experiment, innovate and scale their ideas responsibly.
400
+
401
+ Our release contains the TransNormerLLM model implementation, the open-source weights and the starting code for Supervised Fine-tuning (SFT). We will show examples on how to load [TransNormerLLM](https://github.com/OpenNLPLab/Transnormer) models, run SFT and inference on it.
402
+
403
+ - TransNormerLLM is the first linear attention-based LLM that outperforms conventional softmax attention-based models in terms of both accuracy and efficiency. It was trained on a high-quality corpus with up to **1.4 trillion** tokens.
404
+ - TransNormerLLM evolves from the previous linear attention architecture TransNormer by making advanced modifications that include LRPE positional embedding, Lightning Attention acceleration, new gating and normalization mechanisms.
405
+ - TransNormerLLM achieved competitive performance of its size on multiple well-approved Chinese, English, and multi-language general and domain-specific benchmarks.
406
+ - This release includes **Base** versions with **385M**, **1B**, and **7B** parameters.
407
+ - All versions are fully open to academic research. Developers only need to apply via email and obtain official commercial permission to use it for free commercially.
408
+ - For more information, welcome reading our academic paper [TransNormerLLM](https://arxiv.org/pdf/2307.14995.pdf).
409
+
410
+
411
+ # Released Weights
412
+
413
+ The specific released versions and download links are shown as below:
414
+
415
+ | | Base Models |
416
+ |:-------:|:-----------:|
417
+ | 385M | 🤗 [TransNormerLLM-385M](https://huggingface.co/OpenNLPLab/TransNormerLLM-385M) |
418
+ | 1B | 🤗 [TransNormerLLM-1B](https://huggingface.co/OpenNLPLab/TransNormerLLM-1B) |
419
+ | 7B | 🤗 [TransNormerLLM-7B](https://huggingface.co/OpenNLPLab/TransNormerLLM-7B) |
420
+
421
+ # Benchmark Results
422
+
423
+ To validate TransNormerLLM, we tested our 385M, 1B, and 7B models on Commonsense Reasoning Task, MMLU, CMMLU, and C-Eval. For comparison, we selected several open-source models as competitors, including Transformer-based models such as OPT, Pythia, BLOOM, GPT-Neo, GPT-J, MPT, Falcon, LLaMA1/2, OpenLLAMA v1/v2, Baichuan 1/2, ChatGLM 1/2, and non-Transformer model RWKV. It can be observed that, compared to these models, TransNormerLLM remains highly competitive.
424
+
425
+ **Commonsense Reasoning** We report BoolQ, PIQA, SIQA,
426
+ HellaSwag, WinoGrande, ARC easy and challenge, OpenBookQA and their average. We report 0-shot results for all benchmarks using LM-Eval-Harness.
427
+ All of our models achieve competitive performance compared to existing state-of-the-art LLMs, showcasing a remarkable ability to comprehend and apply commonsense reasoning.
428
+
429
+ **Aggregated Benchmarks**
430
+ We report the overall results for MMLU, CMMLU, C-Eval. Official scripts were used for evaluating MMLU, CMMLU, and C-Eval, with all evaluation results being conducted with a 5-shot setup. In comparison to top-tier open-source models available in the industry, our models have demonstrated matched performance in both English and Chinese benchmarks.
431
+
432
+ ## General Domain
433
+
434
+ In the general domain, we conducted 5-shot tests on the following datasets:
435
+ - [C-Eval](https://cevalbenchmark.com/index.html#home) is a comprehensive Chinese basic model evaluation dataset, covering 52 disciplines and four levels of difficulty. Our evaluation approach followed that of [LM-Evaluation-Harness](https://github.com/EleutherAI/lm-evaluation-harness).
436
+ - [MMLU](https://arxiv.org/abs/2009.03300) is an English evaluation dataset comprising 57 tasks, encompassing elementary math, American history, computer science, law, etc. The difficulty ranges from high school level to expert level. It's a mainstream LLM evaluation dataset. We used its [official](https://github.com/hendrycks/test) evaluation approach.
437
+ - [CMMLU](https://github.com/haonan-li/CMMLU) is a comprehensive Chinese evaluation benchmark covering 67 topics, specifically designed to assess language models' knowledge and reasoning capabilities in a Chinese context. We adopted its [official](https://github.com/haonan-li/CMMLU) evaluation approach.
438
+
439
+
440
+ ### Model Results
441
+ **Performance Comparison on Commonsense Reasoning and Aggregated Benchmarks.** For a fair comparison, we report competing methods' results reproduced by us using their released models. PS: parameter size (billion). T: tokens (trillion). HS: HellaSwag. WG: WinoGrande.
442
+
443
+ | Model | PS | T | BoolQ | PIQA | HS | WG | ARC-e | ARC-c | OBQA | MMLU | CMMLU | C-Eval |
444
+ |-------------|------|------|----------------|----------------|----------------|----------------|----------------|----------------|----------------|----------------|----------------|----------------|
445
+ | GPT-J | 6.9 | 0.3 | 65.44 | 75.41 | 66.25 | 64.09 | 66.92 | 36.60 | 38.20 | 25.40 | 26.47 | 23.39 |
446
+ | OPT | 6.7 | 0.3 | 66.18 | 76.22 | 67.21 | 65.19 | 65.66 | 34.64 | 37.20 | 24.57 | 25.36 | 25.32 |
447
+ | Pythia | 6.9 | 0.3 | 63.46 | 75.14 | 63.92 | 60.77 | 67.34 | 35.41 | 37.00 | 24.64 | 25.56 | 26.40 |
448
+ | BLOOM | 7.1 | 0.35 | 62.91 | 72.69 | 62.33 | 64.01 | 65.11 | 33.45 | 35.80 | 26.25 | 24.97 | 24.25 |
449
+ | RWKV | 7.4 | - | - | 76.06 | 65.51 | 61.01 | 67.80 | 37.46 | 40.20 | 24.96 | - | - |
450
+ | MPT | 6.9 | 1.0 | 73.88 | 79.43 | 76.25 | 68.27 | 74.79 | 41.72 | 42.20 | 30.80 | 25.99 | 24.06 |
451
+ | Falcon | 7.2 | 1.5 | 73.73 | 79.38 | 76.3 | 67.17 | 74.62 | 43.60 | 43.80 | 27.79 | 25.73 | 22.92 |
452
+ | Baichuan1 | 7.0 | 1.2 | 70.09 | 76.01 | 70.06 | 64.09 | 71.72 | 40.53 | 38.20 | 42.30 | 44.43 | 42.80 |
453
+ | Baichuan2 | 7.0 | 2.6 | 72.72 | 76.50 | 72.17 | 68.35 | 75.17 | 42.32 | 39.60 | 54.16 | 57.07 | 54.00 |
454
+ | ChatGLM1 | 6.7 | 1.0 | 74.74 | 68.88 | 45.57 | 52.25 | 48.78 | 31.66 | 36.80 | 40.63 | 37.48 | 40.23 |
455
+ | ChatGLM2 | 7.1 | 1.4 | 77.65 | 69.37 | 50.51 | 57.62 | 59.13 | 34.30 | 37.00 | 45.46 | 48.80 | 52.55 |
456
+ | OpenLLaMAv1 | 6.7 | 1.0 | 70.43 | 75.68 | 69.23 | 66.69 | 71.17 | 38.57 | 39.00 | 30.49 | 25.40 | 26.09 |
457
+ | OpenLLaMAv2 | 6.7 | 1.0 | 72.20 | 78.84 | 74.51 | 65.67 | 72.39 | 41.30 | 41.00 | 41.29 | 29.58 | 30.01 |
458
+ | LLaMA1 | 6.7 | 1.0 | 76.50 | 79.80 | 76.10 | 70.10 | 72.80 | 47.60 | 57.20 | 35.10 | 25.62 | 25.72 |
459
+ | LLaMA2 | 6.7 | 2.0 | 77.68 | 78.07 | 76.02 | 68.98 | 76.30 | 46.33 | 44.20 | 45.30 | 32.96 | 33.20 |
460
+ | **Ours** | 6.8 | 1.4 | 75.11 | 85.47 | 78.61 | 66.93 | 73.11 | 52.99 | 61.60 | 44.90 | 49.32 | 45.01 |
461
+
462
+
463
+ # Inference and Deployment
464
+
465
+ The model weights, source code, and configuration needed for inference have been released on Hugging Face. Download links can be found in the table at the beginning of this document. Below, we demonstrate various inference methods using TransNormerLLM-7B-Chat as an example. The program will automatically download the required resources from Hugging Face.
466
+
467
+ ## Dependency Installation
468
+
469
+
470
+ **📝Note** Please configure the following environment before using the model:
471
+
472
+ ```shell
473
+ pip install triton==2.0.0
474
+ pip install einops
475
+ ```
476
+
477
+ ## Notice
478
+ If you encounter errors related to Triton, please set the following environment variables:
479
+ ```
480
+ export use_triton=False
481
+ ```
482
+
483
+
484
+ ## Python Code Inference
485
+
486
+ ### Demonstration of Base Model Inference
487
+
488
+ **📝Note** Kindly utilize the model employing `bfloat16` instead of `float16`.
489
+
490
+ ```python
491
+ >>> from transformers import AutoModelForCausalLM, AutoTokenizer
492
+ >>> tokenizer = AutoTokenizer.from_pretrained("OpenNLPLab/TransNormerLLM-7B", trust_remote_code=True)
493
+ >>> model = AutoModelForCausalLM.from_pretrained("OpenNLPLab/TransNormerLLM-7B", torch_dtype=torch.bfloat16, device_map="auto", trust_remote_code=True)
494
+ >>> inputs = tokenizer('今天是美好的一天', return_tensors='pt')
495
+ >>> pred = model.generate(**inputs, max_new_tokens=4096, repetition_penalty=1.0)
496
+ >>> print(tokenizer.decode(pred.cpu()[0], skip_special_tokens=True))
497
+ ```
498
+
499
+ > In the above code snippets, the model loading specifies `device_map='auto'`, which will use all available GPUs. If you need to specify the device(s) to use, you can control it in a way similar to `export CUDA_VISIBLE_DEVICES=0,1` (using the 0 and 1 graphics cards).
500
+
501
+
502
+ # Fine-tuning the Model
503
+
504
+ ## Dependency Installation
505
+
506
+ ```shell
507
+ git clone https://github.com/OpenNLPLab/TransNormerLLM.git
508
+ cd TransNormerLLM/fine-tune
509
+ pip install -r requirements.txt
510
+ ```
511
+ - To use lightweight fine-tuning methods like LoRA, you must additionally install [peft](https://github.com/huggingface/peft).
512
+
513
+ ## Training
514
+
515
+ Below, we provide an example of fine-tuning the TransNormerLLM-1B on a single machine with ZeRO-3.
516
+
517
+ Training Data: `alpaca_data.json`. This sample data was drawn from [alpaca_data.json](https://raw.githubusercontent.com/tatsu-lab/stanford_alpaca/main/alpaca_data.json), consisting of a selection of 52,002 entries, and has been reformatted. The main purpose is to demonstrate how to SFT our model, and effectiveness is not guaranteed.
518
+
519
+ ```shell
520
+ torchrun \
521
+ --nproc_per_node=8 \
522
+ train.py \
523
+ --model_name_or_path OpenNLPLab/TransNormerLLM-1B \
524
+ --data_path ./alpaca_data.json \
525
+ --output_dir output \
526
+ --num_train_epochs 1 \
527
+ --per_device_train_batch_size 2 \
528
+ --per_device_eval_batch_size 1 \
529
+ --gradient_accumulation_steps 1 \
530
+ --bf16 true \
531
+ --adam_beta1 0.9 \
532
+ --adam_beta2 0.95 \
533
+ --evaluation_strategy "no" \
534
+ --save_strategy "steps" \
535
+ --save_steps 5000 \
536
+ --save_total_limit 30 \
537
+ --learning_rate 1e-4 \
538
+ --weight_decay 0.1 \
539
+ --warmup_ratio 0.1 \
540
+ --lr_scheduler_type "cosine" \
541
+ --deepspeed 'configs/zero3.json' \
542
+ --logging_steps 1 \
543
+ --dataloader_num_workers 24 \
544
+ --ddp_find_unused_parameters false \
545
+ --tf32 true \
546
+ ```
547
+
548
+ # Community and Ecosystem
549
+
550
+ **📢📢📢 We will continuously update the support for TransNormerLLM from the community and ecosystem here 😀😀😀**
551
+ - [nanoTransnormer](https://github.com/Doraemonzzz/nanoTransNormer)
552
+
553
+ # Disclaimer, License and Citation
554
+
555
+ ## Disclaimer
556
+ We hereby declare that our team has not developed any applications based on TransNormerLLM models, not on iOS, Android, the web, or any other platform. We strongly call on all users not to use TransNormerLLM models for any activities that harm national / social security or violate the law. Also, we ask users not to use TransNormerLLM models for Internet services that have not undergone appropriate security reviews and filings. We hope that all users can abide by this principle and ensure that the development of technology proceeds in a regulated and legal environment.
557
+
558
+ We have done our best to ensure the compliance of the data used in the model training process. However, despite our considerable efforts, there may still be some unforeseeable issues due to the complexity of the model and data. Therefore, if any problems arise due to the use of TransNormerLLM open-source models, including but not limited to data security issues, public opinion risks, or any risks and problems brought about by the model being misled, abused, spread or improperly exploited, we will not assume any responsibility.
559
+
560
+ ## License
561
+ The community usage of TransNormerLLM model requires adherence to [Apache 2.0](https://github.com/OpenNLPLab/TransNormerLLM/blob/main/LICENSE) and [Community License for TransNormerLLM Model](https://huggingface.co/OpenNLPLab/TransNormerLLM-1B/blob/main/TransNormerLLM模型社区许可协议.pdf). The TransNormerLLM model supports commercial use. If you plan to use the TransNormerLLM model or its derivatives for commercial purposes, please ensure that your entity meets the following conditions:
562
+
563
+ 1. The Daily Active Users (DAU) of your or your affiliate's service or product is less than 1 million.
564
+ 2. Neither you nor your affiliates are software service providers or cloud service providers.
565
+ 3. There is no possibility for you or your affiliates to grant the commercial license given to you, to reauthorize it to other third parties without TransNormerLLM's permission.
566
+
567
+ Upon meeting the above conditions, you need to submit the application materials required by the TransNormerLLM Model Community License Agreement via the following contact email: opennlplab@gmail.com. Once approved, TransNormerLLM will hereby grant you a non-exclusive, global, non-transferable, non-sublicensable, revocable commercial copyright license.
568
+
569
+ ## Acknowledgments
570
+ Our project is developed based on the following open source projects:
571
+ - [Baichuan](https://github.com/baichuan-inc/Baichuan-7B) for the tokenizer.
572
+ - [metaseq](https://github.com/facebookresearch/metaseq) for training.
573
+ - [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness) for evaluation.
574
+
575
+ ## Citation
576
+ If you wish to cite our work, please use the following reference:
577
+ ```
578
+ @article{qin2023scaling,
579
+ title={Scaling transnormer to 175 billion parameters},
580
+ author={Qin, Zhen and Li, Dong and Sun, Weigao and Sun, Weixuan and Shen, Xuyang and Han, Xiaodong and Wei, Yunshen and Lv, Baohong and Yuan, Fei and Luo, Xiao and others},
581
+ journal={arXiv preprint arXiv:2307.14995},
582
+ year={2023}
583
+ }
584
+ ```