FinGPT: Financial Large Language Models

repository·master·Indexed 12 days ago

https://github.com/ai4finance-foundation/fingpt

An open-source project providing financial Large Language Models (FinLLMs) for tasks such as sentiment analysis, stock forecasting, and financial report analysis. It features tools for lightweight adaptation via LoRA fine-tuning, a benchmark for multi-task instruction tuning, and the FinGPT-Forecaster model for stock price predictions using Llama-2.

Tokens
51.8K
Snippets
129
Records
215
Agent score
97%

What's inside FinGPT

  1. What is FinGPT-Forecaster?

    master

    FinGPT-Forecaster is a financial forecasting model designed to act as a junior robo-advisor. It takes market news and optional basic financials for a specific company from the past few weeks as input.

    Outputs:

    • Positive developments and potential concerns for the company.
    • A prediction of stock price movement for the upcoming week.
    • An analysis summary supporting the prediction.

    Technical Details:

    • The model is fine-tuned on Llama-2-7b-chat-hf using LoRA, trained on DOW30 market data from the past year.
    • It demonstrates generalization capabilities across various ticker symbols beyond the DOW30.
  2. Overview of FinGPT Multi-Agent RAG

    master

    FinGPT Multi-Agent RAG is a framework designed to reduce fact-conflict hallucinations in Large Language Models (LLMs) within the financial domain. It achieves this through three core pillars:

    1. Multi-Agent Systems (MAS) Debates: Orchestrating debates among multiple agents to critique and refine reasoning and accuracy.
    2. Retrieval-Augmented Generation (RAG): Using a custom retrieval engine to supplement model responses with up-to-date external knowledge.
    3. Financial Instruction-Tuning: Fine-tuning models on specialized financial datasets (such as FiQA and WealthAlpaca) to enhance domain-specific expertise.
  3. Explore FinGPT Model Paradigms and Use Cases

    master

    FinGPT provides several specialized model implementations and frameworks for different financial tasks. Depending on your goal, you can use one of the following specialized modules:

    • Instruction Tuning: Use FinGPT-Benchmark for task-specific, multi-task, or zero-shot instruction tuning.
    • Forecasting & Analysis: Use FinGPT-Forecaster for company news analysis and stock price prediction, or FinGPT-FinancialReportAnalysis for analyzing financial reports.
    • Sentiment Analysis: There are three versions available:
      • FinGPT-Sentiment-Analysis-v1: Uses market labels.
      • FinGPT-Sentiment-Analysis-v2: Uses LLM labels.
      • FinGPT-Sentiment-Analysis-v3: Uses academic datasets (showcases LoRA power).
    • Retrieval Augmented Generation: Use FinGPT-RAG for RAG-based pipelines.
    • Trading & Advisory: Use FinGPT-Trading for practical trading applications or FinGPT-Robo-Advisor for news and filings analysis.
    • Development: Use FinGPT-Low-Code-Development for low-code financial field development.
  4. Explore FinGPT RAG repository contents

    master

    The repository is organized into two primary functional directories:

    • multisource_retrieval: Contains the core logic for the retrieval augmentation module used to enrich queries with context.
    • instruction-FinGPT: Contains the code and datasets required for the instruction-tuned LLM module.

    Detailed instructions for running, fine-tuning, or evaluating the models are located within these specific directories.

  5. Data Splitting and Aggregation Logic

    master

    FinGPT-V1.1 uses news data with exact timestamps. The data is split into training and testing periods as follows:

    • Training Period: 2019-01-01 to 2021-12-31
    • Testing Period: 2022-01-01 to 2023-08-31

    Data Aggregation Note: To manage the 4096 token limit, the system prioritizes the News Title and truncates content that exceeds the maximum length to ensure more news items can be processed within the context window.

  6. Financial Disclaimer

    master
    FinGPT is shared for academic purposes under the MIT license. The code and outputs provided are NOT financial advice and are NOT recommendations to trade real money. Users should exercise common sense and consult a professional before making any trading or investing decisions.
  7. Data requirements and prompt schema for FinGPT-Forecaster

    master

    FinGPT-Forecaster requires specific data points to generate accurate forecasts. Data is typically retrieved using yfinance and finnhub.

    Required Data Fields:

    • Company Profile: Name, industry (finnhubIndustry), IPO date, market capitalization, currency, shares outstanding, country, ticker, and exchange.
    • Market Context: Stock price movement (increase/decrease) between a startDate and endDate, including start and end prices.
    • News Data: A list of headlines and summaries for news occurring during the specified period.
    • Financials: Recent basic financials (e.g., specific attributes and values) reported at a specific date.

    Expected Output Format: The model is trained to respond using the following structure:

    1. [Positive Developments]: 2-4 concise factors.
    2. [Potential Concerns]: 2-4 concise factors.
    3. [Prediction & Analysis]: A summary analysis and a prediction for the upcoming week's stock price movement.
  8. How Finogrid uses FinGPT models

    master

    Finogrid v1 does not use the full FinGPT research framework. Instead, it utilizes FinGPT as a source for pre-trained model weights and specific inference patterns. The integration is limited to loading pre-trained LoRA adapters via transformers and peft at agent startup.

    Key models used:

    • FinGPT/fingpt-sentiment_llama2-13b_lora: Used by the Ops Oversight Agent for scoring corridor news sentiment.
    • FinGPT/fingpt-forecaster_dow30_llama2-7b_lora: Used by the Process Improvement Agent for FX/macro signal generation.
  9. Supported Models and Datasets for SFT

    master

    The SFT process is designed to work with pretrained decoder models and various Huggingface datasets. While the documentation uses the Meta OPT family (e.g., facebook/opt-1.3b) as a baseline, you can substitute other models like GPT-Neo or Bloom.

    Supported Datasets:

    • Dahoas/rm-static
    • Dahoas/full-hh-rlhf
    • Dahoas/synthetic-instruct-gptj-pairwise
    • yitingxie/rlhf-reward-datasets
    • openai/webgpt_comparisons
    • stanfordnlp/SHP

    Important: Prompt Alignment Different datasets use different prompt formats (e.g., Dahoas/rm-static uses Human: and Assistant:). You must manually align these prompts so they are consistent across your training data. The examples in this project follow the Dahoas/rm-static format.

  10. Understand the FinGPT RAG framework architecture

    master

    The FinGPT RAG framework is designed to enhance financial sentiment analysis by addressing the succinctness of financial news. It uses a two-fold approach:

    1. Retrieval-Augmentation Module (multisource_retrieval): Enhances concise queries by providing additional context.
    2. Instruction-Tuned LLM Module (instruction-FinGPT): An LLM specifically tuned to provide accurate responses to financial sentiment analysis tasks.

    In a typical workflow, the multisource_retrieval module produces a .csv file containing augmented context, which is then used as input for the instruction-FinGPT module during evaluation.