FinGPT README

The project's README from github.com/AI4Finance-Foundation/FinGPT. As one markdown file: README.md.

image

FinGPT: Open-Source Financial Large Language Models

Downloads Downloads Join Discord Python 3.8 PyPI License

Let us not expect Wall Street to open-source LLMs or open APIs, due to FinTech institutes' internal regulations and policies.

Blueprint of FinGPT

https://huggingface.co/FinGPT

Visitors Discord

Project Contributors

FinGPT is an open-source financial large language model project developed and maintained by the AI4Finance Foundation.

Key contributors include:

What's New:

Quick Start

🚀 Get started with FinGPT in minutes!

For detailed setup instructions for running FinGPT locally or on Replit, including hardware requirements and troubleshooting, check out our comprehensive SETUP Guide.

Installation

# Clone the repository
git clone https://github.com/AI4Finance-Foundation/FinGPT.git
cd FinGPT

# Install dependencies
pip install -r requirements.txt
pip install -e .

Try the Demo

Visit our HuggingFace Space to try FinGPT-Forecaster without any installation!

Basic Usage

# Using cloud API (no GPU required)
import os
os.environ['FINGPT_LLM_PROVIDER'] = 'openai'

# Using local models (requires GPU)
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

# See SETUP.md for detailed examples

Why FinGPT?

1). Finance is highly dynamic. BloombergGPT trained an LLM using a mixture of finance data and general-purpose data, which took about 53 days, at a cost of around $3M). It is costly to retrain an LLM model like BloombergGPT every month or every week, thus lightweight adaptation is highly favorable. FinGPT can be fine-tuned swiftly to incorporate new data (the cost falls significantly, less than $300 per fine-tuning).

2). Democratizing Internet-scale financial data is critical, say allowing timely updates of the model (monthly or weekly updates) using an automatic data curation pipeline. BloombergGPT has privileged data access and APIs, while FinGPT presents a more accessible alternative. It prioritizes lightweight adaptation, leveraging the best available open-source LLMs.

3). The key technology is "RLHF (Reinforcement learning from human feedback)", which is missing in BloombergGPT. RLHF enables an LLM model to learn individual preferences (risk-aversion level, investing habits, personalized robo-advisor, etc.), which is the "secret" ingredient of ChatGPT and GPT4.

Milestone of AI Robo-Advisor: FinGPT-Forecaster

Try the latest released FinGPT-Forecaster demo at our HuggingFace Space

The dataset for FinGPT-Forecaster: https://huggingface.co/datasets/FinGPT/fingpt-forecaster-dow30-202305-202405

demo_interface

Enter the following inputs:

  1. ticker symbol (e.g. AAPL, MSFT, NVDA)
  2. the day from which you want the prediction to happen (yyyy-mm-dd)
  3. the number of past weeks where market news are retrieved
  4. whether to add the latest basic financials as additional information

Click Submit! And you'll be responded with a well-rounded analysis of the company and a prediction for next week's stock price movement!

For detailed and more customized implementation, please refer to FinGPT-Forecaster

FinGPT Demos:

Current State-of-the-arts for Financial Sentiment Analysis

Instruction Tuning Datasets and Models

The datasets we used, and the multi-task financial LLM models are available at https://huggingface.co/FinGPT

Our Code

Datasets Train Rows Test Rows Description
fingpt-sentiment-train 76.8K N/A Sentiment Analysis Training Instructions
fingpt-finred 27.6k 5.11k Financial Relation Extraction Instructions
fingpt-headline 82.2k 20.5k Financial Headline Analysis Instructions
fingpt-ner 511 98 Financial Named-Entity Recognition Instructions
fingpt-fiqa_qa 17.1k N/A Financial Q&A Instructions
fingpt-fineval 1.06k 265 Chinese Multiple-Choice Questions Instructions

Multi-task financial LLMs Models:

  demo_tasks = [
      'Financial Sentiment Analysis',
      'Financial Relation Extraction',
      'Financial Headline Classification',
      'Financial Named Entity Recognition',]
  demo_inputs = [
      "Glaxo's ViiV Healthcare Signs China Manufacturing Deal With Desano",
      "Apple Inc. Chief Executive Steve Jobs sought to soothe investor concerns about his health on Monday, saying his weight loss was caused by a hormone imbalance that is relatively simple to treat.",
      'gold trades in red in early trade; eyes near-term range at rs 28,300-28,600',
      'This LOAN AND SECURITY AGREEMENT dated January 27 , 1999 , between SILICON VALLEY BANK (" Bank "), a California - chartered bank with its principal place of business at 3003 Tasman Drive , Santa Clara , California 95054 with a loan production office located at 40 William St ., Ste .',]
  demo_instructions = [
      'What is the sentiment of this news? Please choose an answer from {negative/neutral/positive}.',
      'Given phrases that describe the relationship between two words/phrases as options, extract the word/phrase pair and the corresponding lexical relationship between them from the input text. The output format should be "relation1: word1, word2; relation2: word3, word4". Options: product/material produced, manufacturer, distributed by, industry, position held, original broadcaster, owned by, founded by, distribution format, headquarters location, stock exchange, currency, parent organization, chief executive officer, director/manager, owner of, operator, member of, employer, chairperson, platform, subsidiary, legal form, publisher, developer, brand, business division, location of formation, creator.',
      'Does the news headline talk about price going up? Please choose an answer from {Yes/No}.',
      'Please extract entities and their types from the input sentence, entity types should be chosen from {person/organization/location}.',]
