FinLoRA: Finetuning Quantized Financial Large Language Models Using Low-Rank Adaptation

Dannong Wang, Daniel Kim, Bo Jin, Xingjian Zhao, Tianfan Fu, Steve Yang, Xiao-Yang LiuarXiv 2024

TL;DR

This paper introduces FinLoRA, a method for efficiently finetuning large language models (LLMs) for financial tasks on commodity GPUs. By combining Quantized Low-Rank Adaptation (QLoRA) with distributed parallelism, FinLoRA significantly reduces memory requirements and training time, achieving up to 48% accuracy improvements on financial datasets while maintaining model performance.

What Problem Does This Paper Address?

Large Language Models (LLMs) have shown immense promise in various domains, including finance, for tasks like sentiment analysis and information extraction. However, finetuning these powerful models for specific financial applications presents significant challenges. Financial institutions often require local deployment due to privacy and regulatory concerns, which can be hindered by the substantial computational resources (especially GPU memory) needed for finetuning. Existing methods can be prohibitively expensive or require specialized hardware. This paper aims to bridge this gap by enabling efficient and cost-effective finetuning of LLMs for financial tasks on widely accessible GPUs.

Methods

The core of FinLoRA lies in its innovative combination of techniques:

  • Quantized Low-Rank Adaptation (QLoRA): This method is central to reducing computational demands. QLoRA leverages two key ideas:
  • Low-Rank Adaptation (LoRA): Instead of updating all parameters of a pre-trained LLM, LoRA injects small, trainable low-rank matrices into specific layers. This drastically reduces the number of trainable parameters, leading to lower memory usage and faster finetuning.
  • Quantization: QLoRA further compresses the model by quantizing the pre-trained weights to 8-bit or even 4-bit precision. During finetuning, these quantized weights are dynamically dequantized to 16-bit for computations involving the LoRA adapters, which themselves remain in 16-bit precision. This significantly cuts down GPU memory consumption.
  • Distributed Data Parallelism (DDP): To further accelerate training, the authors employ DDP. This technique distributes the training data across multiple GPUs, allowing each GPU to process a different subset of the data concurrently. Gradients are then synchronized across all GPUs, speeding up the overall training process.
  • Pipeline Parallelism: For inference, pipeline parallelism is used. This involves partitioning the LLM's layers across multiple GPUs, with each GPU responsible for processing a specific segment of the model. This is particularly useful for handling the large memory footprint of models during inference.
  • 0/1 Adam Optimizer: The paper also mentions using a modified Adam optimizer that linearizes Adam steps and uses 1-bit compression, aiming for faster convergence and reduced data volume.

Datasets

The paper utilizes a variety of datasets for finetuning and evaluation across different financial tasks:

  • Sentiment Analysis:
    • Financial Phrasebank (FPB): Sentences from financial news and reports annotated with sentiment labels.
  • FIQA SA: Similar to FPB, but from microblog headlines and financial news.
  • Twitter financial news sentiment (TFNS): Annotated tweets related to financial news.
  • News with GPT instruction (NWGI): Samples with seven sentiment labels, mapped to three for consistency.
  • Headline Classification:
    • Headline dataset: Categorizes headlines into "yes" or "no" based on predefined questions.
  • Named Entity Recognition (NER):
    • NER dataset: Annotates entities (location, person, organization) in sentences.
  • XBRL Tagging and Extraction:
    • FiNER dataset: Sentences annotated with 139 types of XBRL tags.
  • XBRL extraction dataset: Questions and answers derived from XBRL filings, used for extracting specific XBRL tags and values.

The authors note that for the XBRL extraction tasks, they use one-shot prompting to improve instruction following.

Key Insights and Ideas

  • QLoRA is a Game-Changer for Resource-Constrained Finetuning: The combination of low-rank adaptation and quantization proves highly effective in drastically reducing GPU memory requirements without sacrificing significant performance. This opens the door for finetuning large models on more accessible hardware.
  • Distributed Parallelism is Crucial for Scalability: While QLoRA reduces memory per parameter, DDP and pipeline parallelism are essential for handling larger models and accelerating the overall finetuning and inference processes, especially when multiple GPUs are available.
  • Financial Tasks Benefit Significantly from Specialized Finetuning: The experiments show substantial accuracy gains on various financial tasks, highlighting that general-purpose LLMs, even large ones, can be greatly improved by domain-specific finetuning using efficient methods like FinLoRA.
  • 4-bit Quantization is Viable for Large Models: The paper demonstrates that even with 4-bit quantization, comparable performance to 8-bit or even 16-bit finetuning can be achieved, especially for larger models like Llama 3.1-70B, making them more practical for deployment.

Key Results

  • Accuracy Improvements: Finetuned Llama 3.1 8B models achieved up to a 48% average increase in accuracy compared to their base models across various financial tasks. Notably, even with 4-bit quantization and a lower rank (r=4), the finetuned 8B model performed comparably to its 8-bit, rank 8 counterpart.
  • Memory Reduction: Table 1 and Table 6 clearly illustrate the significant memory savings. For instance, finetuning Llama 3.1-8B with 4-bit QLoRA (r=4) uses only 8.65 GB of GPU memory during inference, a fraction of the base model's requirement. For the 70B model, 4-bit quantization reduces memory usage to around 37.89 GB.
  • Efficiency: The paper highlights that finetuning is achievable with four GPUs and less than 20 hours of training time per task, making it a feasible option for many institutions.

Limitations and Future Work

  • Limitations:
    • While the paper demonstrates effectiveness on commodity GPUs, the exact hardware configuration (four NVIDIA RTX A6000 GPUs, each with 48 GB) is still substantial. The paper notes that finetuning is achievable with one GPU (48GB) but implies longer training times.
  • The paper focuses on specific financial tasks; broader applicability across a wider range of financial NLP problems might require further investigation.
  • Future Work:
    • The authors plan to explore multi-task finetuning for classification tasks.
  • They also aim to expand their investigation into XBRL-related tasks, enabling FinLORA to handle more complex analysis and reasoning. This could further enhance the utility of LLMs in financial reporting and analysis.

Summary updated

BibTeX
@misc{wang2024finlora,
  author = {Dannong Wang and Daniel Kim and Bo Jin and Xingjian Zhao and Tianfan Fu and Steve Yang and Xiao-Yang Liu},
  title = {{FinLoRA: Finetuning Quantized Financial Large Language Models Using Low-Rank Adaptation}},
  year = {2024},
  eprint = {2412.11378},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.11378},
}
Figure