Downloads · 30 days
0
jialeCharlotte/finbot
finbot is a machine learning model from jialeCharlotte. 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 mit.
This model fine-tunes the DeepSeek-R1-Distill-Qwen-1.5B model to analyze sentiment in financial news and reports. It classifies financial news into Bullish, Bearish, or Neutral sentiment categories based on the implie…
Downloads · 30 days
0
Access
Public
Updated Mar 16, 2025
Repo size
4.4 MB
Likes
0
Public
Click a slice to open those files.
.safetensors4.4 MB · 100%
From the Hugging Face model README
This model fine-tunes the DeepSeek-R1-Distill-Qwen-1.5B model to analyze sentiment in financial news and reports. It classifies financial news into Bullish, Bearish, or Neutral sentiment categories based on the implied impact on specific stocks.
This model is designed to help investors, traders, and financial analysts quickly assess the sentiment implications of financial news for specific stocks. It can be used for:
You can use this model to analyze the sentiment of financial news by providing a news title, summary, and the stock ticker:
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
import json
# Load model and tokenizer
model_name = "jialeCharlotte/finbot"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map="auto")
def analyze_sentiment(news_title, news_summary, ticker):
prompt = f"""You are a financial analyst in a leading hedge fund.
Analyze the sentiment of the following financial news for the given stock ticker step by step.
Title: "{news_title}"
Summary: "{news_summary}"
Stock Ticker: {ticker}
Step 1: Identify key financial terms and their implications.
Step 2: Determine whether the news suggests market optimism, pessimism, or neutrality for this specific stock.
Step 3: Based on your analysis, classify the sentiment into one of the following categories:
- "Bullish": If the news suggests confidence, growth, or positive impact on this stock.
- "Bearish": If the news suggests decline, risks, or negative impact on this stock.
- "Neutral": If the news is ambiguous or does not convey strong sentiment.
Finally, **return only** the final result in valid JSON format, with the structure:
{{
"ticker": "{ticker}",
"sentiment": "Bullish" | "Bearish" | "Neutral",
"sentiment_reasoning": "Provide a brief explanation of the sentiment analysis."
}}
Do not include any extra text or explanations outside the JSON.
### Response:
"""
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=200,
do_sample=True,
temperature=0.7,
top_p=0.9,
pad_token_id=tokenizer.pad_token_id
)
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
try:
# Parse the JSON response
result = json.loads(response)
return result
except json.JSONDecodeError:
# If the response isn't valid JSON, return the raw text
return {"error": "Failed to parse response", "raw_response": response}
# Example usage
news_title = "Apple Reports Record Q1 Revenue"
news_summary = "Apple Inc. announced today that they have achieved record-breaking revenue in Q1 2025, exceeding analyst expectations by 15%."
ticker = "AAPL"
result = analyze_sentiment(news_title, news_summary, ticker)
print(result)
The model was trained on a curated dataset of financial news articles and reports, each labeled with sentiment classifications (Bullish, Bearish, or Neutral) specific to the mentioned stock tickers. The training data includes diverse sources of financial information covering various market sectors and company types.
This model is intended to assist with financial analysis but should not be the sole basis for investment decisions. Users should:
If you use this model in your research or application, please cite:
@misc{finbot2025,
author = {Charlotte Zhou, Zhilin Zhu},
title = {FinBot - Financial Sentiment Analyzer},
year = {2025},
publisher = {HuggingFace},
howpublished = {\url{https://huggingface.co/jialeCharlotte/finbot}}
}