feat: init
Browse files- .gitattributes +0 -8
- README.md +39 -0
- config.json +30 -0
- merges.txt +0 -0
- pytorch_model.bin +3 -0
- tokenizer_config.json +1 -0
- vocab.json +0 -0
.gitattributes
CHANGED
@@ -6,12 +6,4 @@
|
|
6 |
*.tar.gz filter=lfs diff=lfs merge=lfs -text
|
7 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
8 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
9 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
10 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
11 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
15 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
16 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
17 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
6 |
*.tar.gz filter=lfs diff=lfs merge=lfs -text
|
7 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
8 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
9 |
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
README.md
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language: zh
|
3 |
+
widget:
|
4 |
+
- text: "谁用谁知道?"
|
5 |
+
license: apache-2.0
|
6 |
+
---
|
7 |
+
|
8 |
+
# liam168/chat-DialoGPT-small-zh
|
9 |
+
|
10 |
+
## Model description
|
11 |
+
|
12 |
+
用中文聊天数据训练的模型;
|
13 |
+
|
14 |
+
### How to use
|
15 |
+
|
16 |
+
Now we are ready to try out how the model works as a chatting partner!
|
17 |
+
|
18 |
+
```python
|
19 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
20 |
+
import torch
|
21 |
+
|
22 |
+
mode_name = 'liam168/chat-DialoGPT-small-zh'
|
23 |
+
tokenizer = AutoTokenizer.from_pretrained(mode_name)
|
24 |
+
model = AutoModelForCausalLM.from_pretrained(mode_name)
|
25 |
+
|
26 |
+
# Let's chat for 5 lines
|
27 |
+
for step in range(5):
|
28 |
+
# encode the new user input, add the eos_token and return a tensor in Pytorch
|
29 |
+
new_user_input_ids = tokenizer.encode(input(">> User:") + tokenizer.eos_token, return_tensors='pt')
|
30 |
+
|
31 |
+
# append the new user input tokens to the chat history
|
32 |
+
bot_input_ids = torch.cat([chat_history_ids, new_user_input_ids], dim=-1) if step > 0 else new_user_input_ids
|
33 |
+
|
34 |
+
# generated a response while limiting the total chat history to 1000 tokens,
|
35 |
+
chat_history_ids = model.generate(bot_input_ids, max_length=1000, pad_token_id=tokenizer.eos_token_id)
|
36 |
+
|
37 |
+
# pretty print last ouput tokens from bot
|
38 |
+
print("Answer: {}".format(tokenizer.decode(chat_history_ids[:, bot_input_ids.shape[-1]:][0], skip_special_tokens=True)))
|
39 |
+
```
|
config.json
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"activation_function": "gelu_new",
|
3 |
+
"architectures": [
|
4 |
+
"GPT2LMHeadModel"
|
5 |
+
],
|
6 |
+
"attn_pdrop": 0.1,
|
7 |
+
"bos_token_id": 50256,
|
8 |
+
"embd_pdrop": 0.1,
|
9 |
+
"eos_token_id": 50256,
|
10 |
+
"initializer_range": 0.02,
|
11 |
+
"layer_norm_epsilon": 1e-05,
|
12 |
+
"model_type": "gpt2",
|
13 |
+
"n_ctx": 1024,
|
14 |
+
"n_embd": 768,
|
15 |
+
"n_head": 12,
|
16 |
+
"n_layer": 12,
|
17 |
+
"n_positions": 1024,
|
18 |
+
"resid_pdrop": 0.1,
|
19 |
+
"summary_activation": null,
|
20 |
+
"summary_first_dropout": 0.1,
|
21 |
+
"summary_proj_to_labels": true,
|
22 |
+
"summary_type": "cls_index",
|
23 |
+
"summary_use_proj": true,
|
24 |
+
"task_specific_params": {
|
25 |
+
"conversational": {
|
26 |
+
"max_length": 1000
|
27 |
+
}
|
28 |
+
},
|
29 |
+
"vocab_size": 50257
|
30 |
+
}
|
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:e6e2be6d12f77bf925a89f2381c6c685f4739752289039d590622d37d48a153d
|
3 |
+
size 351265583
|
tokenizer_config.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"model_max_length": 1024}
|
vocab.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|