Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -19,21 +19,21 @@ def fill_the_mask(text):
|
|
19 |
#First sort the list of dictionaries according to the score
|
20 |
model_out = sorted(model_out, key=lambda x: x['score'],reverse=True)
|
21 |
|
22 |
-
#Create a
|
23 |
-
|
24 |
|
25 |
#Iterate over the list of dictionaries and get the required ouput
|
26 |
for sub_dict in model_out:
|
27 |
-
|
28 |
|
29 |
-
return
|
30 |
|
31 |
#Create a Gradio user interface
|
32 |
my_interface = gr.Interface(title="Masked Language Model APP\n(by Umair Akram)",
|
33 |
description="This App uses a fine-tuned DistilBERT-Base-Uncased Masked Language Model to predict the missed word in a sentence.\nEnter your text and put \"[MASK]\" at the word which you want to predict, as shown in the following example: Can we [MASK] to Paris?",
|
34 |
fn=fill_the_mask,
|
35 |
inputs="text",
|
36 |
-
outputs="
|
37 |
|
38 |
#Define the main function
|
39 |
if __name__ == "__main__":
|
|
|
19 |
#First sort the list of dictionaries according to the score
|
20 |
model_out = sorted(model_out, key=lambda x: x['score'],reverse=True)
|
21 |
|
22 |
+
#Create a dictionary to store the model output
|
23 |
+
out_dict = {}
|
24 |
|
25 |
#Iterate over the list of dictionaries and get the required ouput
|
26 |
for sub_dict in model_out:
|
27 |
+
out_dict[sub_dict["sequence"]] = round(sub_dict["score"], 3)
|
28 |
|
29 |
+
return out_dict
|
30 |
|
31 |
#Create a Gradio user interface
|
32 |
my_interface = gr.Interface(title="Masked Language Model APP\n(by Umair Akram)",
|
33 |
description="This App uses a fine-tuned DistilBERT-Base-Uncased Masked Language Model to predict the missed word in a sentence.\nEnter your text and put \"[MASK]\" at the word which you want to predict, as shown in the following example: Can we [MASK] to Paris?",
|
34 |
fn=fill_the_mask,
|
35 |
inputs="text",
|
36 |
+
outputs="label")
|
37 |
|
38 |
#Define the main function
|
39 |
if __name__ == "__main__":
|