Spaces:
Runtime error
Runtime error
clean up and fix typos
Browse files
app.py
CHANGED
|
@@ -87,44 +87,12 @@ def create_response_paraphrase(input_str, max_length,num_return_sequences):
|
|
| 87 |
# return results
|
| 88 |
return result_output_str
|
| 89 |
|
| 90 |
-
def create_response(input_str,
|
| 91 |
-
temperature,
|
| 92 |
-
seed,
|
| 93 |
-
model_name):
|
| 94 |
-
print("input_str="+input_str)
|
| 95 |
-
print("model_name="+str(model_name))
|
| 96 |
-
print("temperature" + str(temperature))
|
| 97 |
-
seed=int(seed)
|
| 98 |
-
print("seed" + str(seed))
|
| 99 |
-
input_ids = tokenizer.encode(input_str + tokenizer.eos_token, return_tensors="pt")
|
| 100 |
|
| 101 |
-
|
| 102 |
-
#= encoded["input_ids"]
|
| 103 |
-
#attention_mask = encoded["attention_mask"]
|
| 104 |
-
|
| 105 |
-
if seed != -1:
|
| 106 |
-
set_seed(seed)
|
| 107 |
-
if model_name == "original_model":
|
| 108 |
-
output = original_model.generate(input_ids, max_length=100, temperature=temperature, pad_token_id=tokenizer.eos_token_id)
|
| 109 |
-
|
| 110 |
-
#elif model_name == "untethered_model":
|
| 111 |
-
else:
|
| 112 |
-
output = original_model.generate(input_ids, max_length=100, temperature=temperature, pad_token_id=tokenizer.eos_token_id )
|
| 113 |
-
|
| 114 |
-
outputs = model_name+" generated <br>"
|
| 115 |
-
sentence = tokenizer.decode(output[0], skip_special_tokens=True)
|
| 116 |
-
outputs = outputs + sentence+ "<br/>"
|
| 117 |
-
|
| 118 |
-
return outputs
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
common_examples_string="<br/>Sample Inputs:<br/>What is death?<br/>One of the best teachers in all of life turns out to be what?<br/>what is your most meaningful relationship?<br/>What actually gives life meaning?<br/>"
|
| 122 |
-
|
| 123 |
-
interface_original = gr.Interface(fn=create_response_question_generation,
|
| 124 |
title="Question Generation",
|
| 125 |
-
description="Enter a
|
| 126 |
inputs=[
|
| 127 |
-
gr.Textbox(label="input text here", lines=3),
|
| 128 |
gr.Number(
|
| 129 |
label="max length",
|
| 130 |
value=64),
|
|
@@ -134,7 +102,7 @@ interface_original = gr.Interface(fn=create_response_question_generation,
|
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
-
|
| 138 |
title="Paraphrase",
|
| 139 |
description="Paraphrase sentences",
|
| 140 |
#examples=examples,
|
|
@@ -153,6 +121,6 @@ interface_untethered_model = gr.Interface(fn=create_response_paraphrase,
|
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
-
demo = gr.TabbedInterface([
|
| 157 |
|
| 158 |
demo.launch()
|
|
|
|
| 87 |
# return results
|
| 88 |
return result_output_str
|
| 89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
+
interface_question_generation = gr.Interface(fn=create_response_question_generation,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
title="Question Generation",
|
| 93 |
+
description="Enter a statmente like Paris is the capital of France",
|
| 94 |
inputs=[
|
| 95 |
+
gr.Textbox(label="input text here", lines=3, value="Paris is the capital of France"),
|
| 96 |
gr.Number(
|
| 97 |
label="max length",
|
| 98 |
value=64),
|
|
|
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
+
interface_paraphrase = gr.Interface(fn=create_response_paraphrase,
|
| 106 |
title="Paraphrase",
|
| 107 |
description="Paraphrase sentences",
|
| 108 |
#examples=examples,
|
|
|
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
+
demo = gr.TabbedInterface([interface_question_generation, interface_paraphrase], ["Question Generation", "Paraphrase"])
|
| 125 |
|
| 126 |
demo.launch()
|