Implementation:AI4Finance Foundation FinGPT load dataset
| Knowledge Sources | |
|---|---|
| Domains | NLP, Data_Preparation |
| Last Updated | 2026-10-18 00:00 GMT |
Overview
Concrete tool for loading financial benchmark datasets with replication support provided by the FinGPT Benchmark utilities.
Description
The load_dataset function loads one or multiple benchmark datasets by name, with optional replication factors (e.g., `fpb*2` loads FPB twice). It supports loading from HuggingFace Hub (`from_remote=True`) or local disk (`data/fingpt-{name}`). If a dataset lacks a `test` split, it creates one via `train_test_split` with 20% test size.
The Forecaster has its own version in `FinGPT_Forecaster/utils.py` that loads from `data/fingpt-forecaster-{name}` paths.
Usage
Import this function when you need to load benchmark datasets for training or evaluation:
- Benchmark training: Loading training datasets like `fpb`, `fiqa`, `tfns`.
- Dataset replication: Using `*N` suffix to replicate small datasets for longer training.
- Remote loading: Loading from HuggingFace Hub with `from_remote=True`.
Code Reference
Source Location
- Repository: FinGPT
- File: fingpt/FinGPT_Benchmark/utils.py (L166-216), fingpt/FinGPT_Forecaster/utils.py (L57-73)
Signature
def load_dataset(
names: str,
from_remote: bool = False,
) -> list[datasets.DatasetDict]
Import
from utils import load_dataset
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| names | str | Yes | Comma-separated dataset names with optional *N replication (e.g., "fpb*2,fiqa") |
| from_remote | bool | No | Load from HuggingFace Hub vs local disk (default False) |
Outputs
| Name | Type | Description |
|---|---|---|
| return value | list[DatasetDict] | List of loaded datasets with 'train' and 'test' splits |
Usage Examples
Load Multiple Datasets
from utils import load_dataset
# Load FPB (x2) and FiQA locally
datasets = load_dataset("fpb*2,fiqa", from_remote=False)
# Returns [DatasetDict(fpb), DatasetDict(fpb), DatasetDict(fiqa)]
# Concatenate for training
import datasets
train = datasets.concatenate_datasets([d['train'] for d in datasets])