Spaces:
Runtime error
Runtime error
Rik Bose
commited on
Commit
·
8d06405
1
Parent(s):
87dd4e3
efficiency?
Browse files
app.py
CHANGED
|
@@ -1,17 +1,20 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
|
| 3 |
-
# Create a text element and let the reader know the data is loading.
|
| 4 |
-
data_load_state = st.text('Loading data...')
|
| 5 |
-
# Load 10,000 rows of data into the dataframe.
|
| 6 |
-
# Notify the reader that the data was successfully loaded.
|
| 7 |
from transformers import pipeline
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
|
| 12 |
text = st.text_input("Enter a sentence. Use a * for a mask.")
|
| 13 |
-
result = nlp(text.replace("*",nlp.tokenizer.mask_token))
|
| 14 |
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
+
@st.cached
|
| 6 |
+
def get_model():
|
| 7 |
+
return pipeline("fill-mask", model="roberta-base")
|
| 8 |
+
|
| 9 |
|
| 10 |
text = st.text_input("Enter a sentence. Use a * for a mask.")
|
|
|
|
| 11 |
|
| 12 |
+
# Create a text element and let the reader know the data is loading.
|
| 13 |
|
| 14 |
+
if text:
|
| 15 |
+
data_load_state = st.text('Loading data...')
|
| 16 |
+
nlp = get_model()
|
| 17 |
+
result = nlp(text.replace("*",nlp.tokenizer.mask_token))
|
| 18 |
+
data_load_state.text('Loading data...done!')
|
| 19 |
+
for d in result:
|
| 20 |
+
st.write(str(d["score"])+"\n"+d["sequence"])
|