Baolin commited on
Commit
04ae2a3
·
1 Parent(s): b038996

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +71 -0
README.md ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ thumbnail: https://huggingface.co/front/thumbnails/dialogpt.png
3
+ tags:
4
+ - conversational
5
+ license: mit
6
+ ---
7
+
8
+ ### Large-Scale Pre-Training for Goal-Directed Dialog (GODEL)
9
+
10
+ GODEL is a large-scale pre-trained model for goal-directed dialogs. It is parameterized with a Transformer-based encoder-decoder model and trained for response generation grounded in external text, which allows more effective fine-tuning on dialog tasks that require conditioning the response on information that is external to the current conversation (e.g., a retrieved document). The pre-trained model can be efficiently fine-tuned and adapted to accomplish a new dialog task with a handful of task-specific dialogs. The v1.1 model is trained on 551M multi-turn dialogs from Reddit discussion thread, and 5M instruction and knowledge grounded dialogs.
11
+
12
+ ##### Multi-turn generation examples from an interactive environment:
13
+ Chitchat example:
14
+ > Instruction: given a dialog context, you need to response empathically. <br>
15
+ > User: Does money buy happiness? <br>
16
+ > Agent: It is a question. Money buys you a lot of things, but not enough to buy happiness. <br>
17
+ > User: What is the best way to buy happiness ? <br>
18
+ > Agent: Happiness is bought through your experience and not money. <br>
19
+
20
+ Grounded response generation example:
21
+ > Instruction: given a dialog context and related knowledge, you need to response safely based on the knowledge. <br>
22
+ > Knowledge: The best Stardew Valley mods PCGamesN_0 / About SMAPI <br>
23
+ > User: My favorite game is stardew valley. stardew valley is very fun. <br>
24
+ > Agent: I love Stardew Valley mods, like PCGamesN_0 / About SMAPI. <br>
25
+
26
+ Please find the information about preprocessing, training and full details of the GODEL in the [project webpage](https://aka.ms/GODEL).
27
+
28
+ ArXiv paper: [https://arxiv.org/abs/2206.11309](https://arxiv.org/abs/2206.11309)
29
+
30
+ ### How to use
31
+
32
+ Now we are ready to try out how the model works as a chatting partner!
33
+
34
+ ```python
35
+ from transformers import AutoTokenizer,AutoModel
36
+ tokenizer = AutoTokenizer.from_pretrained("microsoft/GODEL-v1_1-large-seq2seq")
37
+ model = AutoModelForSeq2SeqLM.from_pretrained("microsoft/GODEL-v1_1-large-seq2seq")
38
+ def generate(instruction, knowledge, dialog):
39
+ if knowledge != '':
40
+ knowledge = '[KNOWLEDGE] ' + knowledge
41
+ dialog = ' EOS '.join(dialog)
42
+ query = f"{instruction} [CONTEXT] {dialog} {knowledge}"
43
+ input_ids = tokenizer(f"{query}", return_tensors="pt").input_ids
44
+ outputs = model.generate(input_ids, max_length=128, min_length=8, top_p=0.9, do_sample=True)
45
+ output = tokenizer.decode(outputs[0], skip_special_tokens=True)
46
+ return output
47
+ # Instruction for a chitchat task
48
+ instruction = f'Instruction: given a dialog context, you need to response empathically.'
49
+ # Leave the knowldge empty
50
+ knowledge = ''
51
+ dialog = [
52
+ 'Does money buy happiness?',
53
+ 'It is a question. Money buys you a lot of things, but not enough to buy happiness.',
54
+ 'What is the best way to buy happiness ?'
55
+ ]
56
+ response = generate(instruction, knowledge, dialog)
57
+ print(response)
58
+ ```
59
+
60
+ ### Citation
61
+ if you use this code and data in your research, please cite our arxiv paper:
62
+ ```
63
+ @misc{peng2022godel,
64
+ author = {Peng, Baolin and Galley, Michel and He, Pengcheng and Brockett, Chris and Liden, Lars and Nouri, Elnaz and Yu, Zhou and Dolan, Bill and Gao, Jianfeng},
65
+ title = {GODEL: Large-Scale Pre-training for Goal-Directed Dialog},
66
+ howpublished = {arXiv},
67
+ year = {2022},
68
+ month = {June},
69
+ url = {https://www.microsoft.com/en-us/research/publication/godel-large-scale-pre-training-for-goal-directed-dialog/},
70
+ }
71
+ ```