Principle:AI4Finance Foundation FinGPT Sentiment Classification
| Knowledge Sources | |
|---|---|
| Domains | NLP, Sentiment_Analysis, Finance |
| Last Updated | 2026-10-18 00:00 GMT |
Overview
The task of categorizing financial text (news, statements, headlines) into sentiment polarities (positive, neutral, negative) using either external LLM APIs or fine-tuned local models.
Description
Financial sentiment classification assigns one of three labels—positive, neutral, or negative—to financial text. FinGPT supports two approaches: (1) external LLM-based classification via the OpenAI API (GPT-3.5/GPT-4), and (2) fine-tuned local model classification via LoRA-adapted LLMs. The RAG pipeline uses external LLMs with a structured classification prompt that instructs the model to return one of the three sentiment labels.
The external approach sends a financial statement with a classification instruction to the OpenAI chat completions API. Results are stored as numeric codes (0=negative, 1=positive, 2=neutral) in a new CSV column. The fine-tuned approach uses the Benchmark instruction-tuning pipeline to train models on labeled datasets like FPB and FiQA.
Usage
Use this principle when:
- Classifying financial statements: Determining sentiment polarity for financial text.
- RAG-enhanced classification: Using retrieved context to improve sentiment prediction.
- Batch classification: Processing CSV files of financial statements with LLM-based labeling.
Theoretical Basis
Sentiment classification maps text to a label :
For external LLM classification, the probability is estimated by the LLM's next-token distribution. For fine-tuned models, it is learned via supervised training on labeled data.
Classification prompt structure:
# Abstract: sentiment classification prompt
prompt = f'We have the following financial statement: "{text}"'
prompt += '. For financial statement above, determine its sentiment '
prompt += '(based on your existing knowledge). Your answer should be '
prompt += 'either "negative" or "neutral" or "positive"'
Practical Guide
- Set `OPENAI_API_KEY` environment variable before running external classification.
- Use `model='gpt-3.5-turbo'` for cost-effective classification.
- Save results incrementally (every 10 rows) to avoid data loss on failures.
- Map LLM text responses to numeric codes: 0=negative, 1=positive, 2=neutral.
- Use `change_target` to normalize model outputs (e.g., "Positive" → "positive").