File size: 634 Bytes
ea4b307 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import streamlit as st
from transformers import pipeline
# Title for the app
st.title('Fill in the Blank Bot')
# Load the fill-mask pipeline
fill_mask = pipeline('fill-mask')
# Text area for the user input
user_input = st.text_area("Enter a sentence with a <mask> in place of the missing word")
# Button to trigger the fill-mask function
if st.button('Fill the Blank'):
# Predict the missing words
results = fill_mask(user_input)
# Display the top 5 predictions
st.write("Top predictions:")
for result in results:
st.write(f"Prediction: {result['token_str']}, Confidence: {round(result['score'], 4)}") |