File size: 626 Bytes
1e775fe
 
 
06e92f0
3b81279
3b863fe
 
8d06405
06e92f0
87dd4e3
 
3ad0ea6
 
8d06405
87dd4e3
8d06405
 
3ad0ea6
592a4fd
8d06405
a5ff044
 
592a4fd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import streamlit as st

from transformers import pipeline

@st.cache(allow_output_mutation=True)
def get_model(model):
	return pipeline("fill-mask", model=model)


text = st.text_input("Enter a sentence. Use a * for a mask.")

model = st.selectbox("choose a model", ["roberta-base", "bert-base-uncased", "gpt2", "t5"])

# Create a text element and let the reader know the data is loading.

if text:
	data_load_state = st.text('Loading data...')
	nlp = get_model(model)
	result = nlp(text.replace("*", nlp.tokenizer.mask_token))
	data_load_state.text('Loading data...done!')
	for c in result:
		del c["token"]
	st.table(result)