Coder Social home page Coder Social logo

yuweiyin / finpt Goto Github PK

View Code? Open in Web Editor NEW
22.0 2.0 3.0 84 KB

FinPT: Financial Risk Prediction with Profile Tuning on Pretrained Foundation Models

Home Page: https://arxiv.org/abs/2308.00065

License: MIT License

Python 100.00%
financial-data large-language-models financial-risk-prediction

finpt's Introduction

FinPT: Financial Risk Prediction with Profile Tuning on Pretrained Foundation Models

License: MIT arXiv

picture

  • Abstract:
Financial risk prediction plays a crucial role in the financial sector. 
Machine learning methods have been widely applied for automatically 
detecting potential risks and thus saving the cost of labor.
However, the development in this field is lagging behind in recent years 
by the following two facts: 1) the algorithms used are somewhat outdated, 
especially in the context of the fast advance of generative AI and 
large language models (LLMs); 2) the lack of a unified and open-sourced 
financial benchmark has impeded the related research for years.
To tackle these issues, we propose FinPT and FinBench: the former is a 
novel approach for financial risk prediction that conduct Profile Tuning 
on large pretrained foundation models, and the latter is a set of 
high-quality datasets on financial risks such as default, fraud, and churn.
In FinPT, we fill the financial tabular data into the pre-defined instruction 
template, obtain natural-language customer profiles by prompting LLMs, and 
fine-tune large foundation models with the profile text to make predictions.
We demonstrate the effectiveness of the proposed FinPT by experimenting with 
a range of representative strong baselines on FinBench. The analytical studies 
further deepen the understanding of LLMs for financial risk prediction.

Environment

conda create -n finpt python=3.9
conda activate finpt
pip install -r requirements.txt

Data

from datasets import load_dataset

# ds_name_list = ["cd1", "cd2", "ld1", "ld2", "ld3", "cf1", "cf2", "cc1", "cc2", "cc3"]
ds_name = "cd1"  # change the dataset name here
dataset = load_dataset("yuweiyin/FinBench", ds_name)

Experiments

The instructions obtained in Step 1 and customer profiles generated in Step 2 are provided as X_instruction_for_profile and X_profile in FinBench.

Run Tree-based Baselines

SAVE_DIR="./log/baseline_tree/"
mkdir -p "${SAVE_DIR}"

DATASETS=("cd1" "cd2" "cd3" "ld1" "ld2" "cf1" "cc1" "cc2" "cc3")
MODELS=("RandomForestClassifier" "XGBClassifier" "CatBoostClassifier" "LGBMClassifier")
SEEDS=(0 1 42 1234)

for dataset in "${DATASETS[@]}"; do
  for model in "${MODELS[@]}"; do
    for seed in "${SEEDS[@]}"; do
      echo -e "\n\n\n>>> run_step3_baseline_tree.py: dataset: ${dataset}; model: ${model} seed: ${seed}"
      python run_step3_baseline_tree.py --ds_name "${dataset}" --model_name ${model} --seed ${cur_seed} --grid_search \
        > "${SAVE_DIR}/${dataset}-${model}-${seed}.log"
    done
  done
done

Run Neural Network Baselines

SAVE_DIR="./log/baseline_nn/"
mkdir -p "${SAVE_DIR}"

DATASETS=("cd1" "cd2" "cd3" "ld1" "ld2" "cf1" "cc1" "cc2" "cc3")
MODELS=("DeepFM" "STG" "VIME" "TabNet")
SEEDS=(0 1 42 1234)

for dataset in "${DATASETS[@]}"; do
  for model in "${MODELS[@]}"; do
    for seed in "${SEEDS[@]}"; do
      echo -e "\n\n\n>>> run_step3_baseline_nn.py: dataset: ${dataset}; model: ${model} seed: ${seed}"
      python run_step3_baseline_nn.py --cuda "0" --ds_name "${dataset}" --model_name ${model} --seed ${cur_seed} \
        > "${SAVE_DIR}/${dataset}-${model}-${seed}.log"
    done
  done
done

Run FinPT

SAVE_DIR="./log/finpt/"
mkdir -p "${SAVE_DIR}"

DATASETS=("cd1" "cd2" "cd3" "ld1" "ld2" "cf1" "cc1" "cc2" "cc3")
MODELS=("bert" "finbert" "gpt2" "t5-base" "flan-t5-base" "t5-xxl" "flan-t5-xxl" "llama-7b" "llama-13b")

for dataset in "${DATASETS[@]}"; do
  for model in "${MODELS[@]}"; do
      echo -e "\n\n\n>>> run_step3_finpt.py: dataset: ${dataset}; model: ${model} seed: ${seed}"
      python run_step3_finpt.py --cuda "0,1" --ds_name "${dataset}" --model_name ${model} --use_pos_weight \
        > "${SAVE_DIR}/${dataset}-${model}-${seed}.log"
  done
done

License

Please refer to the LICENSE file for more details.

Citation

@article{yin2023finpt,
  title   = {FinPT: Financial Risk Prediction with Profile Tuning on Pretrained Foundation Models},
  author  = {Yin, Yuwei and Yang, Yazheng and Yang, Jian and Liu, Qi},
  journal = {arXiv preprint arXiv:2308.00065},
  year    = {2023},
  url     = {https://arxiv.org/abs/2308.00065},
}

finpt's People

Contributors

yuweiyin avatar

Stargazers

Coolixz avatar Himanshu Chaudhary avatar  avatar Zekun Jiang avatar kychanbp avatar Xu Han avatar  avatar Seongwoo Lim avatar Won Jo avatar YangSUN avatar  avatar first avatar  avatar  avatar Novi Amanda Puspita Sari avatar Buraka avatar 808OVADOZE avatar  avatar Jeff Carpenter avatar Nathan Gold avatar 唐国梁Tommy avatar Guanlin Li avatar

Watchers

Kostas Georgiou avatar  avatar

finpt's Issues

Reproducibility

Hello, thank you for releasing your code. However, I have a question.

When I tried to reproduce the result of FinBERT on CF1, the test F1 score was not the same as in your paper.

Paper: 45.1
Reproduced: 34.3
I suspect the problem may stem from unspecified package versions. Although I have spent a lot of time trying to align the package versions with the code, I almost didn't modify the code.

Could you inform me about the specific versions of the packages? If you have any ideas about other possible issues, sharing them would also help me solve this problem.

Reproducibility of the results

Hi,
I have been trying to re-implement the paper but in many of the combinations of the dataset and model that is being for training and evaluation, the F1-scores and accuracies are at a constant value from the very first epoch till the last (F1-score is at 0 and Accuracy at 0.9153) although the loss decreases. I have not changed any of the code and am unable to understand the issue.
For some combination of dataset and model it works well but not for others. Currently for ld1 dataset and bert model this is the issue similarly for many others as well.

Can you please help me sort out the issue?

Model Checkpoint

Limited by computer resources, could you please provide the trained model parameters file? Thanks a lot!!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.