zeroshot/twitter-financial-news-sentiment
Viewer • Updated • 11.9k • 4.69k • 168
How to use codealchemist01/financial-sentiment-bert-large with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="codealchemist01/financial-sentiment-bert-large") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("codealchemist01/financial-sentiment-bert-large")
model = AutoModelForSequenceClassification.from_pretrained("codealchemist01/financial-sentiment-bert-large")BERT-Large financial sentiment analysis model with high accuracy
This model is fine-tuned from bert-large-uncased for financial sentiment analysis, capable of classifying financial text into three categories:
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("codealchemist01/financial-sentiment-bert-large")
model = AutoModelForSequenceClassification.from_pretrained("codealchemist01/financial-sentiment-bert-large")
# Example usage
text = "Apple stock is showing strong growth potential"
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
predicted_class = torch.argmax(predictions, dim=-1).item()
# Labels: 0=Bearish, 1=Neutral, 2=Bullish
labels = ["Bearish", "Neutral", "Bullish"]
print(f"Prediction: {labels[predicted_class]}")
This model is specifically trained for financial sentiment analysis and may not perform well on general sentiment analysis tasks.
If you use this model, please cite:
@misc{financial-sentiment-large,
author = {CodeAlchemist01},
title = {financial-sentiment-bert-large},
year = {2024},
publisher = {Hugging Face},
url = {https://huggingface.co/codealchemist01/financial-sentiment-bert-large}
}