import streamlit as st from transformers import pipeline # Load the pre-trained Finnish model model_name = "TurkuNLP/bert-base-finnish-cased-v1" nlp = pipeline("fill-mask", model=model_name) st.title("Finnish Language Understanding App") st.write("This app demonstrates understanding of the Finnish language.") # User input user_input = st.text_input("Enter a sentence in Finnish:") if user_input: st.write("You entered:", user_input) # Use the model to predict masked words (as a simple example of language understanding) masked_input = user_input.replace("____", "[MASK]") results = nlp(masked_input) st.write("Predictions for the masked word:") for result in results: st.write(f"Prediction: {result['token_str']}, Score: {result['score']:.4f}") if st.checkbox("Show example usage"): st.write("Example sentence: Hän on ____ ystävä.") example_results = nlp("Hän on [MASK] ystävä.") st.write("Predictions for the masked word in the example:") for result in example_results: st.write(f"Prediction: {result['token_str']}, Score: {result['score']:.4f}")