Downloads · 30 days
9
2% of all-time downloads
nusret35/roberta-financial-news-impact-analysis
roberta-financial-news-impact-analysis is a machine learning model from nusret35. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as mit.
This is a RoBERTa-base model trained on 15k financial news title from January 1, 2021 to April 22, 2024 and finetuned for market impact analysis. The data is taken from forexfactory.com. This model is suitable for Eng…
Downloads · 30 days
9
2% of all-time downloads
All-time downloads
562
Public
Repo size
997 MB
Likes
0
Public
Click a slice to open those files.
.bin499 MB · 100%
From the Hugging Face model README
This is a RoBERTa-base model trained on 15k financial news title from January 1, 2021 to April 22, 2024 and finetuned for market impact analysis. The data is taken from forexfactory.com. This model is suitable for English.
Labels: 0 -> Low, 1 -> Medium, 2 -> High
from transformers import AutoModelForSequenceClassification
from transformers import RobertaTokenizerFast
import torch
label_mapping = {
0: "Low",
1: "Medium",
2: "High"
}
MODEL = "nusret35/roberta-financial-news-impact-analysis"
tokenizer = RobertaTokenizerFast.from_pretrained('roberta-base')
model = AutoModelForSequenceClassification.from_pretrained(MODEL)
input_text = "German Buba President Nagel Speaks"
encoding = tokenizer(input_text, padding='max_length', truncation=True, max_length=128, return_tensors='pt')
input_ids = encoding['input_ids'].flatten()
attention_mask = encoding['attention_mask'].flatten()
input_ids = input_ids.unsqueeze(0)
attention_mask = attention_mask.unsqueeze(0)
output = model(input_ids,attention_mask)
predicted_class_index = torch.argmax(output.logits)
predicted_label = label_mapping[predicted_class_index.item()]
print("Predicted Impact:", predicted_label)
Output:
Predicted Impact: Low