mbahrami commited on
Commit
da676c8
1 Parent(s): ba51a4f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+
4
+ from transformers import pipeline
5
+
6
+ @st.cache(allow_output_mutation=True)
7
+ def get_model(model):
8
+ return pipeline("fill-mask", model=model)
9
+
10
+
11
+ text = st.text_input("Enter a text for auto completion...")
12
+
13
+ history_keyword_text = st.text_input("Users's history keyword split with ','")
14
+
15
+ model = st.selectbox("choose a model", ["roberta-base", "bert-base-uncased", "gpt2", "t5"])
16
+
17
+ if text:
18
+ data_load_state = st.text('Loading...')
19
+ nlp = get_model(model)
20
+ result = nlp(text+nlp.tokenizer.mask_token)
21
+ data_load_state.text('Loading data...done!')
22
+ # for c in result:
23
+ # del c["token"]
24
+ st.table(result)