Downloads · 30 days
0
iPwnds/finanalyst-qwen1.5b
finanalyst-qwen1.5b is a text generation model from iPwnds. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
A financial analyst LLM fine-tuned from Qwen2.5-1.5B-Instruct using QLoRA (4-bit NF4 quantisation + LoRA adapters) on custom instruction-tuning data generated from live stock market data. The model produces analyst-st…
Downloads · 30 days
0
Access
Public
Updated May 8, 2026
Repo size
20.2 MB
Likes
0
Public
Click a slice to open those files.
.json11.4 MB · 57%
From the Hugging Face model README
A financial analyst LLM fine-tuned from Qwen2.5-1.5B-Instruct using QLoRA (4-bit NF4 quantisation + LoRA adapters) on custom instruction-tuning data generated from live stock market data. The model produces analyst-style responses for stock analysis, market overviews, and free-form financial Q&A.
It runs fully locally — no API keys required. On Apple Silicon it uses MPS acceleration; on a machine with a CUDA GPU it uses that automatically; otherwise it falls back to CPU.
finanalyst-qwen1.5b is a parameter-efficient fine-tune of Qwen/Qwen2.5-1.5B-Instruct trained to behave like a senior sell-side analyst. It was fine-tuned using QLoRA: the base model is loaded in 4-bit NF4 quantisation (keeping weights at ~1 GB) while small LoRA adapter matrices are injected into the attention projection layers and trained on financial instruction data. Only 0.14% of the total parameters (2.18M out of 1.54B) were updated during training.
The model is the generative core of the AI Stock Market Analyst CLI — a Bloomberg-style terminal that uses this model for all text generation (stock deep-dives, market overviews, watchlist digests, and natural-language Q&A).
Qwen/Qwen2.5-1.5B-Instructnotebooks/FinAnalyst_Generative.ipynbiPwnds/finsentiment-distilbertThe model is designed to generate analyst-style financial commentary given a structured prompt containing live market data (price, fundamentals, news sentiment). It handles three task types out of the box:
The model plugs directly into the AI Stock Market Analyst CLI via analysis/llm.py, which loads it with AutoPeftModelForCausalLM, merges the LoRA adapter into the base weights for faster inference, and exposes ask_llm() / ask_llm_json() helper functions used throughout the application.
It can also be used as a drop-in instruction-following LLM for any financial NLP pipeline that needs analyst-style prose generation.
Qwen2.5-1.5B-Instruct, may carry biases inherited from its pre-training corpus.Always supply the model with current, factual market data in the prompt (price, fundamentals, news). Do not rely on the model's parametric knowledge for specific numerical claims. All output should be reviewed by a qualified professional before informing any financial decision.
from peft import AutoPeftModelForCausalLM
from transformers import AutoTokenizer, pipeline
import torch
MODEL = "iPwnds/finanalyst-qwen1.5b"
# Detect device
if torch.backends.mps.is_available():
device_map, dtype = {"": "mps"}, torch.float16
elif torch.cuda.is_available():
device_map, dtype = "auto", torch.float16
else:
device_map, dtype = {"": "cpu"}, torch.float32
# Load base model + LoRA adapter, then merge for faster inference
model = AutoPeftModelForCausalLM.from_pretrained(
MODEL,
torch_dtype=dtype,
device_map=device_map,
).merge_and_unload()
tokenizer = AutoTokenizer.from_pretrained(MODEL)
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
messages = [
{"role": "system", "content": "You are a senior equity analyst. Be concise and data-driven."},
{"role": "user", "content": "Is NVDA overbought at current levels given its AI growth story?"},
]
result = pipe(messages, max_new_tokens=512, temperature=0.3, do_sample=True)
print(result[0]["generated_text"][-1]["content"])
The model uses the ChatML chat template (<|im_start|> / <|im_end|>) inherited from Qwen2.5-1.5B-Instruct. Always pass messages as a list of role/content dicts rather than raw strings.
Training data was generated programmatically by scripts/generate_training_data.py, which:
yfinance for a curated list of 23 tickers (large-cap US equities across major sectors).Qwen2.5-1.5B-Instruct to generate reference analyst responses.{"instruction", "input", "output", "task_type", "ticker"} format.The final dataset contains 68 instruction pairs split across:
| Task type | Count |
|---|---|
stock_analysis | 21 |
ask (free-form Q&A) | 46 |
market_overview | 1 |
The 90/10 train/test split gives 61 training examples and 7 evaluation examples.
Fine-tuning was performed in Google Colab on a T4 GPU (15 GB VRAM) using SFTTrainer from the trl library.
Each example was formatted into the Qwen2.5 ChatML template:
<|im_start|>system
{instruction}<|im_end|>
<|im_start|>user
{input}<|im_end|>
<|im_start|>assistant
{output}<|im_end|>
Sequences were truncated to a maximum of 512 tokens (set via tokenizer.model_max_length).
| Hyperparameter | Value |
|---|---|
| Base model | Qwen/Qwen2.5-1.5B-Instruct |
| Quantisation | 4-bit NF4 + double quantisation |
| Compute dtype | float16 |
LoRA rank (r) | 16 |
| LoRA alpha | 32 |
| LoRA target modules | q_proj, v_proj |
| LoRA dropout | 0.05 |
| Trainable parameters | 2,179,072 / 1,545,893,376 (0.14%) |
| Epochs | 3 |
| Per-device batch size | 1 |
| Gradient accumulation steps | 8 (effective batch size: 8) |
| Learning rate | 2e-4 |
| Max sequence length | 512 tokens |
| Mixed precision | None (fp16=False, bf16=False) |
| Gradient checkpointing | Enabled |
| Optimizer | AdamW (default) |
Note on mixed precision: Qwen2.5's layer norms remain in BFloat16 regardless of
dtype, which conflicts with PyTorch's fp16 AMP scaler. Settingfp16=False, bf16=Falseletsbitsandbyteshandle precision internally and avoids the_amp_foreach_non_finite_check_and_unscale_cudaerror on T4.
| Training time | ~4 minutes (T4 GPU, Google Colab) |
| Total steps | 24 |
| Adapter size (pushed to Hub) | ~8 MB |
| Base model size (downloaded at inference) | ~3 GB |
| Training loss (final) | 1.5266 |
A random 10% split (7 examples, seed=42) held out from the same generated dataset. The small size means evaluation loss should be interpreted qualitatively — it indicates whether the model is learning the response style rather than serving as a rigorous benchmark.
Evaluation loss (cross-entropy on held-out completions) was used as the primary training signal. No external benchmarks were run; the model is evaluated end-to-end within the CLI application by inspecting output quality on real analyst prompts.
| Metric | Value |
|---|---|
| Final training loss | 1.5266 |
| Final evaluation loss | 1.4721 |
| Eval runtime | 3.78 s (7 samples) |
The evaluation loss being slightly lower than training loss is consistent with the very small dataset size and indicates the model generalised to the held-out examples rather than overfitting.
The model successfully learns the instruction-following format and analyst prose style within 3 epochs on 61 examples. Responses are coherent, stay on-topic, and reference the data provided in the prompt. The primary limitation is dataset size — broader coverage of tickers, task types, and market conditions would improve robustness.
Training was performed on a Google Colab T4 GPU for approximately 4 minutes. Estimated carbon emissions are negligible at this scale.
bitsandbytes, with low-rank adapter matrices (LoRA) injected into the q_proj and v_proj layers of each attention block<|im_start|> / <|im_end|>)| Package | Role |
|---|---|
transformers | Model loading, tokenisation, pipeline |
peft | LoRA adapter injection and AutoPeftModelForCausalLM |
trl | SFTTrainer / SFTConfig for supervised fine-tuning |
bitsandbytes ≥ 0.46.1 | 4-bit NF4 quantisation |
accelerate | Device placement and distributed training |
datasets | Dataset formatting and train/test split |
Florian Braun (@iPwnds)