Spaces:
Runtime error
Runtime error
File size: 1,452 Bytes
f3340bb d92cf74 48683e5 3fcb95b d92cf74 9776416 d92cf74 9776416 d92cf74 9776416 5eab48a d92cf74 9776416 e1bbb2f fc815f0 b236209 |
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 33 34 35 36 37 38 |
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"
<img src="https://huggingface.co/spaces/course-demos/Rick_and_Morty_QA/resolve/main/rick.png" width=200px>
"""
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()
|