Cicciokr's picture
utilizzo del modello LuisAVasquez/simple-latin-bert-uncased
b5fe0df verified
raw
history blame
1.03 kB
#import streamlit as st
#x = st.slider('Select a value')
#st.write(x, 'squared is', x * x)
import streamlit as st
from transformers import pipeline, AutoModelForMaskedLM, AutoTokenizer
st.title("Completamento del testo in Latino con Latin BERT")
st.write("Inserisci un testo con il token [MASK] per vedere le previsioni del modello.")
input_text = st.text_input("Testo:", value="Lorem ipsum dolor sit amet, [MASK] adipiscing elit.")
#modelname = "./models/latin_bert/"
modelname = "LuisAVasquez/simple-latin-bert-uncased"
tokenizer = AutoTokenizer.from_pretrained(modelname)
model = AutoModelForMaskedLM.from_pretrained(modelname)
# Creare un pipeline di riempimento maschere
fill_mask = pipeline("fill-mask", model=model, tokenizer=tokenizer)
#fill_mask = pipeline("fill-mask", model=modelname)
if input_text:
predictions = fill_mask(input_text)
st.subheader("Risultati delle previsioni:")
for pred in predictions:
st.write(f"**Parola**: {pred['token_str']}, **Probabilità**: {pred['score']:.4f}")