Gemma 4 2B Finance Reasoning โ€” LoRA Adapter

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.

Model Details

  • Developed by: likhitjuttada
  • Model type: Causal LM โ€” LoRA adapter (attach to base model for inference)
  • Language: English
  • Finetuned from: unsloth/gemma-4-e2b-it-unsloth-bnb-4bit
  • PEFT version: 0.18.1

Uses

Direct Use

Personal finance Q&A โ€” budgeting, investing, debt management, wealth-building principles. The model reasons through questions step by step before giving a final answer.

Out-of-Scope Use

Not suitable for real financial advice, legal decisions, or domains outside personal finance. Does not handle numerical computation or live market data.

Training Details

Training Data

Synthetic instruction-following dataset generated from five personal finance books:

  • The Intelligent Investor โ€” Benjamin Graham
  • The Psychology of Money โ€” Morgan Housel
  • Rich Dad Poor Dad โ€” Robert Kiyosaki
  • The Richest Man in Babylon โ€” George S. Clason
  • Think and Grow Rich โ€” Napoleon Hill

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.

Training Procedure

Method: QLoRA (Quantized Low-Rank Adaptation) via Unsloth + TRL SFTTrainer on Kaggle T4 GPU.

Training Hyperparameters

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

LoRA Config

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

Compute

  • Hardware: Kaggle T4 (16GB VRAM)
  • Base model precision: nf4 (4-bit quantized, dequantized per block at runtime)
  • Adapter precision: fp16

How to Get Started

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))

Framework versions

  • PEFT 0.18.1
Downloads last month
7
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support