Update README.md
Browse files
README.md
CHANGED
@@ -6,4 +6,34 @@ language:
|
|
6 |
- en
|
7 |
---
|
8 |
Basic Dialog Model from DialoGPT-small.
|
9 |
-
Finetuned on Daily Dialog dataset.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
- en
|
7 |
---
|
8 |
Basic Dialog Model from DialoGPT-small.
|
9 |
+
Finetuned on Daily Dialog dataset.
|
10 |
+
|
11 |
+
### How to use
|
12 |
+
|
13 |
+
Use it as any torch python Language Model
|
14 |
+
|
15 |
+
```python
|
16 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
17 |
+
import torch
|
18 |
+
|
19 |
+
tokenizer = AutoTokenizer.from_pretrained("gpt")
|
20 |
+
model = AutoModelForCausalLM.from_pretrained("jinymusim/dialogmodel")
|
21 |
+
|
22 |
+
# Take user Input
|
23 |
+
user_utterance = input('USER> ')
|
24 |
+
user_utterance = user_utterance.strip()
|
25 |
+
tokenized_context = tokenizer.encode(user_utterance + tokenizer.eos_token, return_tensors='pt')
|
26 |
+
|
27 |
+
# generated a response, limit max_lenght to resonable size
|
28 |
+
out_response = model.generate(tokenized_context,
|
29 |
+
max_length=30,
|
30 |
+
num_beams=2,
|
31 |
+
no_repeat_ngram_size=2,
|
32 |
+
early_stopping=True,
|
33 |
+
pad_token_id=self.tokenizer.eos_token_id)
|
34 |
+
|
35 |
+
# Truncate User Input
|
36 |
+
decoded_response = self.tokenizer.decode(out_response[0], skip_special_tokens=True)[len(user_utterance):]
|
37 |
+
|
38 |
+
print(f'SYSTEM> {decoded_response}')
|
39 |
+
```
|