Views
No views yet
roberta_finance_sentiment/
config.json
merges.txt
model.safetensors
special_tokens_map.json
tokenizer_config.json
tokenizer.json
vocab.jsonroberta_finance_sentiment/. Scripts and datasets are kept separate and are not included in this folder or in the model upload.1import torch
2from transformers import AutoTokenizer, AutoModelForSequenceClassification
3# Directory of the model folder
4model_dir = "roberta_finance_sentiment"
5# read the model
6tokenizer = AutoTokenizer.from_pretrained(model_dir)
7model = AutoModelForSequenceClassification.from_pretrained(model_dir)
8model.eval()
9
10# Example
11text = "Apple stock surges after strong earnings report."
12inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=128)
13with torch.no_grad():
14 logits = model(**inputs).logits
15 pred = torch.argmax(logits, dim=1).item()
16
17label_map = {0: 'negative', 1: 'neutral', 2: 'positive'}
18print(f"Predicted sentiment: {label_map[pred]}")roberta_finance_sentiment/ folder contains only the files needed for inference.