Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,10 +9,10 @@ HISTORY_WEIGHT = 100 # set history weight (if found any keyword from history, it
|
|
9 |
|
10 |
@st.cache(allow_output_mutation=True)
|
11 |
def get_model(model):
|
12 |
-
return pipeline("fill-mask", model=model, top_k=
|
13 |
|
14 |
def main(nlp, semantic_model):
|
15 |
-
data_load_state = st.text('Inference
|
16 |
result = nlp(text+' '+nlp.tokenizer.mask_token)
|
17 |
data_load_state.text('')
|
18 |
sem_list=[semantic_text.strip()]
|
@@ -41,16 +41,17 @@ def main(nlp, semantic_model):
|
|
41 |
if __name__ == '__main__':
|
42 |
if st._is_running_with_streamlit:
|
43 |
st.markdown("""
|
44 |
-
#
|
45 |
This is an example of an auto-complete approach where the next token suggested based on users's history Keyword match & Semantic similarity of users's history (log).
|
46 |
The next token is predicted per probability and a weight if it is appeared in keyword user's history or there is a similarity to semantic user's history
|
47 |
|
48 |
""")
|
49 |
-
history_keyword_text = st.text_input("Enter users's history
|
|
|
50 |
|
51 |
text = st.text_input("Enter a text for auto completion...", value='Where is Bill')
|
52 |
|
53 |
-
|
54 |
|
55 |
model = st.selectbox("Choose a model", ["roberta-base", "bert-base-uncased"])
|
56 |
|
|
|
9 |
|
10 |
@st.cache(allow_output_mutation=True)
|
11 |
def get_model(model):
|
12 |
+
return pipeline("fill-mask", model=model, top_k=10)#set the maximum of tokens to be retrieved after each inference to model
|
13 |
|
14 |
def main(nlp, semantic_model):
|
15 |
+
data_load_state = st.text('Inference from model...')
|
16 |
result = nlp(text+' '+nlp.tokenizer.mask_token)
|
17 |
data_load_state.text('')
|
18 |
sem_list=[semantic_text.strip()]
|
|
|
41 |
if __name__ == '__main__':
|
42 |
if st._is_running_with_streamlit:
|
43 |
st.markdown("""
|
44 |
+
# Auto-Complete
|
45 |
This is an example of an auto-complete approach where the next token suggested based on users's history Keyword match & Semantic similarity of users's history (log).
|
46 |
The next token is predicted per probability and a weight if it is appeared in keyword user's history or there is a similarity to semantic user's history
|
47 |
|
48 |
""")
|
49 |
+
history_keyword_text = st.text_input("Enter users's history **keywords match** (optional, i.e., 'Gates')", value="")
|
50 |
+
semantic_text = st.text_input("Enter users's history **semantic** (optional, i.e., 'Microsoft or President')", value="Microsoft")
|
51 |
|
52 |
text = st.text_input("Enter a text for auto completion...", value='Where is Bill')
|
53 |
|
54 |
+
|
55 |
|
56 |
model = st.selectbox("Choose a model", ["roberta-base", "bert-base-uncased"])
|
57 |
|