Skip to main content

Retriever

The Retriever class is the entry point for loading your conversation data into Fair Forge. Every evaluation requires a custom retriever that implements load_dataset(). Fair Forge supports three iteration strategies that control how data is consumed — from loading everything upfront to yielding individual QA pairs on demand.

Iteration Modes

Choose the mode that fits your dataset size and processing requirements: The default mode is FULL_DATASET. To use streaming, override the iteration_level property.

Interface

The return type of load_dataset() must be consistent with iteration_level. Returning an Iterator with the default FULL_DATASET level will raise a ValueError at runtime.

Full Dataset Mode

The simplest and most common mode. Load all sessions into a list and return it.

Loading from JSON

Loading from a Database

Loading from an API

Loading from CSV

Multi-Assistant Retriever (BestOf)

BestOf expects one Dataset per assistant, all answering the same questions. The retriever loads them — BestOf handles the tournament logic automatically.
The JSON file must contain one entry per assistant, all sharing the same qa_id values so BestOf can pair their responses:

Best Practices

Declare parameters explicitly for clarity and IDE support:
Use model_validate to leverage Pydantic’s validation and defaults:
Fields with defaults (language="english") are filled in automatically.
If your dataset has thousands of sessions or QA pairs, prefer streaming to avoid loading everything into memory. See the Streaming page.

Next Steps

Streaming Retrievers

Handle large datasets with stream_sessions and stream_batches

Dataset & Batch

Understand the data structures used by all retrievers