File size: 971 Bytes
79113c6 e8e622a 02c7de4 5594654 c04f8be 018188f 79113c6 ac25ae6 79113c6 ac25ae6 e3bdd13 018188f e3bdd13 0d9b200 e3bdd13 0d9b200 |
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
model_name = "peace4ever/roberta-large-finetuned-mongolian_v4"
pipeline = pipeline(task="sentiment-analysis", model=model_name) # Load pre-trained pipeline
st.title("Эерэг? Сөрөг эсвэл аль нь ч биш?")
text = st.text_area("Өгүүлбэр оруулна уу?")
if text is not None:
predictions = pipeline(text)
label = predictions[0]["label"]
probability = predictions[0]["score"]
col1, col2 = st.columns(2)
col1.header("Sentiment")
col2.header("Probability")
if label == "entailment":
sentiment = "Negative"
elif label == "contradiction":
sentiment = "Neutral"
elif label == "neutral":
sentiment = "Positive"
col1.write(sentiment)
col2.write(f"{probability:.2f}")
# label = predictions[0]["label"]
# probability = predictions[0]["score"]
# col1.write(label)
# col2.write(f"{probability:.2f}")
|