Improve language tag (#1)
Browse files- Improve language tag (f62d13f6a9c0c132ca3c61260309e4a398264e0c)
Co-authored-by: Loïck BOURDOIS <[email protected]>
README.md
CHANGED
@@ -1,88 +1,100 @@
|
|
1 |
-
---
|
2 |
-
license: mit
|
3 |
-
language:
|
4 |
-
-
|
5 |
-
|
6 |
-
-
|
7 |
-
|
8 |
-
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
model
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
language:
|
4 |
+
- zho
|
5 |
+
- eng
|
6 |
+
- fra
|
7 |
+
- spa
|
8 |
+
- por
|
9 |
+
- deu
|
10 |
+
- ita
|
11 |
+
- rus
|
12 |
+
- jpn
|
13 |
+
- kor
|
14 |
+
- vie
|
15 |
+
- tha
|
16 |
+
- ara
|
17 |
+
base_model:
|
18 |
+
- Qwen/Qwen2.5-7B-Instruct
|
19 |
+
tags:
|
20 |
+
- medical
|
21 |
+
---
|
22 |
+
|
23 |
+
## Model Details
|
24 |
+
This model has been LoRA‑fine‑tuned on Qwen2.5‑7B‑Instruct.
|
25 |
+
In the future, reinforcement learning training may be carried out based on this model, such as DPRO algorithm, etc.
|
26 |
+
|
27 |
+
|
28 |
+
### Base Model Sources [optional]
|
29 |
+
|
30 |
+
https://huggingface.co/Qwen/Qwen2.5-7B-Instruct
|
31 |
+
|
32 |
+
## How to Get Started with the Model
|
33 |
+
```python
|
34 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
35 |
+
model_name = "ggbaobao/medc_llm_based_on_qwen2.5"
|
36 |
+
model = AutoModelForCausalLM.from_pretrained(
|
37 |
+
model_name,
|
38 |
+
device_map="auto",
|
39 |
+
torch_dtype=torch.bfloat16
|
40 |
+
)
|
41 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
42 |
+
prompt = "猩红热多在发热后多久出现皮疹,请从以下选项中选择:12小时之内, 12~48小时, 60~72小时, 84~96小时, 大于96小时"
|
43 |
+
messages = [
|
44 |
+
{"role": "system", "content": "You are Qwen, You are a helpful assistant."},
|
45 |
+
{"role": "user", "content": prompt},
|
46 |
+
]
|
47 |
+
text = tokenizer.apply_chat_template(
|
48 |
+
messages,
|
49 |
+
tokenize=False,
|
50 |
+
add_generation_prompt=True
|
51 |
+
)
|
52 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
53 |
+
|
54 |
+
generated_ids = model.generate(
|
55 |
+
**model_inputs,
|
56 |
+
max_new_tokens=512,
|
57 |
+
do_sample=True
|
58 |
+
)
|
59 |
+
generated_ids = [output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)]
|
60 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
61 |
+
|
62 |
+
print(response)
|
63 |
+
```
|
64 |
+
## Training Details
|
65 |
+
```python
|
66 |
+
lora_config = LoraConfig(
|
67 |
+
r=16,
|
68 |
+
lora_alpha=32,
|
69 |
+
target_modules=["q_proj", "v_proj"],
|
70 |
+
lora_dropout=0.1
|
71 |
+
)
|
72 |
+
|
73 |
+
training_args = TrainingArguments(
|
74 |
+
output_dir="./results_final1",
|
75 |
+
learning_rate=7e-5,
|
76 |
+
per_device_train_batch_size=2,
|
77 |
+
per_device_eval_batch_size=2,
|
78 |
+
gradient_accumulation_steps=1, # 梯度累积
|
79 |
+
num_train_epochs=2,
|
80 |
+
evaluation_strategy="steps",
|
81 |
+
# evaluate_steps=1,
|
82 |
+
save_strategy="steps",
|
83 |
+
save_steps=10,
|
84 |
+
logging_steps=10,
|
85 |
+
logging_dir="./logs1",
|
86 |
+
bf16=True, # 混合精度训练
|
87 |
+
```
|
88 |
+
### Training Data
|
89 |
+
|
90 |
+
The training data comes from https://github.com/SupritYoung/Zhongjing
|
91 |
+
If you want to know more details about the above github project, you can also read their paper:
|
92 |
+
Zhongjing: Enhancing the Chinese Medical Capabilities of Large Language Model through Expert Feedback and Real-world Multi-turn Dialogue
|
93 |
+
|
94 |
+
The data includes about one-seventh of the multi-round medical consultation data and six-sevenths of the single medical consultation data.
|
95 |
+
|
96 |
+
#### Hardware
|
97 |
+
vGPU-32GB * 6
|
98 |
+
|
99 |
+
#### Software
|
100 |
+
use peft and deepspeed
|