takala/financial_phrasebank
Updated β’ 9.32k β’ 257
How to use Tasfiya025/FinancialSentimentAnalyzer with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="Tasfiya025/FinancialSentimentAnalyzer") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("Tasfiya025/FinancialSentimentAnalyzer")
model = AutoModelForSequenceClassification.from_pretrained("Tasfiya025/FinancialSentimentAnalyzer")This model is a fine-tuned version of the bert-base-uncased pre-trained model for Sequence Classification. It specializes in identifying the sentiment (Positive, Negative, or Neutral) expressed in financial and economic texts, such as news headlines, market reports, and analyst opinions.
The model uses the standard BERT (Bidirectional Encoder Representations from Transformers) architecture.
bert-base-uncased.0: Negative, 1: Neutral, 2: Positive.This model is intended for:
Use the pipeline feature for quick inference:
from transformers import pipeline
# Load the model and tokenizer
sentiment_pipeline = pipeline("sentiment-analysis", model="[YOUR_HF_USERNAME]/FinancialSentimentAnalyzer")
# Test cases
result1 = sentiment_pipeline("Tesla's revenue beat expectations, leading to a surge in stock price.")
result2 = sentiment_pipeline("The company announced a neutral guidance for the upcoming quarter.")
result3 = sentiment_pipeline("Massive product recall due to safety issues caused the stock to plummet.")
print(result1)
# [{'label': 'Positive', 'score': 0.998}]
print(result2)
# [{'label': 'Neutral', 'score': 0.985}]
print(result3)
# [{'label': 'Negative', 'score': 0.999}]