Skip to content

Repository files navigation

PEFT LoRA Study Project

This is a small study project to check whether I can fine-tune a LoRA adapter locally on an 8GB RTX 4060 laptop GPU.

It is not intended for production use. The banking terms-and-conditions dataset generation is just a convenient domain example for practicing the workflow.

What This Does

The project has two scripts:

  • generate_dataset.py reads a local plain-text terms-and-conditions file and uses DeepSeek's OpenAI-compatible API to generate instruction-tuning examples.
  • train_qwen.py fine-tunes a LoRA adapter locally with Unsloth using unsloth/Qwen3.5-2B.

The training script is configured for standard LoRA, not QLoRA:

model_name = "unsloth/Qwen3.5-2B"
load_in_4bit = False
load_in_16bit = True

Expected Local Files

Create this input file before generating the dataset:

bank_raw_tc.txt

Generated files are ignored by git:

bank_tc_dataset.json
bank_tc_dataset.progress.json
outputs/
qwen3.5_2b_bank_tc_lora/

Dataset Generation

Set a DeepSeek API key:

$env:DEEPSEEK_API_KEY = "your_api_key_here"

Then run:

python generate_dataset.py

The generator saves progress after each chunk. If interrupted, it resumes from bank_tc_dataset.progress.json. If bank_raw_tc.txt changes, it starts a fresh dataset to avoid mixing examples from different source documents.

Local LoRA Training

After bank_tc_dataset.json exists, run:

python train_qwen.py

The script expects CUDA. It is tuned for a local 8GB GPU study run:

  • Model: unsloth/Qwen3.5-2B
  • LoRA rank: 16
  • Sequence length: 2048
  • Batch size: 1
  • Gradient accumulation: 8
  • Max steps: 100
  • Optimizer: adamw_8bit

If training runs out of VRAM, reduce max_seq_length to 1024 or 512 first.

Unsloth Studio GUI

The same study workflow is documented for Unsloth Studio GUI in UNSLOTH_GUI.md.

Testing

Easy smoke tests and example evaluation prompts are documented in TESTING.md.

Notes

This project is for learning PEFT/LoRA mechanics:

  • generating a toy instruction dataset
  • formatting chat-style examples
  • attaching LoRA adapters
  • running a short local SFT training loop
  • saving the resulting adapter

It should not be treated as a reliable banking assistant, legal interpretation system, or production model.

Current Status

The repository now includes the local study dataset source, dataset generation script, LoRA training script, and notes for using Unsloth Studio GUI.

About

Study project for local LoRA fine-tuning with Unsloth on an 8GB RTX 4060

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages