import gradio as gr import timm from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline import transformers title = "Finetuning [BERT] on A Financial News Sentiment Dataset" description = """ The LLM was finetuned on a Financial News Tweet Sentiment Dataset. The documents have 3 different labels: "LABEL_0": "Bearish", "LABEL_1": "Bullish", "LABEL_2": "Neutral" """ article = "Check out the model card [here](https://huggingface.co./at2507/finetuned_model)!" def sentiment_analyzer(financial_news_headline): tokenizer = AutoTokenizer.from_pretrained("at2507/finetuned_model") model = AutoModelForSequenceClassification.from_pretrained("at2507/finetuned_model") zeroshotsent_model = pipeline("text-classification", model = model.to('cpu:0'), tokenizer=tokenizer) return zeroshotsent_model(financial_news_headline) gr.Interface( fn=sentiment_analyzer, inputs="textbox", outputs="text", title=title, description=description, article=article, examples=[["CLNE, TRXC, TGE and ADMS among midday movers"], ["CRISPR Therapeutics among healthcare gainers; Plus Therapeutics leads the losers"], ["Firsthand Technology Value Fund and Itau CorpBanca among Financial gainers; Mmtec and Jupai among losers"], ["Canopy Growth up 6% as BofA buys the dip"]], ).launch()