Spaces:
Runtime error
Runtime error
File size: 1,540 Bytes
cca095a 5eab48a 7dc5723 5eab48a 7dc5723 5eab48a |
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 |
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()
|