Research Project

PhinGPT: A Homemade Language Model for the Financial Sector

Large language models are revolutionizing various fields of knowledge. This work aims to train a specialized model for the financial sector by optimizing computational costs with optimal training.

FinanceAILLMsNLPQLoRA
English | Español

Key Highlights

Overview

Financial text analysis presents unique challenges that require specialized language models. PhinGPT addresses this gap by providing an efficient, open-source language model specifically designed for financial applications.

We leverage QLoRA (Quantized Low-Rank Adaptation), a state-of-the-art fine-tuning technique that dramatically reduces memory requirements and training costs while maintaining model performance. This approach makes advanced NLP accessible to researchers and practitioners with limited computational resources.

Motivation

Traditional large language models require substantial computational resources for fine-tuning, making them inaccessible to many research groups and small organizations. Additionally, general-purpose models often struggle with domain-specific terminology and contexts found in financial documents.

PhinGPT was developed to:

Methodology

Model Architecture

PhinGPT is based on a transformer architecture with the following characteristics:

QLoRA Fine-Tuning

QLoRA enables efficient fine-tuning through:

  1. 4-bit Quantization: Reduces memory footprint by ~75%
  2. Low-Rank Adapters: Trains only a small subset of parameters
  3. Double Quantization: Further compression without performance loss
  4. Paged Optimizers: Handles memory spikes during training

This combination allows training on consumer-grade GPUs (e.g., RTX 3090, A100 40GB) instead of requiring multi-GPU clusters.

Evaluation

Tasks

PhinGPT was evaluated on two primary financial NLP tasks:

1. Named Entity Recognition (NER)

Identifying and classifying entities in financial text:

2. Text Classification

Categorizing financial documents by:

Results

TaskPhinGPTBaselineImprovement
Financial NER87.3% F182.1% F1+5.2%
Sentiment Classification89.5% Acc85.2% Acc+4.3%
Document Classification91.2% Acc88.7% Acc+2.5%

Baseline: General-purpose LLM without financial fine-tuning

Key Findings

Applications

PhinGPT can be applied to various financial use cases:

Automated Document Processing

Market Intelligence

Risk Management

Research & Analysis

Technical Implementation

Training Details

# Example QLoRA configuration
from peft import LoraConfig, get_peft_model
from transformers import AutoModelForCausalLM

# Load base model in 4-bit
model = AutoModelForCausalLM.from_pretrained(
    "base-model",
    load_in_4bit=True,
    device_map="auto"
)

# Configure LoRA
lora_config = LoraConfig(
    r=16,  # LoRA rank
    lora_alpha=32,
    target_modules=["q_proj", "v_proj"],
    lora_dropout=0.05,
    bias="none",
    task_type="CAUSAL_LM"
)

# Apply LoRA
model = get_peft_model(model, lora_config)

Inference

Using PhinGPT is straightforward with the Hugging Face API:

from transformers import AutoTokenizer, AutoModelForCausalLM

# Load model
tokenizer = AutoTokenizer.from_pretrained("RobertGomezDP/phingpt-cls")
model = AutoModelForCausalLM.from_pretrained("RobertGomezDP/phingpt-cls")

# Generate predictions
text = "Apple Inc. reported Q3 earnings of $1.2B..."
inputs = tokenizer(text, return_tensors="pt")
outputs = model.generate(**inputs, max_length=100)
result = tokenizer.decode(outputs[0])

Future Work

We are actively developing PhinGPT with planned improvements:

Short-term (2024-2025)

Long-term

Community & Contributions

PhinGPT is an open-source project, and we welcome contributions:

Citation

If you use PhinGPT in your research, please cite:

@article{phingpt2024,
  title={PhinGPT: Efficient Fine-Tuning of Language Models for Financial Applications},
  author={Peña, Tuli and Gomez, Robert and Gutiérrez, Francisco José},
  journal={Under Review},
  year={2024}
}

Acknowledgments

This work was supported by the Universidad Nacional de Colombia through the SIMG (Semillero de Investigación en Modelos Generativos) seed research program. We thank the open-source community for tools and datasets that made this project possible.

Special thanks to:


Want to learn more or collaborate? Contact us through the SIMG website or join our community discussions on Hugging Face.

Publications

PhinGPT: Efficient Fine-Tuning of Language Models for Financial Applications

Tuli Peña, Robert Gomez, Francisco José Gutiérrez

Under Review June 20, 2024 preprint

Resources

Team & Collaborators

Researchers

  • Tuli Peña
  • Robert Gomez
  • Francisco José Gutiérrez

Collaborators

SIMG Research Group

Universidad Nacional de Colombia

Supported by