tokudai commited on
Commit
41e1053
1 Parent(s): fa51161

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -48
app.py CHANGED
@@ -10,52 +10,52 @@ from transformers import (
10
  tokenizer = AutoTokenizer.from_pretrained("microsoft/GODEL-v1_1-base-seq2seq")
11
  model = AutoModelForSeq2SeqLM.from_pretrained("microsoft/GODEL-v1_1-base-seq2seq")
12
 
13
- preset_examples = [
14
- ('Instruction: given a dialog context, you need to response empathically.',
15
- '', 'Does money buy happiness?', 'Chitchat'),
16
- ('Instruction: given a dialog context, you need to response empathically.',
17
- '', 'What is the goal of life?', 'Chitchat'),
18
- ('Instruction: given a dialog context, you need to response empathically.',
19
- '', 'What is the most interesing thing about our universe?', 'Chitchat'),
20
- ('Instruction: given a dialog context and related knowledge, you need to answer the question based on the knowledge.',
21
- '''Scooby-Doo is the eponymous character and protagonist of the animated television franchise of the same name, created in 1969 by the American animation company Hanna-Barbera.[1] He is a male Great Dane and lifelong companion of amateur detective Shaggy Rogers, with whom he shares many personality traits. He features a mix of both canine and human behaviors (reminiscent of other talking animals in Hanna-Barbera's series), and is treated by his friends more or less as an equal. Scooby often speaks in a rhotacized way, substituting the first letters of many words with the letter 'r'. His catchphrase is "Scooby-Dooby-Doo!"
22
- ''',
23
- 'What kind of animal is scooby from scooby doo?', 'Conversational Question Answering'
24
- ),
25
- ('Instruction: given a dialog context and related knowledge, you need to answer the question based on the knowledge.',
26
- '''Subject: faa demos
27
- Dan: PM Team, Attached are some general ideas and issues around developing new demos for our new target markets. Please review and provide feedback. Also, please provide links where we can learn more about various FAA applications. Thanx, Dan.
28
- Alex: Dan, Thanks for putting the high level descriptions together. My questions are: *Is it practical to do an EAI demo given the inherent complexity of application integration? ... * Should we delay looking at Outlook for now?... *What do you think that timelines are developing these demos? ... Alex
29
- Dan: Alex, Thanks for the feedback, please see my comments below:
30
- ''',
31
- 'what does Dan ask PM team to do?', 'Conversational Question Answering'
32
- ),
33
- ('Instruction: given a dialog context and related knowledge, you need to answer the question based on the knowledge.',
34
- '''Carlos Alcaraz, at just 19, completed an improbable journey on Sunday in Flushing Meadows as he defeated No. 5 Casper Ruud to win the 2022 US Open. Alcaraz came away with a 6-4, 2-6, 7-6, 6-2 win over Ruud to win his first career Grand Slam title.
35
 
36
- In doing so, Alcaraz became the second-youngest player to win a men's US Open title at 19 years, 129 days old, only trailing Pete Sampras. In addition, Alcaraz is the seventh youngest male or female to ever win a Grand Slam tournament. With the Grand Slam victory, Alcaraz becomes the No. 1 ranked player in the world. Additionally, the 19-year-old budding star is also the youngest player to ever be ranked as the world's No. 1 player.
37
- ''',
38
- 'who won the 2022 US Open? EOS Carlos Alcaraz EOS how old?', 'Conversational Question Answering'
39
- ),
40
- (
41
- 'Instruction: given a dialog context and related knowledge, you need to response safely based on the knowledge.',
42
- '''Over-the-counter medications such as ibuprofen (Advil, Motrin IB, others), acetaminophen (Tylenol, others) and aspirin.
43
- ''',
44
- 'I have a headache, what should I do?', "Grounded Response Generation"
45
- ),
46
- (
47
- 'Instruction: given a dialog context and related knowledge, you need to response safely based on the knowledge.',
48
- '''The best Stardew Valley mods PCGamesN_0 / About SMAPI
49
- ''',
50
- 'My favorite game is stardew valley. stardew valley is very fun.', "Grounded Response Generation"
51
- ),
52
- (
53
- 'Instruction: given a dialog context and related knowledge, you need to response safely based on the knowledge.',
54
- '''Wong Kar-wai BBS (born 17 July 1958) is a Hong Kong film director, screenwriter, and producer. His films are characterised by nonlinear narratives, atmospheric music, and vivid cinematography involving bold, saturated colours. A pivotal figure of Hong Kong cinema, Wong is considered a contemporary auteur, and ranks third on Sight & Sound's 2002 poll of the greatest filmmakers of modern times.[note 1] His films frequently appear on best-of lists domestically and internationally.
55
- ''',
56
- 'My favorite director is wrong kar wai. i think in modern cinema there is no other director is is making the medium as cool', "Grounded Response Generation"
57
- )
58
- ]
59
 
60
 
61
  def generate(instruction, knowledge, dialog, top_p, min_length, max_length):
@@ -104,11 +104,14 @@ with gr.Blocks() as demo:
104
 
105
  # >Looking for a large open-source pre-trained language model for dialog? Look no further than GODEL! GODEL leverages a new phase of grounded pretraining designed to better support finetuning phases that require information external to the current conversation (e.g., a database or document) to produce good responses. So if you're looking for a language model that can help you produce better responses in a variety of situations, GODEL is the right choice for you!<p style="text-align:right"> ------ a copy from GPT-3</p>''')
106
 
107
- dropdown = gr.Dropdown(
108
- [f"Example {i+1}" for i in range(9)], label='Examples')
109
 
 
 
 
110
  radio = gr.Radio(
111
- ["Conversational Question Answering", "Chitchat", "Grounded Response Generation"], label="Instruction Type", value='Conversational Question Answering'
112
  )
113
  instruction = gr.Textbox(lines=1, interactive=True, label="Instruction",
114
  value="Instruction: given a dialog context and related knowledge, you need to answer the question based on the knowledge.")
 
10
  tokenizer = AutoTokenizer.from_pretrained("microsoft/GODEL-v1_1-base-seq2seq")
11
  model = AutoModelForSeq2SeqLM.from_pretrained("microsoft/GODEL-v1_1-base-seq2seq")
12
 
13
+ # preset_examples = [
14
+ # ('Instruction: given a dialog context, you need to response empathically.',
15
+ # '', 'Does money buy happiness?', 'Chitchat'),
16
+ # ('Instruction: given a dialog context, you need to response empathically.',
17
+ # '', 'What is the goal of life?', 'Chitchat'),
18
+ # ('Instruction: given a dialog context, you need to response empathically.',
19
+ # '', 'What is the most interesing thing about our universe?', 'Chitchat'),
20
+ # ('Instruction: given a dialog context and related knowledge, you need to answer the question based on the knowledge.',
21
+ # '''Scooby-Doo is the eponymous character and protagonist of the animated television franchise of the same name, created in 1969 by the American animation company Hanna-Barbera.[1] He is a male Great Dane and lifelong companion of amateur detective Shaggy Rogers, with whom he shares many personality traits. He features a mix of both canine and human behaviors (reminiscent of other talking animals in Hanna-Barbera's series), and is treated by his friends more or less as an equal. Scooby often speaks in a rhotacized way, substituting the first letters of many words with the letter 'r'. His catchphrase is "Scooby-Dooby-Doo!"
22
+ # ''',
23
+ # 'What kind of animal is scooby from scooby doo?', 'Conversational Question Answering'
24
+ # ),
25
+ # ('Instruction: given a dialog context and related knowledge, you need to answer the question based on the knowledge.',
26
+ # '''Subject: faa demos
27
+ # Dan: PM Team, Attached are some general ideas and issues around developing new demos for our new target markets. Please review and provide feedback. Also, please provide links where we can learn more about various FAA applications. Thanx, Dan.
28
+ # Alex: Dan, Thanks for putting the high level descriptions together. My questions are: *Is it practical to do an EAI demo given the inherent complexity of application integration? ... * Should we delay looking at Outlook for now?... *What do you think that timelines are developing these demos? ... Alex
29
+ # Dan: Alex, Thanks for the feedback, please see my comments below:
30
+ # ''',
31
+ # 'what does Dan ask PM team to do?', 'Conversational Question Answering'
32
+ # ),
33
+ # ('Instruction: given a dialog context and related knowledge, you need to answer the question based on the knowledge.',
34
+ # '''Carlos Alcaraz, at just 19, completed an improbable journey on Sunday in Flushing Meadows as he defeated No. 5 Casper Ruud to win the 2022 US Open. Alcaraz came away with a 6-4, 2-6, 7-6, 6-2 win over Ruud to win his first career Grand Slam title.
35
 
36
+ # In doing so, Alcaraz became the second-youngest player to win a men's US Open title at 19 years, 129 days old, only trailing Pete Sampras. In addition, Alcaraz is the seventh youngest male or female to ever win a Grand Slam tournament. With the Grand Slam victory, Alcaraz becomes the No. 1 ranked player in the world. Additionally, the 19-year-old budding star is also the youngest player to ever be ranked as the world's No. 1 player.
37
+ # ''',
38
+ # 'who won the 2022 US Open? EOS Carlos Alcaraz EOS how old?', 'Conversational Question Answering'
39
+ # ),
40
+ # (
41
+ # 'Instruction: given a dialog context and related knowledge, you need to response safely based on the knowledge.',
42
+ # '''Over-the-counter medications such as ibuprofen (Advil, Motrin IB, others), acetaminophen (Tylenol, others) and aspirin.
43
+ # ''',
44
+ # 'I have a headache, what should I do?', "Grounded Response Generation"
45
+ # ),
46
+ # (
47
+ # 'Instruction: given a dialog context and related knowledge, you need to response safely based on the knowledge.',
48
+ # '''The best Stardew Valley mods PCGamesN_0 / About SMAPI
49
+ # ''',
50
+ # 'My favorite game is stardew valley. stardew valley is very fun.', "Grounded Response Generation"
51
+ # ),
52
+ # (
53
+ # 'Instruction: given a dialog context and related knowledge, you need to response safely based on the knowledge.',
54
+ # '''Wong Kar-wai BBS (born 17 July 1958) is a Hong Kong film director, screenwriter, and producer. His films are characterised by nonlinear narratives, atmospheric music, and vivid cinematography involving bold, saturated colours. A pivotal figure of Hong Kong cinema, Wong is considered a contemporary auteur, and ranks third on Sight & Sound's 2002 poll of the greatest filmmakers of modern times.[note 1] His films frequently appear on best-of lists domestically and internationally.
55
+ # ''',
56
+ # 'My favorite director is wrong kar wai. i think in modern cinema there is no other director is is making the medium as cool', "Grounded Response Generation"
57
+ # )
58
+ # ]
59
 
60
 
61
  def generate(instruction, knowledge, dialog, top_p, min_length, max_length):
 
104
 
105
  # >Looking for a large open-source pre-trained language model for dialog? Look no further than GODEL! GODEL leverages a new phase of grounded pretraining designed to better support finetuning phases that require information external to the current conversation (e.g., a database or document) to produce good responses. So if you're looking for a language model that can help you produce better responses in a variety of situations, GODEL is the right choice for you!<p style="text-align:right"> ------ a copy from GPT-3</p>''')
106
 
107
+ # dropdown = gr.Dropdown(
108
+ # [f"Example {i+1}" for i in range(9)], label='Examples')
109
 
110
+ # radio = gr.Radio(
111
+ # ["Conversational Question Answering", "Chitchat", "Grounded Response Generation"], label="Instruction Type", value='Conversational Question Answering'
112
+ # )
113
  radio = gr.Radio(
114
+ ["Conversational Question Answering"], label="Instruction Type", value='Conversational Question Answering'
115
  )
116
  instruction = gr.Textbox(lines=1, interactive=True, label="Instruction",
117
  value="Instruction: given a dialog context and related knowledge, you need to answer the question based on the knowledge.")