Nuthanon commited on
Commit
e3283b1
1 Parent(s): fc0c412

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -6
app.py CHANGED
@@ -1,10 +1,31 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
- st.title("Test")
5
- test_pipeline = pipeline("sentiment-analysis")
6
- text = st.text_area("Enter some text")
7
 
8
- if text:
9
- out = test_pipeline(text)
10
- st.json(out)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
+ # Load the pre-trained Finnish model
5
+ model_name = "TurkuNLP/bert-base-finnish-cased-v1"
6
+ nlp = pipeline("fill-mask", model=model_name)
7
 
8
+ st.title("Finnish Language Understanding App")
9
+
10
+ st.write("This app demonstrates understanding of the Finnish language.")
11
+
12
+ # User input
13
+ user_input = st.text_input("Enter a sentence in Finnish:")
14
+
15
+ if user_input:
16
+ st.write("You entered:", user_input)
17
+
18
+ # Use the model to predict masked words (as a simple example of language understanding)
19
+ masked_input = user_input.replace("____", "[MASK]")
20
+ results = nlp(masked_input)
21
+
22
+ st.write("Predictions for the masked word:")
23
+ for result in results:
24
+ st.write(f"Prediction: {result['token_str']}, Score: {result['score']:.4f}")
25
+
26
+ if st.checkbox("Show example usage"):
27
+ st.write("Example sentence: Hän on ____ ystävä.")
28
+ example_results = nlp("Hän on [MASK] ystävä.")
29
+ st.write("Predictions for the masked word in the example:")
30
+ for result in example_results:
31
+ st.write(f"Prediction: {result['token_str']}, Score: {result['score']:.4f}")