huseinzol05
commited on
Commit
•
f3a6a81
1
Parent(s):
902fa8a
Update README.md
Browse files
README.md
CHANGED
@@ -10,4 +10,41 @@ README at https://github.com/mesolitica/malaya/tree/5.1/pretrained-model/mistral
|
|
10 |
- Dataset gathered at https://github.com/malaysia-ai/dedup-text-dataset/tree/main/pretrain-llm
|
11 |
- We use Ray cluster to train on 5 nodes of 4x A100 80GB, https://github.com/malaysia-ai/jupyter-gpu/tree/main/ray
|
12 |
|
13 |
-
WandB, https://wandb.ai/mesolitica/pretrain-mistral-1.1b?workspace=user-husein-mesolitica
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
- Dataset gathered at https://github.com/malaysia-ai/dedup-text-dataset/tree/main/pretrain-llm
|
11 |
- We use Ray cluster to train on 5 nodes of 4x A100 80GB, https://github.com/malaysia-ai/jupyter-gpu/tree/main/ray
|
12 |
|
13 |
+
WandB, https://wandb.ai/mesolitica/pretrain-mistral-1.1b?workspace=user-husein-mesolitica
|
14 |
+
|
15 |
+
## how-to
|
16 |
+
|
17 |
+
```python
|
18 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
19 |
+
import torch
|
20 |
+
|
21 |
+
TORCH_DTYPE = 'bfloat16'
|
22 |
+
nf4_config = BitsAndBytesConfig(
|
23 |
+
load_in_4bit=True,
|
24 |
+
bnb_4bit_quant_type='nf4',
|
25 |
+
bnb_4bit_use_double_quant=True,
|
26 |
+
bnb_4bit_compute_dtype=getattr(torch, TORCH_DTYPE)
|
27 |
+
)
|
28 |
+
|
29 |
+
tokenizer = AutoTokenizer.from_pretrained('mesolitica/malaysian-mistral-1.1B-4096')
|
30 |
+
model = AutoModelForCausalLM.from_pretrained(
|
31 |
+
'mesolitica/malaysian-mistral-1.1B-4096',
|
32 |
+
use_flash_attention_2 = True,
|
33 |
+
quantization_config = nf4_config
|
34 |
+
)
|
35 |
+
prompt = '<s>nama saya'
|
36 |
+
inputs = tokenizer([prompt], return_tensors='pt', add_special_tokens=False).to('cuda')
|
37 |
+
inputs.pop('token_type_ids')
|
38 |
+
|
39 |
+
generate_kwargs = dict(
|
40 |
+
inputs,
|
41 |
+
max_new_tokens=512,
|
42 |
+
top_p=0.95,
|
43 |
+
top_k=50,
|
44 |
+
temperature=0.9,
|
45 |
+
do_sample=True,
|
46 |
+
num_beams=1,
|
47 |
+
repetition_penalty=1.05,
|
48 |
+
)
|
49 |
+
r = model.generate(**generate_kwargs)
|
50 |
+
```
|