init
Browse files- .gitattributes +1 -0
- README.md +136 -0
- config.json +32 -0
- generation_config.json +7 -0
- model.safetensors +3 -0
- optimizer.pt +3 -0
- rng_state.pth +3 -0
- scheduler.pt +3 -0
- special_tokens_map.json +24 -0
- tokenizer.json +3 -0
- tokenizer_config.json +49 -0
- trainer_state.json +0 -0
- training_args.bin +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DPO Chinese Error Correction Model
|
| 2 |
+
使用DPO訓練之中文糾錯模型。
|
| 3 |
+
|
| 4 |
+
### Usage
|
| 5 |
+
```python
|
| 6 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, LlamaForCausalLM,AddedToken
|
| 7 |
+
import sys
|
| 8 |
+
|
| 9 |
+
mode_id = "p208p2002/bloom-1b1-zh-error-correction-dpo"
|
| 10 |
+
model: LlamaForCausalLM = AutoModelForCausalLM.from_pretrained("p208p2002/bloom-1b1-zh-error-correction-dpo")
|
| 11 |
+
tokenizer = AutoTokenizer.from_pretrained("p208p2002/bloom-1b1-zh-error-correction-dpo")
|
| 12 |
+
|
| 13 |
+
test_texts = [
|
| 14 |
+
"為了潔約能源請隨守關閉沒有使用的電器",
|
| 15 |
+
"今天新情很好",
|
| 16 |
+
"你快樂我也很高心",
|
| 17 |
+
"但不再算再找實習生了",
|
| 18 |
+
"今天太陽很大要注意篩傷",
|
| 19 |
+
"你要不要和我依起去台北",
|
| 20 |
+
"清晨六點終太陽會升起",
|
| 21 |
+
"傾城六點鐘太陽會升起",
|
| 22 |
+
"鍋馬路時你應該要注意虹綠燈",
|
| 23 |
+
"他正在學學彈吉他",
|
| 24 |
+
"下樓梯請注意階梯",
|
| 25 |
+
"此信件為系統自動發送之通知",
|
| 26 |
+
"此信件為系統自動發送知通知",
|
| 27 |
+
"如為誤傳也請立即刪除本郵件並通知寄件者"
|
| 28 |
+
]
|
| 29 |
+
for text in test_texts:
|
| 30 |
+
inputs = tokenizer(
|
| 31 |
+
f"{tokenizer.bos_token}{text} {tokenizer.eos_token}\n {tokenizer.bos_token}",
|
| 32 |
+
return_tensors="pt",
|
| 33 |
+
add_special_tokens=False
|
| 34 |
+
)["input_ids"]
|
| 35 |
+
|
| 36 |
+
out = model.generate(
|
| 37 |
+
inputs,
|
| 38 |
+
max_new_tokens=20,
|
| 39 |
+
)
|
| 40 |
+
decode_out = tokenizer.decode(out[0])
|
| 41 |
+
|
| 42 |
+
input_text,output_text = decode_out.split("\n")
|
| 43 |
+
input_text = input_text.strip()
|
| 44 |
+
output_text = output_text.strip()
|
| 45 |
+
|
| 46 |
+
print("input :",input_text)
|
| 47 |
+
print("output:",output_text)
|
| 48 |
+
print('-'*30)
|
| 49 |
+
```
|
| 50 |
+
```
|
| 51 |
+
input: <s>為了潔約能源請隨守關閉沒有使用的電器 </s>
|
| 52 |
+
output: <s>為了節約能源請隨時關閉沒有使用的電器 </s>
|
| 53 |
+
------------------------------
|
| 54 |
+
input: <s>今天新情很好 </s>
|
| 55 |
+
output: <s>今天心情很好 </s>
|
| 56 |
+
------------------------------
|
| 57 |
+
input: <s>你快樂我也很高心 </s>
|
| 58 |
+
output: <s>你快樂我也很高興 </s>
|
| 59 |
+
------------------------------
|
| 60 |
+
input: <s>但不再算再找實習生了 </s>
|
| 61 |
+
output: <s>但不再去找實習生了 </s>
|
| 62 |
+
------------------------------
|
| 63 |
+
input: <s>今天太陽很大要注意篩傷 </s>
|
| 64 |
+
output: <s>今天太陽很大要注意一下 </s>
|
| 65 |
+
------------------------------
|
| 66 |
+
input: <s>你要不要和我依起去台北 </s>
|
| 67 |
+
output: <s>你要不要和我一起去台北 </s>
|
| 68 |
+
------------------------------
|
| 69 |
+
input: <s>清晨六點終太陽會升起 </s>
|
| 70 |
+
output: <s>清晨六點鐘太陽會升起 </s>
|
| 71 |
+
------------------------------
|
| 72 |
+
input: <s>傾城六點鐘太陽會升起 </s>
|
| 73 |
+
output: <s>凌晨六點鐘太陽會升起 </s>
|
| 74 |
+
------------------------------
|
| 75 |
+
input: <s>鍋馬路時你應該要注意虹綠燈 </s>
|
| 76 |
+
output: <s>過馬路時你應該要注意紅綠燈 </s>
|
| 77 |
+
------------------------------
|
| 78 |
+
input: <s>他正在學學彈吉他 </s>
|
| 79 |
+
output: <s>他正在學習彈吉他 </s>
|
| 80 |
+
------------------------------
|
| 81 |
+
input: <s>下樓梯請注意階梯 </s>
|
| 82 |
+
output: <s>下樓梯請注意階梯 </s>
|
| 83 |
+
------------------------------
|
| 84 |
+
input: <s>此信件為系統自動發送之通知 </s>
|
| 85 |
+
output: <s>此信件為系統自動發送之通知 </s>
|
| 86 |
+
------------------------------
|
| 87 |
+
input: <s>此信件為系統自動發送知通知 </s>
|
| 88 |
+
output: <s>此信件為系統自動發送通知 </s>
|
| 89 |
+
------------------------------
|
| 90 |
+
input: <s>如為誤傳也請立即刪除本郵件並通知寄件者 </s>
|
| 91 |
+
output: <s>如為誤傳也請立即刪除本郵件並通知寄件者 </s>
|
| 92 |
+
------------------------------
|
| 93 |
+
(venv) philip@nca100-3-G1:~/ec-dpo$ python test_model.py dpo_trainer/checkpoint-250
|
| 94 |
+
input : <s>為了潔約能源請隨守關閉沒有使用的電器 </s>
|
| 95 |
+
output: <s>為了節約能源請隨時關閉沒有使用的電器 </s>
|
| 96 |
+
------------------------------
|
| 97 |
+
input : <s>今天新情很好 </s>
|
| 98 |
+
output: <s>今天心情很好 </s>
|
| 99 |
+
------------------------------
|
| 100 |
+
input : <s>你快樂我也很高心 </s>
|
| 101 |
+
output: <s>你快樂我也很高興 </s>
|
| 102 |
+
------------------------------
|
| 103 |
+
input : <s>但不再算再找實習生了 </s>
|
| 104 |
+
output: <s>但不再去找實習生了 </s>
|
| 105 |
+
------------------------------
|
| 106 |
+
input : <s>今天太陽很大要注意篩傷 </s>
|
| 107 |
+
output: <s>今天太陽很大要注意一下 </s>
|
| 108 |
+
------------------------------
|
| 109 |
+
input : <s>你要不要和我依起去台北 </s>
|
| 110 |
+
output: <s>你要不要和我一起去台北 </s>
|
| 111 |
+
------------------------------
|
| 112 |
+
input : <s>清晨六點終太陽會升起 </s>
|
| 113 |
+
output: <s>清晨六點鐘太陽會升起 </s>
|
| 114 |
+
------------------------------
|
| 115 |
+
input : <s>傾城六點鐘太陽會升起 </s>
|
| 116 |
+
output: <s>凌晨六點鐘太陽會升起 </s>
|
| 117 |
+
------------------------------
|
| 118 |
+
input : <s>鍋馬路時你應該要注意虹綠燈 </s>
|
| 119 |
+
output: <s>過馬路時你應該要注意紅綠燈 </s>
|
| 120 |
+
------------------------------
|
| 121 |
+
input : <s>他正在學學彈吉他 </s>
|
| 122 |
+
output: <s>他正在學習彈吉他 </s>
|
| 123 |
+
------------------------------
|
| 124 |
+
input : <s>下樓梯請注意階梯 </s>
|
| 125 |
+
output: <s>下樓梯請注意階梯 </s>
|
| 126 |
+
------------------------------
|
| 127 |
+
input : <s>此信件為系統自動發送之通知 </s>
|
| 128 |
+
output: <s>此信件為系統自動發送之通知 </s>
|
| 129 |
+
------------------------------
|
| 130 |
+
input : <s>此信件為系統自動發送知通知 </s>
|
| 131 |
+
output: <s>此信件為系統自動發送通知 </s>
|
| 132 |
+
------------------------------
|
| 133 |
+
input : <s>如為誤傳也請立即刪除本郵件並通知寄件者 </s>
|
| 134 |
+
output: <s>如為誤傳也請立即刪除本郵件並通知寄件者 </s>
|
| 135 |
+
------------------------------
|
| 136 |
+
```
|
config.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "sft_trainer/checkpoint-4500/",
|
| 3 |
+
"apply_residual_connection_post_layernorm": false,
|
| 4 |
+
"architectures": [
|
| 5 |
+
"BloomForCausalLM"
|
| 6 |
+
],
|
| 7 |
+
"attention_dropout": 0.0,
|
| 8 |
+
"attention_softmax_in_fp32": true,
|
| 9 |
+
"bias_dropout_fusion": true,
|
| 10 |
+
"bos_token_id": 1,
|
| 11 |
+
"eos_token_id": 2,
|
| 12 |
+
"hidden_dropout": 0.0,
|
| 13 |
+
"hidden_size": 1536,
|
| 14 |
+
"initializer_range": 0.02,
|
| 15 |
+
"layer_norm_epsilon": 1e-05,
|
| 16 |
+
"masked_softmax_fusion": true,
|
| 17 |
+
"model_type": "bloom",
|
| 18 |
+
"n_head": 16,
|
| 19 |
+
"n_inner": null,
|
| 20 |
+
"n_layer": 24,
|
| 21 |
+
"offset_alibi": 100,
|
| 22 |
+
"pad_token_id": 3,
|
| 23 |
+
"pretraining_tp": 1,
|
| 24 |
+
"skip_bias_add": true,
|
| 25 |
+
"skip_bias_add_qkv": false,
|
| 26 |
+
"slow_but_exact": false,
|
| 27 |
+
"torch_dtype": "float32",
|
| 28 |
+
"transformers_version": "4.37.2",
|
| 29 |
+
"unk_token_id": 0,
|
| 30 |
+
"use_cache": true,
|
| 31 |
+
"vocab_size": 250880
|
| 32 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 1,
|
| 4 |
+
"eos_token_id": 2,
|
| 5 |
+
"pad_token_id": 3,
|
| 6 |
+
"transformers_version": "4.37.2"
|
| 7 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2a4d934b57e15c85fabeee1c80fc1ba3fb58d9bd959865a102d1fedd35b0ebcd
|
| 3 |
+
size 4261291440
|
optimizer.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2e82e1971b8b37f9437ead50ede64293d81ecf954e006d50246065f3b12a49f5
|
| 3 |
+
size 8522768386
|
rng_state.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1ff264f99d31b522cc7e2a4eac9d38606d0c58a34c0adc74d71e0ca8b371dc36
|
| 3 |
+
size 14244
|
scheduler.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6f3ec4f70580d870f44b786edc3a8bc0395e2f10d51f478622a7a57d30160892
|
| 3 |
+
size 1064
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": {
|
| 3 |
+
"content": "<s>",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": false,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"eos_token": {
|
| 10 |
+
"content": "</s>",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"pad_token": "</s>",
|
| 17 |
+
"unk_token": {
|
| 18 |
+
"content": "<unk>",
|
| 19 |
+
"lstrip": false,
|
| 20 |
+
"normalized": false,
|
| 21 |
+
"rstrip": false,
|
| 22 |
+
"single_word": false
|
| 23 |
+
}
|
| 24 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:17a208233d2ee8d8c83b23bc214df737c44806a1919f444e89b31e586cd956ba
|
| 3 |
+
size 14500471
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"added_tokens_decoder": {
|
| 4 |
+
"0": {
|
| 5 |
+
"content": "<unk>",
|
| 6 |
+
"lstrip": false,
|
| 7 |
+
"normalized": false,
|
| 8 |
+
"rstrip": false,
|
| 9 |
+
"single_word": false,
|
| 10 |
+
"special": true
|
| 11 |
+
},
|
| 12 |
+
"1": {
|
| 13 |
+
"content": "<s>",
|
| 14 |
+
"lstrip": false,
|
| 15 |
+
"normalized": false,
|
| 16 |
+
"rstrip": false,
|
| 17 |
+
"single_word": false,
|
| 18 |
+
"special": true
|
| 19 |
+
},
|
| 20 |
+
"2": {
|
| 21 |
+
"content": "</s>",
|
| 22 |
+
"lstrip": false,
|
| 23 |
+
"normalized": false,
|
| 24 |
+
"rstrip": false,
|
| 25 |
+
"single_word": false,
|
| 26 |
+
"special": true
|
| 27 |
+
},
|
| 28 |
+
"3": {
|
| 29 |
+
"content": "<pad>",
|
| 30 |
+
"lstrip": false,
|
| 31 |
+
"normalized": false,
|
| 32 |
+
"rstrip": false,
|
| 33 |
+
"single_word": false,
|
| 34 |
+
"special": true
|
| 35 |
+
}
|
| 36 |
+
},
|
| 37 |
+
"bos_token": "<s>",
|
| 38 |
+
"clean_up_tokenization_spaces": false,
|
| 39 |
+
"eos_token": "</s>",
|
| 40 |
+
"max_length": 256,
|
| 41 |
+
"model_max_length": 1000000000000000019884624838656,
|
| 42 |
+
"pad_token": "</s>",
|
| 43 |
+
"padding_side": "right",
|
| 44 |
+
"stride": 0,
|
| 45 |
+
"tokenizer_class": "BloomTokenizer",
|
| 46 |
+
"truncation_side": "right",
|
| 47 |
+
"truncation_strategy": "longest_first",
|
| 48 |
+
"unk_token": "<unk>"
|
| 49 |
+
}
|
trainer_state.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9299d7ea4fb442144a1ab68d137cae8b85e61eaf3c86b5bdbffc30c723e505cf
|
| 3 |
+
size 4664
|