Nick Doiron
commited on
Commit
•
f433ef9
1
Parent(s):
a24bcd5
commit quant model
Browse files- README.md +49 -0
- config.json +46 -0
- merges.txt +0 -0
- pytorch_model.bin +3 -0
- vocab.json +0 -0
README.md
CHANGED
@@ -1,3 +1,52 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
+
language:
|
4 |
+
- ar
|
5 |
+
- hi
|
6 |
+
- id
|
7 |
+
pipeline_tag: text-generation
|
8 |
+
tags:
|
9 |
+
- multilingual
|
10 |
---
|
11 |
+
|
12 |
+
# mGPT-quantized
|
13 |
+
|
14 |
+
The concept: 8-bit quantized version of [mGPT](https://huggingface.co/ai-forever/mGPT), a 1.3B param model released by AI-Forever / Sberbank AI in April 2022.
|
15 |
+
|
16 |
+
On the GPT scale, it is a similar # of parameters to GPT2-XL, but on 60+ languages.
|
17 |
+
|
18 |
+
My goal is to evaluate this on Arabic, Hindi, and Indonesian tasks, where there are fewer autoregressive language models in this size range.
|
19 |
+
|
20 |
+
For English: use a GPT model or LLaMa2-7B
|
21 |
+
|
22 |
+
[AI-Forever](https://huggingface.co/ai-forever) also released a 13B-parameter model, and in August 2023 added 1.3B-param models for about 1/3 of the model languages. If your language is Mongolian, for example, use mGPT-1.3B-mongol and not this one.
|
23 |
+
|
24 |
+
## How was the model created?
|
25 |
+
|
26 |
+
Quantization of mGPT 1.3B was done using `bitsandbytes` library:
|
27 |
+
|
28 |
+
```python
|
29 |
+
from transformers import BitsAndBytesConfig, GPT2LMHeadModel
|
30 |
+
|
31 |
+
quantization_config = BitsAndBytesConfig(
|
32 |
+
load_in_8bit=True,
|
33 |
+
bnb_8bit_compute_dtype=torch.bfloat16,
|
34 |
+
bnb_8bit_use_double_quant=True,
|
35 |
+
bnb_8bit_quant_type="nf4",
|
36 |
+
)
|
37 |
+
|
38 |
+
qmodel = GPT2LMHeadModel.from_pretrained(
|
39 |
+
"ai-forever/mGPT",
|
40 |
+
load_in_8bit=True,
|
41 |
+
torch_dtype=torch.bfloat16,
|
42 |
+
quantization_config=quantization_config,
|
43 |
+
device_map="auto"
|
44 |
+
)
|
45 |
+
|
46 |
+
qmodel.save_pretrained("model_name")
|
47 |
+
```
|
48 |
+
|
49 |
+
## Future steps
|
50 |
+
|
51 |
+
- mGPT could be further quantized (4-bit), but `model.save_pretrained()` currently throws a `NotImplementedError` error.
|
52 |
+
- It would be great to load and quantize the 10x larger mGPT-13B, but that would take more resources.
|
config.json
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "monsoon-nlp/mGPT-quantized",
|
3 |
+
"activation_function": "gelu_new",
|
4 |
+
"architectures": [
|
5 |
+
"GPT2LMHeadModel"
|
6 |
+
],
|
7 |
+
"attn_pdrop": 0.1,
|
8 |
+
"bos_token_id": 50256,
|
9 |
+
"embd_pdrop": 0.1,
|
10 |
+
"eos_token_id": 50256,
|
11 |
+
"gradient_checkpointing": false,
|
12 |
+
"initializer_range": 0.02,
|
13 |
+
"layer_norm_epsilon": 1e-05,
|
14 |
+
"model_type": "gpt2",
|
15 |
+
"n_ctx": 2048,
|
16 |
+
"n_embd": 2048,
|
17 |
+
"n_head": 16,
|
18 |
+
"n_inner": null,
|
19 |
+
"n_layer": 24,
|
20 |
+
"n_positions": 2048,
|
21 |
+
"quantization_config": {
|
22 |
+
"bnb_4bit_compute_dtype": "float32",
|
23 |
+
"bnb_4bit_quant_type": "fp4",
|
24 |
+
"bnb_4bit_use_double_quant": false,
|
25 |
+
"llm_int8_enable_fp32_cpu_offload": false,
|
26 |
+
"llm_int8_has_fp16_weight": false,
|
27 |
+
"llm_int8_skip_modules": null,
|
28 |
+
"llm_int8_threshold": 6.0,
|
29 |
+
"load_in_4bit": false,
|
30 |
+
"load_in_8bit": true,
|
31 |
+
"quant_method": "bitsandbytes"
|
32 |
+
},
|
33 |
+
"reorder_and_upcast_attn": false,
|
34 |
+
"resid_pdrop": 0.1,
|
35 |
+
"scale_attn_by_inverse_layer_idx": false,
|
36 |
+
"scale_attn_weights": true,
|
37 |
+
"summary_activation": null,
|
38 |
+
"summary_first_dropout": 0.1,
|
39 |
+
"summary_proj_to_labels": true,
|
40 |
+
"summary_type": "cls_index",
|
41 |
+
"summary_use_proj": true,
|
42 |
+
"torch_dtype": "bfloat16",
|
43 |
+
"transformers_version": "4.32.1",
|
44 |
+
"use_cache": true,
|
45 |
+
"vocab_size": 100000
|
46 |
+
}
|
merges.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:07db59049df6b63f89851b71726f8f7962c9e1e132c29a08d7cca93f234e0992
|
3 |
+
size 1629130141
|
vocab.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|