|
from transformers import AutoTokenizer, AutoModelForSequenceClassification |
|
|
|
|
|
|
|
|
|
model_name="mrm8488/distilroberta-finetuned-financial-news-sentiment-analysis" |
|
tokenizer = AutoTokenizer.from_pretrained(model_name) |
|
model = AutoModelForSequenceClassification.from_pretrained(model_name) |
|
|
|
|
|
text = "With the launch of Apple Silicon, Apple shares have increased" |
|
inputs = tokenizer(text, return_tensors="pt") |
|
outputs = model(**inputs) |
|
predictions = outputs.logits.argmax(dim=1).item() |
|
|
|
|
|
print("Predicted sentiment class:", predictions) |
|
|