fastrag.benchmark.datasets#
Evaluation datasets: a list of question/answer/relevant-id samples.
Classes
|
Override auto-detection for one or more of |
|
One question, with what a metric needs to score an answer to it. |
|
A list of |
- class fastrag.benchmark.datasets.EvalSample(question, expected_answers=<factory>, relevant_ids=<factory>, metadata=<factory>)[source]#
Bases:
objectOne question, with what a metric needs to score an answer to it.
relevant_idsis what enables the retrieval metrics (fastrag.benchmark.metrics.retrieval) — a sample with none is still usable for generation and operational metrics, just not those.- Parameters:
- class fastrag.benchmark.datasets.ColumnMapping(question=None, expected_answers=None, relevant_ids=None)[source]#
Bases:
objectOverride auto-detection for one or more of
QADataset’s columns.Each field left
Noneis auto-detected by scanning its alias list against the loaded records’ keys; passing a value overrides only that field. Auto-detection raisesConfigurationErrorwhen two alias columns are both present, rather than silently picking one.relevant_ids’s alias list includescontextsfor compatibility with RAGAS-style eval sets — but a RAGAScontextscolumn holds retrieved text, not ids. Such a column matches nothing in Fastrag’s chunk ids and scores every retrieval metric0.0: passColumnMapping(relevant_ids=...)pointing at an actual id column, or leaverelevant_idsempty and skip the retrieval metrics for that dataset.
- class fastrag.benchmark.datasets.QADataset(samples)[source]#
Bases:
objectA list of
EvalSample, loadable from several formats.from fastrag.benchmark import ColumnMapping, QADataset QADataset.load("eval.csv") # auto-detected QADataset.load("eval.csv", ColumnMapping(question="user_query"))
- Parameters:
samples (list[EvalSample])
- samples: list[EvalSample]#
- classmethod load(path, columns=None)[source]#
Load a dataset, dispatching on
path’s suffix..jsonaccepts either{"samples": [...]}(the native format,save()’s output) or a bare[...]of records..jsonlreads one record per line..csvreads withcsv.DictReader..yaml/.parquetandfrom_huggingface()need thedatasetsextra — not yet implemented, kept behind the same gate this class already applies to its other deferred formats.- Raises:
ConfigurationError –
path’s suffix is.yamlor.parquet(needs thedatasetsextra, not yet implemented), or is anything else this method does not read.- Parameters:
columns (ColumnMapping | None)
- Return type:
- classmethod from_huggingface(path)[source]#
Load a dataset from Hugging Face Hub.
Not yet implemented — gated by the
datasetsextra, the same way the deferred.yaml/.parquetsuffixes already are.- Raises:
ConfigurationError – Always — the
datasetsextra is not yet wired up, so this raises naming the install command rather than pretending a loading path exists.- Parameters:
path (str)
- Return type: