Principle:AI4Finance Foundation FinGPT LoRA Fine Tuning
| 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 , the update becomes where , , and . Only and are trained, reducing trainable parameters by a factor of .
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 :
Where is initialized to zero and with a random Gaussian, so at the start. The scaling factor controls the magnitude of the update:
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
- Implementation:AI4Finance_Foundation_FinGPT_LoraConfig_get_peft_model
- Implementation:AI4Finance_Foundation_FinGPT_AutoModelForCausalLM_from_pretrained
- Implementation:AI4Finance_Foundation_FinGPT_convert_linear_layer_to_lora
- Implementation:AI4Finance_Foundation_FinGPT_parse_model_name