Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
tags:
|
2 |
+
- conversational
|
3 |
+
license: mit
|
4 |
+
|
5 |
+
An generative AI made using [microsoft/DialoGPT-small](https://huggingface.co/microsoft/DialoGPT-small).
|
6 |
+
Trained on:-
|
7 |
+
https://www.kaggle.com/Cornell-University/movie-dialog-corpus
|
8 |
+
|
9 |
+
Example:-
|
10 |
+
from transformers import AutoTokenizer, AutoModelWithLMHead
|
11 |
+
|
12 |
+
tokenizer = AutoTokenizer.from_pretrained("deepparag/DumBot")
|
13 |
+
model = AutoModelWithLMHead.from_pretrained("deepparag/DumBot")
|
14 |
+
# Let's chat for 4 lines
|
15 |
+
for step in range(4):
|
16 |
+
# encode the new user input, add the eos_token and return a tensor in Pytorch
|
17 |
+
new_user_input_ids = tokenizer.encode(input(">> User:") + tokenizer.eos_token, return_tensors='pt')
|
18 |
+
# print(new_user_input_ids)
|
19 |
+
# append the new user input tokens to the chat history
|
20 |
+
bot_input_ids = torch.cat([chat_history_ids, new_user_input_ids], dim=-1) if step > 0 else new_user_input_ids
|
21 |
+
# generated a response while limiting the total chat history to 1000 tokens,
|
22 |
+
chat_history_ids = model.generate(
|
23 |
+
bot_input_ids, max_length=200,
|
24 |
+
pad_token_id=tokenizer.eos_token_id,
|
25 |
+
no_repeat_ngram_size=3,
|
26 |
+
do_sample=True,
|
27 |
+
top_k=100,
|
28 |
+
top_p=0.7,
|
29 |
+
temperature=0.8
|
30 |
+
)
|
31 |
+
|
32 |
+
# pretty print last ouput tokens from bot
|
33 |
+
print("DumBot: {}".format(tokenizer.decode(chat_history_ids[:, bot_input_ids.shape[-1]:][0], skip_special_tokens=True)))
|