Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,18 +7,21 @@ def get_model(model):
|
|
| 7 |
return pipeline("fill-mask", model=model)
|
| 8 |
|
| 9 |
|
| 10 |
-
text = st.text_input("Enter a text for auto completion...")
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
model = st.selectbox("choose a model", ["roberta-base", "bert-base-uncased", "gpt2", "t5"])
|
| 15 |
|
| 16 |
if text:
|
| 17 |
-
data_load_state = st.text('Loading...')
|
| 18 |
nlp = get_model(model)
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
| 24 |
st.table(result)
|
|
|
|
| 7 |
return pipeline("fill-mask", model=model)
|
| 8 |
|
| 9 |
|
|
|
|
| 10 |
|
| 11 |
+
|
| 12 |
+
history_keyword_text = st.text_input("Enter users's history keywords (optional, i.e., 'Gates')")
|
| 13 |
+
|
| 14 |
+
text = st.text_input("Enter a text for auto completion...")
|
| 15 |
|
| 16 |
model = st.selectbox("choose a model", ["roberta-base", "bert-base-uncased", "gpt2", "t5"])
|
| 17 |
|
| 18 |
if text:
|
| 19 |
+
data_load_state = st.text('Loading model...')
|
| 20 |
nlp = get_model(model)
|
| 21 |
+
data_load_state = st.text('Inference to model...')
|
| 22 |
+
result = nlp(text+' '+nlp.tokenizer.mask_token)
|
| 23 |
+
data_load_state.text('')
|
| 24 |
+
for r in result:
|
| 25 |
+
if r in history_keyword_text:
|
| 26 |
+
r['score']*=0.10
|
| 27 |
st.table(result)
|