File size: 1,125 Bytes
cbbb853
 
 
e3283b1
 
 
432f311
e3283b1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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}")