Skip to main content
The dataloaders module provides a unified interface for loading benchmark datasets, normalizing their formats, and converting them to framework-specific document objects.

Overview

Dataloaders abstract away dataset-specific formats and provide:
  • Catalog-based loader creation - Factory pattern for consistent instantiation
  • Normalized record format - All datasets produce DatasetRecord objects
  • Framework conversion - Automatic conversion to Haystack or LangChain documents
  • Evaluation queries - Ground-truth QA pairs for retrieval benchmarking
  • Streaming support - Memory-efficient iteration over large datasets

Supported datasets

Architecture

Core components

Class hierarchy

Basic usage

Creating a loader

Use the DataloaderCatalog factory to create loaders:

Loading datasets

Converting to framework documents

Data structures

DatasetRecord

Normalized document record with text and metadata:
Example:

EvaluationQuery

Evaluation query with ground-truth answers and relevant document IDs:
Example:

LoadedDataset

Wrapper containing loaded records and metadata:

Dataset implementations

TriviaQA

Dataset ID: triviaqa
HuggingFace: trivia_qa
Structure: Questions with multiple evidence documents
Record format:
  • text: Evidence document content
  • metadata.id: Document identifier
  • metadata.title: Document title
  • metadata.question: Associated question

ARC (AI2 Reasoning Challenge)

Dataset ID: arc
HuggingFace: ai2_arc
Structure: Science questions with multiple-choice answers
Record format:
  • text: Question + answer choices
  • metadata.id: Question identifier
  • metadata.question: Question text
  • metadata.answerKey: Correct answer

PopQA

Dataset ID: popqa
HuggingFace: akariasai/PopQA
Structure: Entity-centric questions from Wikipedia
Record format:
  • text: Wikipedia passage
  • metadata.id: Passage identifier
  • metadata.entity: Entity mention
  • metadata.question: Associated question

FActScore

Dataset ID: factscore
HuggingFace: dskar/FActScore
Structure: Factuality-focused QA pairs
Record format:
  • text: Factual statement
  • metadata.id: Statement identifier
  • metadata.topic: Topic/category

Earnings Calls

Dataset ID: earnings_calls
HuggingFace: lamini/earnings-calls-qa
Structure: Financial QA from earnings call transcripts
Record format:
  • text: Transcript excerpt
  • metadata.id: Excerpt identifier
  • metadata.company: Company name
  • metadata.quarter: Reporting quarter

Base loader interface

All loaders implement the BaseDatasetLoader abstract class:

Document conversion

The DocumentConverter class provides framework-specific conversion:

Haystack conversion

LangChain conversion

Configuration

Dataloaders integrate with YAML configuration:
Load configuration and create loader:

Streaming mode

By default, loaders use streaming to handle large datasets efficiently:

Custom loaders

Implement custom loaders by extending BaseDatasetLoader:

Error handling

Dataloaders raise specific exceptions for different error conditions:

Best practices

Use the catalog

Always use DataloaderCatalog.create() instead of instantiating loaders directly for consistency

Set limits during development

Use limit= parameter during prototyping to avoid loading full datasets

Convert once

Convert to framework documents once during indexing, not repeatedly during queries

Handle exceptions

Catch DatasetLoadError and DatasetValidationError for robust pipelines