Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:AI4Finance Foundation FinGPT LoRA Fine Tuning

From Leeroopedia
Knowledge Sources
Domains Deep_Learning, Parameter_Efficient_Finetuning, NLP
Last Updated 2026-10-18 00:00 GMT

Overview

A parameter-efficient fine-tuning method that injects low-rank decomposition matrices into a pre-trained model's weight updates, enabling adaptation with a fraction of the trainable parameters.

Description

Low-Rank Adaptation (LoRA) freezes the pre-trained model weights and injects trainable rank-decomposition matrices into each target layer. For a weight matrix W0∈ℝd×k, the update becomes W0+ΔW=W0+BA where B∈ℝd×r, A∈ℝr×k, and r≪min⁡(d,k). Only A and B are trained, reducing trainable parameters by a factor of r/d.

In FinGPT, LoRA is applied to attention modules (q_proj, k_proj, v_proj, and optionally o_proj, gate_proj, up_proj, down_proj for Llama-2) with rank r=8, alpha=16-32, and dropout=0.1. This enables fine-tuning 7B-13B parameter models on single or few GPUs with limited VRAM.

Usage

Use this principle when:

  • Fine-tuning large models with limited GPU memory: LoRA reduces trainable parameters to <1% of the model.
  • Multi-task adaptation: Different LoRA adapters can be trained for different financial tasks.
  • Rapid experimentation: Small adapter sizes (r=8) enable quick training cycles.

LoRA is the dominant training approach across all FinGPT subprojects (Forecaster, Benchmark, Sentiment Analysis).

Theoretical Basis

The key insight is that fine-tuning updates have low intrinsic rank—the delta weights can be approximated by a low-rank decomposition. For a pre-trained weight matrix W0:

h=W0x+ΔWx=W0x+BAx

Where B is initialized to zero and A with a random Gaussian, so ΔW=BA=0 at the start. The scaling factor α/r controls the magnitude of the update:

h=W0x+αrBAx

LoRA configuration parameters:

  • r (rank): Controls the expressiveness of the adaptation. Lower = fewer parameters.
  • lora_alpha: Scaling factor. Typical: 2× the rank.
  • lora_dropout: Regularization on the LoRA inputs.
  • target_modules: Which weight matrices to adapt (model-specific).

Practical Guide

  • Use `r=8, lora_alpha=16-32, lora_dropout=0.1` as a starting configuration.
  • Target modules vary by architecture: Llama-2 uses `['q_proj', 'k_proj', 'v_proj']` (Benchmark) or the full 7-module set (Forecaster).
  • Enable `gradient_checkpointing_enable()` and `enable_input_require_grads()` for memory efficiency.
  • Set `model.config.use_cache = False` during training to save memory.
  • Use `TaskType.CAUSAL_LM` for causal language modeling tasks.

Related Pages

Implemented By

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment