Downloads · 30 days
5
6% of all-time downloads
MadhurArora1/mistral-7b-finance-qlora
mistral-7b-finance-qlora is a machine learning model from MadhurArora1. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as apache-2.0.
A fine-tuned version of Mistral-7B-v0.1 on financial question-answering data using QLoRA (Quantized Low-Rank Adaptation).
Downloads · 30 days
5
6% of all-time downloads
All-time downloads
81
Public
Parameters
7.2B
15 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors14.7 GB · 98%
From the Hugging Face model README
A fine-tuned version of Mistral-7B-v0.1 on financial question-answering data using QLoRA (Quantized Low-Rank Adaptation).
This model was fine-tuned to answer financial questions accurately and concisely. It handles topics like investment concepts, financial ratios, market instruments, macroeconomics, and corporate finance.
| Parameter | Value |
|---|---|
| Epochs | 2 |
| Batch size (per device) | 2 |
| Gradient accumulation steps | 8 |
| Effective batch size | 16 |
| Learning rate | 2e-4 |
| LR scheduler | Cosine |
| Warmup ratio | 0.03 |
| Optimizer | paged_adamw_32bit |
| Max sequence length | 512 |
| Quantization | NF4 4-bit (double quant) |
| Compute dtype | float16 |
| Hardware | Kaggle T4 x2 |
| Training time | ~5 hours |
| Epoch | Training Loss | Validation Loss |
|---|---|---|
| 1 | 1.2723 | 1.4589 |
| 2 | 1.0242 | 1.5069 |
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
import torch
base_model_id = "mistralai/Mistral-7B-v0.1"
adapter_id = "MadhurArora1/mistral-7b-finance-qlora"
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16
)
tokenizer = AutoTokenizer.from_pretrained(adapter_id)
model = AutoModelForCausalLM.from_pretrained(
base_model_id,
quantization_config=bnb_config,
device_map="auto"
)
model = PeftModel.from_pretrained(model, adapter_id)
def ask(question, max_new_tokens=200):
prompt = f"Below is a financial question. Answer it accurately and concisely.\n\n### Question:\n{question}\n\n### Answer:\n"
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
with torch.no_grad():
output = model.generate(
**inputs,
max_new_tokens=max_new_tokens,
temperature=0.1,
do_sample=True,
pad_token_id=tokenizer.eos_token_id
)
return tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
print(ask("What is the P/E ratio and how do investors use it?"))
print(ask("Explain the difference between stocks and bonds."))
print(ask("What is compound interest?"))
Q: What is the P/E ratio and how do investors use it?
The P/E ratio (Price-to-Earnings ratio) measures how much investors are willing to pay for each dollar of a company's earnings. It is calculated by dividing the stock price by earnings per share (EPS). A high P/E may indicate the market expects strong future growth, while a low P/E may suggest undervaluation or slow growth expectations. Investors use it to compare companies within the same industry.
Q: What is the difference between ROE and ROA?
ROE (Return on Equity) measures how efficiently a company generates profit from shareholders' equity, while ROA (Return on Assets) measures profitability relative to total assets. ROE focuses on returns to equity holders and is affected by leverage; ROA is a broader measure of operational efficiency regardless of how assets are financed.
Madhur Arora — Backend SWE | AI/ML enthusiast
GitHub | LinkedIn
If you use this model, please cite the base model:
@misc{mistral7b,
title={Mistral 7B},
author={Mistral AI},
year={2023},
url={https://huggingface.co/mistralai/Mistral-7B-v0.1}
}