FPB Dataset Evaluation with O3-Mini
This tutorial demonstrates how to evaluate the O3-Mini model on the Financial PhraseBank (FPB) dataset for sentiment analysis. The evaluation script provides a complete pipeline for testing, storing results, and enabling reproducibility for future research.
Overview
The FPB evaluation script (FPB_TestByChatGPT_o3_mini.ipynb) is designed to:
Load the FPB test dataset from HuggingFace
Query the O3-Mini model for sentiment predictions
Store raw responses for future analysis
Calculate evaluation metrics (accuracy, F1-score)
Provide a reproducible framework for model comparison
File Structure
After completing the evaluation, you need to organize the generated files into three main directories in the FinLLM-Leaderboard repository:
FinLLM-Leaderboard/
├── text_responses/ # Raw LLM outputs (QA pairs)
├── tutorials_code/ # Evaluation scripts
└── evaluation/ # Computed metrics and results
Directory Purposes
- text_responses/
Contains the raw question-answer pairs generated by the LLM. This allows researchers to:
Recompute metrics with different evaluation criteria
Analyze response patterns and failure modes
Compare outputs across different models
Perform qualitative analysis of model behavior
- tutorials_code/
Stores the evaluation scripts and notebooks:
FPB_TestByChatGPT_o3_mini.ipynb- Main evaluation notebookHelper functions and utilities
Data preprocessing scripts
- evaluation/
Contains computed results and metrics:
Accuracy scores
F1-scores (macro, micro, weighted)
Confusion matrices
Performance breakdowns by sentiment class
Prerequisites
Before running the evaluation, ensure you have:
API Access: Valid OpenAI API key for O3-Mini model access
Python Environment: Python 3.8+ with required packages
HuggingFace Access: Account for dataset access (if required)
Required Packages
pip install datasets>=2.19.0
pip install huggingface_hub>=0.24
pip install openai==1.40.2
pip install pandas>=2.2.2
pip install tqdm>=4.66.4
pip install scikit-learn
pip install requests>=2.31.0
Running the Evaluation
Step 1: Open Google Colab
Go to Google Colab
Sign in with your Google account
Step 2: Download the Evaluation Script
Navigate to the FinLLM-Leaderboard repository: https://github.com/Open-Finance-Lab/FinLLM-Leaderboard
Go to the evaluation script: https://github.com/Open-Finance-Lab/FinLLM-Leaderboard/blob/main/tutorials_code/FPB_TestByChatGPT_o3_mini.ipynb
Click “Raw” to view the raw notebook file
Copy the URL of the raw file
In Google Colab, click “File” → “Open notebook” → “GitHub” tab
Paste the repository URL or directly open:
https://github.com/Open-Finance-Lab/FinLLM-Leaderboard/blob/main/tutorials_code/FPB_TestByChatGPT_o3_mini.ipynb
Step 3: Setup Environment
Set up your OpenAI API key in Colab:
import os
os.environ['OPENAI_API_KEY'] = 'your-api-key-here'
Alternatively, use Colab’s secret management: - Click the key icon (🔑) in the left sidebar - Add a new secret named
OPENAI_API_KEY- Set your API key as the value
Step 4: Load Dataset
The script automatically loads the FPB test dataset:
from datasets import load_dataset
ds_raw = load_dataset("TheFinAI/flare-fpb", split="test")
print(f"Loaded {len(ds_raw)} test samples")
Step 5: Run Evaluation
Execute the notebook cells in sequence:
Data Loading: Loads and preprocesses the FPB dataset
Model Setup: Configures O3-Mini API connection
Batch Processing: Sends queries and collects responses
Result Storage: Saves raw responses to
text_responses/Metric Calculation: Computes and saves evaluation metrics
Step 6: Organize Results
After completing the evaluation in Google Colab, you need to manually organize the generated files into the appropriate directories in the FinLLM-Leaderboard repository:
Download Results from Colab: - Download the generated CSV files, JSON responses, and any output files from your Colab session
Organize Files: - Place raw LLM responses in
text_responses/directory - Place evaluation metrics and results inevaluation/directory - The notebook is already intutorials_code/directoryFile Placement Example:
# Place your generated files in the repository structure:
FinLLM-Leaderboard/
├── text_responses/
│ └── o3mini_fpb_responses.json # Your generated responses
├── evaluation/
│ ├── o3mini_fpb_metrics.json # Your computed metrics
│ └── o3mini_fpb_results.csv # Your evaluation results
└── tutorials_code/
└── FPB_TestByChatGPT_o3_mini.ipynb # Already provided
Reproducibility Notes
To ensure reproducible results:
Version Control: Pin all package versions as specified
Random Seeds: The script sets random seeds where applicable
API Consistency: Use the same model version (O3-Mini)
Data Integrity: Verify dataset version and splits
Customization
The evaluation framework can be adapted for:
Different Models: Modify the model configuration
Custom Datasets: Replace the dataset loading logic
Additional Metrics: Extend the evaluation functions
Batch Sizes: Adjust processing parameters for efficiency
Troubleshooting
Common Issues
- API Rate Limits
Implement exponential backoff
Reduce batch size
Add delays between requests
- Memory Issues
Process data in smaller chunks
Clear intermediate variables
Use streaming for large datasets
- Inconsistent Results
Check API model version
Verify random seed settings
Ensure identical preprocessing
Next Steps
After running the evaluation:
Compare Results: Use stored responses to compare with other models
Error Analysis: Examine misclassified examples
Metric Extensions: Calculate additional evaluation metrics
Visualization: Create charts and graphs from the results
For questions or issues, refer to the project documentation or create an issue in the repository.