Downloads · 30 days
9
19% of all-time downloads
vinD27/stock_news
stock_news is a machine learning model from vinD27. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
This model was fine-tuned using the Hugging Face transformers library.
Downloads · 30 days
9
19% of all-time downloads
All-time downloads
48
Public
Parameters
184M
740 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors738 MB · 99%
From the Hugging Face model README
This model was fine-tuned using the Hugging Face transformers library.
pytorch_model.bin: Model weightsconfig.json: Model configurationtokenizer.json: Tokenizer vocabularyspecial_tokens_map.json: Special token mappingstokenizer_config.json: Tokenizer configurationfrom transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
# Load the model and tokenizer from Hugging Face Hub
model_name = "vinD27/stock_news" # Replace with your model repo name
model = AutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
# Map label indices to human-readable class names
label_mapping = {
0: "negative",
1: "neutral",
2: "positive"
}
# Input text
input_text = "Wow. The stock is amazing"
# Tokenize and predict
inputs = tokenizer(input_text, return_tensors="pt", truncation=True, padding=True, max_length=128)
outputs = model(**inputs)
predicted_class_idx = torch.argmax(outputs.logits, dim=-1).item() # Get the predicted label index
# Print the results
print(f"Your input is: '{input_text}'")
print(f"And the prediction is: {label_mapping[predicted_class_idx]} ({predicted_class_idx})")