Instructions to use likhitjuttada/gemma-4-2b-finance-qlora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use likhitjuttada/gemma-4-2b-finance-qlora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/gemma-4-e2b-it-unsloth-bnb-4bit") model = PeftModel.from_pretrained(base_model, "likhitjuttada/gemma-4-2b-finance-qlora") - Transformers
How to use likhitjuttada/gemma-4-2b-finance-qlora with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="likhitjuttada/gemma-4-2b-finance-qlora") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("likhitjuttada/gemma-4-2b-finance-qlora", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use likhitjuttada/gemma-4-2b-finance-qlora with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "likhitjuttada/gemma-4-2b-finance-qlora" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "likhitjuttada/gemma-4-2b-finance-qlora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/likhitjuttada/gemma-4-2b-finance-qlora
- SGLang
How to use likhitjuttada/gemma-4-2b-finance-qlora with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "likhitjuttada/gemma-4-2b-finance-qlora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "likhitjuttada/gemma-4-2b-finance-qlora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "likhitjuttada/gemma-4-2b-finance-qlora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "likhitjuttada/gemma-4-2b-finance-qlora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Desktop
- Docker Model Runner
How to use likhitjuttada/gemma-4-2b-finance-qlora with Docker Model Runner:
docker model run hf.co/likhitjuttada/gemma-4-2b-finance-qlora
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
- 6