CoderEFE commited on
Commit
242b77e
1 Parent(s): a5e7a77

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +32 -0
README.md CHANGED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - conversational
4
+ ---
5
+
6
+ Chat with the model:
7
+ ```python
8
+ from transformers import AutoTokenizer, AutoModelWithLMHead
9
+
10
+ tokenizer = AutoTokenizer.from_pretrained("r3dhummingbird/DialoGPT-marxbot")
11
+ model = AutoModelWithLMHead.from_pretrained("r3dhummingbird/DialoGPT-marxbot")
12
+ # Let's chat for 4 lines
13
+ for step in range(4):
14
+ # encode the new user input, add the eos_token and return a tensor in Pytorch
15
+ new_user_input_ids = tokenizer.encode(input(">> User:") + tokenizer.eos_token, return_tensors='pt')
16
+ # print(new_user_input_ids)
17
+ # append the new user input tokens to the chat history
18
+ bot_input_ids = torch.cat([chat_history_ids, new_user_input_ids], dim=-1) if step > 0 else new_user_input_ids
19
+ # generated a response while limiting the total chat history to 1000 tokens,
20
+ chat_history_ids = model.generate(
21
+ bot_input_ids, max_length=200,
22
+ pad_token_id=tokenizer.eos_token_id,
23
+ no_repeat_ngram_size=3,
24
+ do_sample=True,
25
+ top_k=100,
26
+ top_p=0.7,
27
+ temperature=0.8
28
+ )
29
+
30
+ # pretty print last ouput tokens from bot
31
+ print("MarxBot: {}".format(tokenizer.decode(chat_history_ids[:, bot_input_ids.shape[-1]:][0], skip_special_tokens=True)))
32
+ ```