mohamedemam commited on
Commit
e0f8449
1 Parent(s): 8d554fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -56,7 +56,7 @@ recommended_words = [
56
  ]
57
 
58
  # Function to generate questions and answers with configurable parameters
59
- def generate_qa(context, recommended_word, temperature, top_p,num_seq, num_samples=3):
60
  input_text = f"{recommended_word}: {context}"
61
  input_text=re.sub(f'\n'," ",input_text).lower()
62
  input_ids = tokenizer(input_text, return_tensors='pt')
@@ -67,10 +67,10 @@ def generate_qa(context, recommended_word, temperature, top_p,num_seq, num_sampl
67
  temperature=temperature,
68
  top_p=top_p,
69
  num_return_sequences=num_seq,
70
- do_sample=True,
71
  max_length=100,
72
- num_beams=6,
73
- length_penalty=1.5,
74
  )
75
  #
76
  generated_text = tokenizer.batch_decode(output, skip_special_tokens=True)
@@ -84,7 +84,12 @@ iface = gr.Interface(
84
  gr.inputs.Radio(recommended_words, label="Choose a Recommended Word"),
85
  gr.inputs.Slider(minimum=0.0, maximum=5, default=2.1, step=0.01, label="Temperature"),
86
  gr.inputs.Slider(minimum=0.0, maximum=1, default=0.5, step=0.01, label="Top-p"),
87
- gr.inputs.Slider(minimum=1, maximum=20, default=3, step=1, label="num of sequance")
 
 
 
 
 
88
  ],
89
  outputs=gr.outputs.Textbox(label="Generated Output"),
90
  title="Question Generation and Answering",
 
56
  ]
57
 
58
  # Function to generate questions and answers with configurable parameters
59
+ def generate_qa(context, recommended_word, temperature, top_p,num_seq,l_p, num_b):
60
  input_text = f"{recommended_word}: {context}"
61
  input_text=re.sub(f'\n'," ",input_text).lower()
62
  input_ids = tokenizer(input_text, return_tensors='pt')
 
67
  temperature=temperature,
68
  top_p=top_p,
69
  num_return_sequences=num_seq,
70
+
71
  max_length=100,
72
+ num_beams=num_b,
73
+ length_penalty=l_p, do_sample=True,
74
  )
75
  #
76
  generated_text = tokenizer.batch_decode(output, skip_special_tokens=True)
 
84
  gr.inputs.Radio(recommended_words, label="Choose a Recommended Word"),
85
  gr.inputs.Slider(minimum=0.0, maximum=5, default=2.1, step=0.01, label="Temperature"),
86
  gr.inputs.Slider(minimum=0.0, maximum=1, default=0.5, step=0.01, label="Top-p"),
87
+ gr.inputs.Slider(minimum=1, maximum=20, default=3, step=1, label="num of sequance"),
88
+ gr.inputs.Slider(minimum=1, maximum=20, default=3, step=1, label="l_p")
89
+ ,
90
+ gr.inputs.Slider(minimum=1, maximum=20, default=3, step=1, label="num of beams"),
91
+
92
+
93
  ],
94
  outputs=gr.outputs.Textbox(label="Generated Output"),
95
  title="Question Generation and Answering",