ALFFLLM·FINANCE

The List / Agents and Multi-Agent Systems / paper

Learning to Generate Explainable Stock Predictions using Self-Reflective Large Language Models

Kelvin J.L. Koa; Yunshan Ma; Ritchie Ng; Tat-Seng Chua

2024The Web Conferencecites 61P1arXiv ↗DOI ↗Semantic Scholar ↗Source ↗

Abstract

Explaining stock predictions is generally a difficult task for traditional non-generative deep learning models, where explanations are limited to visualizing the attention weights on important texts. Today, Large Language Models (LLMs) present a solution to this problem, given their known capabilities to generate human-readable explanations for their decision-making process. However, the task of stock prediction remains challenging for LLMs, as it requires the ability to weigh the varying impacts of chaotic social texts on stock prices. The problem gets progressively harder with the introduction of the explanation component, which requires LLMs to explain verbally why certain factors are more important than the others. On the other hand, to fine-tune LLMs for such a task, one would need expert-annotated samples of explanation for every stock movement in the training set, which is expensive and impractical to scale. To tackle these issues, we propose our Summarize-Explain-Predict (SEP) framework, which utilizes a verbal self-reflective agent and Proximal Policy Optimization (PPO) that allow a LLM teach itself how to generate explainable stock predictions, in a fully autonomous manner. The reflective agent learns how to explain past stock movements through a self-reasoning process, while the PPO trainer trains the model to generate the most likely explanations given the input texts at test-time. The training samples for the PPO trainer are also the responses generated during the reflective process, which eliminates the need for human annotators. Using our SEP framework, we fine-tune a specialized LLM that can outperform both traditional deep-learning and LLM methods in prediction accuracy and Matthews correlation coefficient, for the stock classification task. To justify the generalization capability of our framework, we further test it on the portfolio construction task, and demonstrate its effectiveness through various portfolio metrics. Our code can be accessed through https://github.com/koa-fin/sep.

In one sentence

The paper proposes the SEP framework, which uses a self-reflective agent and PPO to fine-tune LLMs for explainable stock prediction and portfolio construction without human annotations.

Summary

The paper addresses the challenge of generating human-readable explanations for stock predictions, a task where traditional deep learning models are black boxes and pre-trained LLMs struggle to weigh chaotic social text impacts. The authors propose the Summarize-Explain-Predict (SEP) framework, which autonomously teaches an LLM to make explainable predictions. The method eliminates the need for expensive expert-annotated data by using a self-reflective agent that iteratively reasons through past mistakes to generate correct and incorrect response pairs. These pairs train a reward model, which then guides a PPO trainer to fine-tune a specialized LLM policy. The experimental setup involves collecting tweet data for the top 5 stocks in 11 industries from 2020-2022, clustered using BERTopic. The SEP framework is evaluated on binary stock classification against deep learning baselines (VAE+Attention, GRU+Attention, Transformer) and LLM baselines (GPT-3.5, Vicuna, FinGPT). The model is fine-tuned using Vicuna-7b with LoRA. Additionally, the framework is tested on a portfolio construction task, generating explainable weights for multi-stock portfolios. Metrics include prediction accuracy, Matthews Correlation Coefficient (MCC), and portfolio profitability/Sharpe Ratio. Results show the SEP model outperforms all baselines in accuracy and MCC, particularly when filtering for informative texts. The self-reflective process improves the quality of explanations, enabling decisive weighing of mixed sentiments. In portfolio construction, the model demonstrates generalization by generating weights that yield positive Sharpe ratios. Limitations include potential hallucinations in base models and the reliance on tweet data, which may not capture all market-moving information. The framework is most relevant for explainable AI in finance and agentic workflows.

Research problem

Traditional deep learning models for stock prediction lack explainability, often relying on attention weights that do not provide human-readable reasoning. While LLMs can generate explanations, they struggle to weigh the varying impacts of chaotic social texts on stock prices and require expensive expert-annotated data for fine-tuning. This paper addresses the need for an autonomous, scalable method to train LLMs for explainable stock prediction without human-in-the-loop annotations.

Core contributions

  • Proposes the SEP framework, integrating a self-reflective agent with PPO for autonomous LLM fine-tuning.
  • Introduces a verbal self-reflection loop that generates training data (correct/incorrect pairs) from the model's own mistakes.
  • Demonstrates superior prediction accuracy and MCC compared to deep learning and LLM baselines on stock classification.
  • Validates generalization by applying the framework to explainable portfolio construction with positive Sharpe ratios.
  • Provides a fully autonomous pipeline that eliminates the need for costly expert-annotated explanation samples.

Method

  • Summarize Module: LLM converts unstructured tweets into point-form factual summaries.
  • Explain Module: LLM generates initial price movement and explanation based on summaries.
  • Self-Reflection: Incorrect predictions trigger a reflective agent to diagnose errors and plan corrections.
  • Data Generation: Iterative reflections produce pairs of correct and incorrect responses for training.
  • Reward Modeling: Pairs train a reward model to score response quality.
  • PPO Fine-Tuning: Policy is optimized using PPO to maximize reward from the trained model.
  • Inference: Best-of-n sampling selects the highest-reward prediction and explanation.

Results & findings

  • SEP outperforms GRU+Attention by 2.4% in accuracy and significantly in MCC on informative texts.
  • MCC improvements highlight better handling of mixed sentiments and non-informative texts.
  • Self-reflection reduces hallucinations and improves reasoning quality in explanations.
  • Vicuna-generated training data showed higher hallucination rates than GPT-3.5, affecting performance.
  • Portfolio construction task yielded positive Sharpe ratios, proving framework generalization.
  • Model effectively identifies days with no informative tweets, avoiding random guesses.

Data & experiments

  • Dataset: Top 5 stocks in 11 industries (55 stocks) from 2020-2022, sourced from Yahoo Finance and Twitter API.
  • Text Processing: Tweets clustered using BERTopic to identify representative daily facts.
  • Baselines: Deep learning (VAE+Attention, GRU+Attention, Transformer) and LLMs (GPT-3.5, Vicuna, FinGPT).
  • Metrics: Prediction accuracy, Matthews Correlation Coefficient (MCC), and portfolio Sharpe Ratio/profitability.
  • Experiments: Binary stock classification and multi-stock portfolio weight generation.

Limitations & caveats

  • Relies on tweet data, which may not capture all market-moving information.
  • Base model hallucinations can propagate if not properly filtered during self-reflection.
  • Performance depends on the quality of the initial LLM used for summarization.
  • Limited to binary classification, missing nuanced price movement magnitudes.
  • Computational cost of iterative self-reflection and PPO training.

Curator notes

Discovery status: round3_promoted. Source links: Automate Strategy Finding with LLM in Quant investment; Exploring the Synergy of Quantitative Factors and Newsflow Representations from Large Language Models for Stock Return Prediction; FinArena: A Human-Agent Collaboration Framework for Financial Market Analysis and Forecasting; Large Language Models in equity markets: applications, techniques, and insights