Qwen3-4B Financial Sentiment Analyzer with Chain-of-Thought

Fine-tuned Qwen3-4B model for financial sentiment analysis with explicit reasoning.

Training Details

  • Base Model: Qwen3-4B
  • Method: SFT Warm-up + GRPO (Group Relative Policy Optimization)
  • Dataset: 8,541 financial news samples with CoT explanations
  • Training Time: ~4 hours on A100

Usage

With Ollama (Recommended for Mac M4)

# Download GGUF and Modelfile
huggingface-cli download Ayansk11/qwen3-4b-financial-sentiment-grpo --include "*.gguf" "Modelfile" --local-dir .

# Create Ollama model
ollama create financial-sentiment -f Modelfile

# Run inference
ollama run financial-sentiment "Analyze: Apple reported record Q4 earnings."

With Transformers (Python)

from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained("Ayansk11/qwen3-4b-financial-sentiment-grpo")
tokenizer = AutoTokenizer.from_pretrained("Ayansk11/qwen3-4b-financial-sentiment-grpo")

messages = [
    {"role": "system", "content": "You are a financial sentiment analyst..."},
    {"role": "user", "content": "Analyze: Tesla stock dropped 10%"}
]

inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True)
outputs = model.generate(inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0]))

Output Format

<reasoning>
1. Key financial indicators: [analysis]
2. Tone and language: [analysis]
3. Market implications: [analysis]
</reasoning>
<answer>positive/negative/neutral</answer>

Performance

  • Mac M4 Inference: 40-60 tokens/sec (Q5_K_M)
  • Memory Usage: ~4 GB (quantized)
  • File Size: ~2.89 GB (Q5_K_M GGUF)

Files

  • *.gguf - Quantized model for Ollama/llama.cpp
  • Modelfile - Ollama configuration with proper stop tokens
  • *.safetensors - Full PyTorch weights

License

Apache 2.0

Downloads last month
23
Safetensors
Model size
4B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Ayansk11/qwen3-4b-financial-sentiment-grpo

Finetuned
Qwen/Qwen3-4B
Quantized
(210)
this model

Dataset used to train Ayansk11/qwen3-4b-financial-sentiment-grpo