Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import AutoTokenizer | |
import timm | |
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 dataset that [BERT cased]((https://huggingface.co/bert-base-cased?text=Paris+is+the+%5BMASK%5D+of+France.)) was [finetuned on](https://huggingface.co/datasets/zeroshot/twitter-financial-news-sentiment/viewer/zeroshot--twitter-financial-news-sentiment/train?row=9505)." | |
def sentiment_analyzer(tweet): | |
model_reloaded = timm.create_model('hf_hub:at2507/zeroshot_finetuned_sentiment', pretrained=True) | |
# model = model.load("models/at2507/zeroshot_finetuned_sentiment") | |
# gr.Interface.load("models/at2507/zeroshot_finetuned_sentiment").launch() | |
tokenizer = AutoTokenizer.from_pretrained("bert-base-cased") | |
zeroshotsent_model = pipeline("text-classification", model = model.to('cpu:0'), tokenizer=tokenizer) | |
return zeroshotsent_model(tweet) | |
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"]], | |
).launch() | |