Downloads · 30 days
5
16% of all-time downloads
likhitjuttada/gemma-4-2b-finance-qlora
gemma-4-2b-finance-qlora is a text generation model from likhitjuttada. Use it when you need the model to write or continue text. It is set up for peft.
A QLoRA fine-tune of Gemma 4 2B IT for personal finance reasoning. The model answers finance questions with a structured <think reasoning block followed by a plain-language response.
Downloads · 30 days
5
16% of all-time downloads
All-time downloads
31
Public
Repo size
156 MB
Likes
0
Public
Click a slice to open those files.
.safetensors124 MB · 79%
From the Hugging Face model README
A QLoRA fine-tune of Gemma 4 2B IT for personal finance reasoning. The model answers finance questions with a structured <think> reasoning block followed by a plain-language response.
Personal finance Q&A — budgeting, investing, debt management, wealth-building principles. The model reasons through questions step by step before giving a final answer.
Not suitable for real financial advice, legal decisions, or domains outside personal finance. Does not handle numerical computation or live market data.
Synthetic instruction-following dataset generated from five personal finance books:
Principles were extracted from each book, then used to generate multi-turn QA pairs with chain-of-thought reasoning. A contrast set (type_c_contrasts) was added to sharpen decision boundaries.
Method: QLoRA (Quantized Low-Rank Adaptation) via Unsloth + TRL SFTTrainer on Kaggle T4 GPU.
| Parameter | Value |
|---|---|
| Training regime | fp16 mixed precision |
| Epochs | 3 |
| Per-device batch size | 2 |
| Gradient accumulation steps | 8 (effective batch = 16) |
| Learning rate | 2e-4 |
| Warmup steps | 100 |
| Max sequence length | 2048 |
| Packing | disabled |
| Checkpoint selection | best eval loss |
| Parameter | Value |
|---|---|
| Rank (r) | 16 |
| Alpha | 16 |
| Dropout | 0 |
| Bias | none |
| Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
base_model_id = 'unsloth/gemma-4-E2B-it'
adapter_path = 'path/to/gemma-lora'
token = 'your_hf_token'
tokenizer = AutoTokenizer.from_pretrained(base_model_id, token=token)
model = AutoModelForCausalLM.from_pretrained(
base_model_id,
torch_dtype=torch.float16,
device_map='cuda',
token=token,
)
model = PeftModel.from_pretrained(model, adapter_path)
model.eval()
messages = [{'role': 'user', 'content': 'Should I invest in index funds or individual stocks?'}]
inputs = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors='pt').to(model.device)
with torch.no_grad():
output_ids = model.generate(inputs, max_new_tokens=512, temperature=0.7, do_sample=True)
print(tokenizer.decode(output_ids[0][inputs.shape[-1]:], skip_special_tokens=True))