Improve language tag
Browse filesHi! As the model is multilingual, this is a PR to add other languages than English to the language tag to improve the referencing. Note that 29 languages are announced in the README, but only 13 are explicitly listed. I was therefore only able to add these 13 languages.
README.md
CHANGED
@@ -1,135 +1,149 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
datasets:
|
4 |
-
- HuggingFaceH4/ultrachat_200k
|
5 |
-
base_model:
|
6 |
-
- Qwen/Qwen2.5-1.5B
|
7 |
-
pipeline_tag: text-generation
|
8 |
-
tags:
|
9 |
-
- trl
|
10 |
-
- qwen
|
11 |
-
- sft
|
12 |
-
- alignment
|
13 |
-
- transformers
|
14 |
-
- custome
|
15 |
-
- chat
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
-
|
23 |
-
-
|
24 |
-
-
|
25 |
-
-
|
26 |
-
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
`
|
46 |
-
`
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- HuggingFaceH4/ultrachat_200k
|
5 |
+
base_model:
|
6 |
+
- Qwen/Qwen2.5-1.5B
|
7 |
+
pipeline_tag: text-generation
|
8 |
+
tags:
|
9 |
+
- trl
|
10 |
+
- qwen
|
11 |
+
- sft
|
12 |
+
- alignment
|
13 |
+
- transformers
|
14 |
+
- custome
|
15 |
+
- chat
|
16 |
+
language:
|
17 |
+
- zho
|
18 |
+
- eng
|
19 |
+
- fra
|
20 |
+
- spa
|
21 |
+
- por
|
22 |
+
- deu
|
23 |
+
- ita
|
24 |
+
- rus
|
25 |
+
- jpn
|
26 |
+
- kor
|
27 |
+
- vie
|
28 |
+
- tha
|
29 |
+
- ara
|
30 |
+
---
|
31 |
+
# Qwen2.5-1.5B-ultrachat200k
|
32 |
+
|
33 |
+
|
34 |
+
## Model Details
|
35 |
+
|
36 |
+
- **Model type:** sft model
|
37 |
+
- **License:** Apache license 2.0
|
38 |
+
- **Finetuned from model:** [Qwen/Qwen2.5-1.5B](https://huggingface.co/Qwen/Qwen2.5-1.5B)
|
39 |
+
- **Training data:** [HuggingFaceH4/ultrachat_200k](https://huggingface.co/datasets/HuggingFaceH4/ultrachat_200k)
|
40 |
+
- **Training framework:** [trl](https://github.com/huggingface/trl)
|
41 |
+
|
42 |
+
## Training Details
|
43 |
+
|
44 |
+
### Training Hyperparameters
|
45 |
+
`attn_implementation`: flash_attention_2 \
|
46 |
+
`bf16`: True \
|
47 |
+
`learning_rate`: 5e-5 \
|
48 |
+
`lr_scheduler_type`: cosine \
|
49 |
+
`per_device_train_batch_size`: 2 \
|
50 |
+
`gradient_accumulation_steps`: 16 \
|
51 |
+
`torch_dtype`: bfloat16 \
|
52 |
+
`num_train_epochs`: 1 \
|
53 |
+
`max_seq_length`: 2048 \
|
54 |
+
`warmup_ratio`: 0.1
|
55 |
+
|
56 |
+
### Results
|
57 |
+
|
58 |
+
`init_train_loss`: 1.421 \
|
59 |
+
`final_train_loss`: 1.192 \
|
60 |
+
`eval_loss`: 1.2003
|
61 |
+
|
62 |
+
### Training script
|
63 |
+
|
64 |
+
```python
|
65 |
+
import multiprocessing
|
66 |
+
|
67 |
+
from datasets import load_dataset
|
68 |
+
from tqdm.rich import tqdm
|
69 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
70 |
+
from trl import (
|
71 |
+
ModelConfig,
|
72 |
+
SFTTrainer,
|
73 |
+
get_peft_config,
|
74 |
+
get_quantization_config,
|
75 |
+
get_kbit_device_map,
|
76 |
+
SFTConfig,
|
77 |
+
ScriptArguments
|
78 |
+
)
|
79 |
+
from trl.commands.cli_utils import TrlParser
|
80 |
+
|
81 |
+
tqdm.pandas()
|
82 |
+
|
83 |
+
if __name__ == "__main__":
|
84 |
+
parser = TrlParser((ScriptArguments, SFTConfig, ModelConfig))
|
85 |
+
args, training_args, model_config = parser.parse_args_and_config()
|
86 |
+
|
87 |
+
quantization_config = get_quantization_config(model_config)
|
88 |
+
model_kwargs = dict(
|
89 |
+
revision=model_config.model_revision,
|
90 |
+
trust_remote_code=model_config.trust_remote_code,
|
91 |
+
attn_implementation=model_config.attn_implementation,
|
92 |
+
torch_dtype=model_config.torch_dtype,
|
93 |
+
use_cache=False if training_args.gradient_checkpointing else True,
|
94 |
+
device_map=get_kbit_device_map() if quantization_config is not None else None,
|
95 |
+
quantization_config=quantization_config,
|
96 |
+
)
|
97 |
+
|
98 |
+
model = AutoModelForCausalLM.from_pretrained(model_config.model_name_or_path,
|
99 |
+
**model_kwargs)
|
100 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
101 |
+
model_config.model_name_or_path, trust_remote_code=model_config.trust_remote_code, use_fast=True
|
102 |
+
)
|
103 |
+
tokenizer.pad_token = tokenizer.eos_token
|
104 |
+
|
105 |
+
train_dataset = load_dataset(args.dataset_name,
|
106 |
+
split=args.dataset_train_split,
|
107 |
+
num_proc=multiprocessing.cpu_count())
|
108 |
+
|
109 |
+
trainer = SFTTrainer(
|
110 |
+
model=model,
|
111 |
+
args=training_args,
|
112 |
+
train_dataset=train_dataset,
|
113 |
+
processing_class=tokenizer,
|
114 |
+
peft_config=get_peft_config(model_config),
|
115 |
+
)
|
116 |
+
|
117 |
+
trainer.train()
|
118 |
+
|
119 |
+
trainer.save_model(training_args.output_dir)
|
120 |
+
```
|
121 |
+
|
122 |
+
### Test Script
|
123 |
+
```python
|
124 |
+
from vllm import LLM
|
125 |
+
from datasets import load_dataset
|
126 |
+
from vllm.sampling_params import SamplingParams
|
127 |
+
from transformers import AutoTokenizer
|
128 |
+
|
129 |
+
MODEL_PATH = "autodl-tmp/saves/Qwen2.5-1.5B-ultrachat200k"
|
130 |
+
|
131 |
+
model = LLM(MODEL_PATH,
|
132 |
+
tensor_parallel_size=1,
|
133 |
+
dtype='bfloat16')
|
134 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
|
135 |
+
|
136 |
+
input = tokenizer.apply_chat_template([{"role": "user", "content": "Which province is Shenyang in?"}],
|
137 |
+
tokenize=False,
|
138 |
+
add_generation_prompt=True)
|
139 |
+
sampling_params = SamplingParams(max_tokens=1024,
|
140 |
+
temperature=0.7,
|
141 |
+
logprobs=1,
|
142 |
+
stop_token_ids=[tokenizer.eos_token_id])
|
143 |
+
|
144 |
+
vllm_generations = model.generate(input,
|
145 |
+
sampling_params)
|
146 |
+
|
147 |
+
print(vllm_generations[0].outputs[0].text)
|
148 |
+
# print result: Shenyang is in Liaoning province, China.
|
149 |
+
```
|