import streamlit as st from transformers import pipeline # widget for selecting langugae model # available sentiment analysis models: https://huggingface.co/models?pipeline_tag=text-classification&sort=downloads&search=sentiment # we take the first 5 most downloaded ones. language_model = st.selectbox( "Select the Pretrained Language Model you'd like to use", ( "finiteautomata/bertweet-base-sentiment-analysis", "siebert/sentiment-roberta-large-english", "cardiffnlp/twitter-roberta-base-sentiment", "Seethal/sentiment_analysis_generic_dataset", "nlptown/bert-base-multilingual-uncased-sentiment", ), ) # pass the model to transformers pipeline - model selection component. sentiment_analysis = pipeline(model=language_model) # get text entry from users data = st.text_input( "Enter Text", "Just started school at NYU! Looking forward to this new chapter!" ) if st.button("Submit"): results = sentiment_analysis([data]) st.write(results)