Wootang01 commited on
Commit
64a1aa6
1 Parent(s): 0fab62c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -11
app.py CHANGED
@@ -8,8 +8,8 @@ question_model = T5ForConditionalGeneration.from_pretrained('ramsrigouthamg/t5_s
8
  question_tokenizer = T5Tokenizer.from_pretrained('ramsrigouthamg/t5_squad_v1')
9
 
10
  def get_question(sentence,answer,mdl,tknizer):
11
- text = "context: {} answer: {}".format(sentence,answer)
12
- print (text)
13
  max_len = 256
14
  encoding = tknizer.encode_plus(text,max_length=max_len, pad_to_max_length=False,truncation=True, return_tensors="pt")
15
 
@@ -32,8 +32,8 @@ def get_question(sentence,answer,mdl,tknizer):
32
  return Question
33
 
34
 
35
- context = "Elon Musk said that Tesla will not accept payments in Bitcoin because of environmental concerns."
36
- answer = "Elon Musk"
37
 
38
  ques = get_question(context,answer,question_model,question_tokenizer)
39
  print ("question: ",ques)
@@ -41,23 +41,27 @@ print ("question: ",ques)
41
  import gradio as gr
42
 
43
  title = "Question Generator Three"
44
- description = "Paste or write a text. Provide a short answer or noun keywords. Submit and the machine will attempt to generate a coherent question"
45
- context = gr.inputs.Textbox(lines=5, placeholder="Enter paragraph/context here...")
46
- answer = gr.inputs.Textbox(lines=3, placeholder="Enter answer/keyword here...")
47
  question = gr.outputs.Textbox( type="auto", label="Question")
48
  examples = [
49
  ["""Fears of a new Covid-19 cluster linked to a hotpot restaurant have surfaced amid Hong Kong’s Omicron-fuelled fifth wave, while infections tied to an investment bank continued to expand, triggering the evacuation of residents in a building after vertical transmission of the virus was detected.
50
  On Wednesday, hundreds thronged Covid-19 testing stations in Tuen Mun, with some residents complaining of long waiting times and chaotic arrangements. Authorities have deemed the district a high-risk area because of a higher number of infections.
51
  Health officials said sewage testing would be conducted in Tuen Mun to monitor the spread of the coronavirus, but a string of preliminary-positive cases detected across the city suggested a wider, more worrying situation.
52
- """, "a higher number of infections"]
 
 
 
 
53
 
54
  ]
55
 
56
- def generate_question(context,answer):
57
- return get_question(context,answer,question_model,question_tokenizer)
58
 
59
  iface = gr.Interface(
60
  fn=generate_question,
61
- inputs=[context,answer],
62
  outputs=question, title=title, description=description, examples=examples)
63
  iface.launch(debug=False)
 
8
  question_tokenizer = T5Tokenizer.from_pretrained('ramsrigouthamg/t5_squad_v1')
9
 
10
  def get_question(sentence,answer,mdl,tknizer):
11
+ prompt = "context: {} answer: {}".format(sentence,answer)
12
+ print (prompt)
13
  max_len = 256
14
  encoding = tknizer.encode_plus(text,max_length=max_len, pad_to_max_length=False,truncation=True, return_tensors="pt")
15
 
 
32
  return Question
33
 
34
 
35
+ Text = "Elon Musk said that Tesla will not accept payments in Bitcoin because of environmental concerns."
36
+ Answer = "Elon Musk"
37
 
38
  ques = get_question(context,answer,question_model,question_tokenizer)
39
  print ("question: ",ques)
 
41
  import gradio as gr
42
 
43
  title = "Question Generator Three"
44
+ description = "Paste or write a text. You may also paste or write a short answer, preferably a noun or noun phrase. Submit and the machine will attempt to generate a coherent question."
45
+ Text = gr.inputs.Textbox(lines=5, placeholder="Enter paragraph/context here...")
46
+ Answer = gr.inputs.Textbox(lines=3, placeholder="Enter answer/keyword here...")
47
  question = gr.outputs.Textbox( type="auto", label="Question")
48
  examples = [
49
  ["""Fears of a new Covid-19 cluster linked to a hotpot restaurant have surfaced amid Hong Kong’s Omicron-fuelled fifth wave, while infections tied to an investment bank continued to expand, triggering the evacuation of residents in a building after vertical transmission of the virus was detected.
50
  On Wednesday, hundreds thronged Covid-19 testing stations in Tuen Mun, with some residents complaining of long waiting times and chaotic arrangements. Authorities have deemed the district a high-risk area because of a higher number of infections.
51
  Health officials said sewage testing would be conducted in Tuen Mun to monitor the spread of the coronavirus, but a string of preliminary-positive cases detected across the city suggested a wider, more worrying situation.
52
+ """, "a higher number of infections"],
53
+ ["""Squid Game made history on Wednesday as the first non-English-language television series and the first Korean series to score a nomination for a Screen Actors Guild Award.
54
+ The hit Netflix show, created by Hwang Dong-hyuk, is nominated for ensemble in a drama series alongside The Handmaid’s Tale, The Morning Show, Succession and Yellowstone.
55
+ Squid Game stars Lee Jung-jae and Jung Ho-yeon also landed individual nominations for actor and actress in a drama series, respectively.
56
+ """, "Yellowstone"]
57
 
58
  ]
59
 
60
+ def generate_question(Text,Answer):
61
+ return get_question(Text,Answer,question_model,question_tokenizer)
62
 
63
  iface = gr.Interface(
64
  fn=generate_question,
65
+ inputs=[Text,Answer],
66
  outputs=question, title=title, description=description, examples=examples)
67
  iface.launch(debug=False)