Models Description Function
fingpt-mt_llama2-7b_lora Fine-tuned Llama2-7b model with LoRA Multi-Task
fingpt-mt_falcon-7b_lora Fine-tuned falcon-7b model with LoRA Multi-Task
fingpt-mt_bloom-7b1_lora Fine-tuned bloom-7b1 model with LoRA Multi-Task
fingpt-mt_mpt-7b_lora Fine-tuned mpt-7b model with LoRA Multi-Task
fingpt-mt_chatglm2-6b_lora Fine-tuned chatglm-6b model with LoRA Multi-Task
fingpt-mt_qwen-7b_lora Fine-tuned qwen-7b model with LoRA Multi-Task
fingpt-sentiment_llama2-13b_lora Fine-tuned llama2-13b model with LoRA Single-Task
fingpt-forecaster_dow30_llama2-7b_lora Fine-tuned llama2-7b model with LoRA Single-Task

Tutorials

[Training] Beginner’s Guide to FinGPT: Training with LoRA and ChatGLM2–6B One Notebook, $10 GPU

Understanding FinGPT: An Educational Blog Series

FinGPT Ecosystem

FinGPT embraces a full-stack framework for FinLLMs with five layers:

  1. Data source layer: This layer assures comprehensive market coverage, addressing the temporal sensitivity of financial data through real-time information capture.
  2. Data engineering layer: Primed for real-time NLP data processing, this layer tackles the inherent challenges of high temporal sensitivity and low signal-to-noise ratio in financial data.
  3. LLMs layer: Focusing on a range of fine-tuning methodologies such as LoRA, this layer mitigates the highly dynamic nature of financial data, ensuring the model’s relevance and accuracy.
  4. Task layer: This layer is responsible for executing fundamental tasks. These tasks serve as the benchmarks for performance evaluations and cross-comparisons in the realm of FinLLMs
  5. Application layer: Showcasing practical applications and demos, this layer highlights the potential capability of FinGPT in the financial sector.

Cloud LLM Providers for FinGPT Inference

For the Finogrid platform (finogrid/), FinGPT supports multiple cloud LLM providers as alternatives to running local models. Set FINGPT_LLM_PROVIDER in your environment:

Provider Model Context Length Use Case
OpenAI GPT-3.5-turbo 16K Default fallback for sentiment & agents
MiniMax MiniMax-M3 512K Latest flagship model with 128K max output and image input support
Fin

FinGPT (AI4Finance-Foundation/FinGPT)

Searching Database…

21.4K ·GitHub
这是做什么的?FinGPT 是 AI4Finance Foundation 的金融大语言模型开源项目:训练好的模型发布在 HuggingFace 上,并附带围绕这些模型的 RAG、微调流水线和基准测试代码。
FinGPT 是一个模型,还是一整套工具箱?是一套组件的组合,而不是单个模型:FinGPT-RAG(用于金融情感分析的检索增强框架)、FinGPT-FinNLP(训练和微调流水线)以及 FinGPT-Benchmark(评估)。
训练好的模型放在哪里,我该怎么开始使用?训练好的模型发布在 HuggingFace 上,可以直接使用;也可以走 FinGPT-FinNLP 流水线,它涵盖完整的金融领域大语言模型训练和微调;具体细节在项目 wiki 里有说明。
运行之前需要装好什么环境?需要一个 Python 环境——这个仓库的代码是 Python 和 Jupyter Notebook,没有 Docker 配置,所以流水线和 notebook 都要自己在自己的电脑上运行。
这是成熟的产品,还是仍处于研究阶段的代码库?它属于研究级别的代码,而不是成品应用:需要自己搭建 notebook、流水线和基准测试,没有打包好的安装程序,本地训练也仍然需要你自己的算力。
使用它需要有华尔街背景吗?不需要:FinNLP 部分明确是一个面向所有对金融领域大语言模型和 NLP 感兴趣的人的试验场——无论是探索语言模型金融应用的研究人员、开发者还是爱好者都可以用。
运行 FinGPT 需要自己的 GPU 吗?不一定:在 Finogrid 平台上,你可以把 FINGPTLLMPROVIDER 设置为云端服务商,而不必在本地跑模型——情感分析和智能体默认回退使用 OpenAI GPT-3.5-turbo (16K),MiniMax-M3 则提供 512K 的上下文长度。
为什么要做开源的金融大语言模型?项目的出发点是:由于金融科技机构的内部规章制度和政策,华尔街不会发布开源大语言模型或开放 API——FinGPT 的存在就是为了成为人人都能在其基础上构建的开源替代方案。
模型质量到底是怎么衡量的?通过 FinGPT-Benchmark:一种面向金融领域开源大语言模型的新型指令微调范式,支持任务特定微调、多任务微调和零样本微调,让跨多种金融数据集的基准测试既系统又省钱。
FinGPT 有多火?相当火:在 GitHub 上大约有 21.4k 颗 star,由 AI4Finance Foundation 维护,训练好的模型发布在 HuggingFace 上可以直接下载。
Size
12.9 MB
Stars
21.4K
Age
3y
Commits · 90 Days