45 lines
1.7 KiB
Python
45 lines
1.7 KiB
Python
"""Dataset metadata (DatasetSpec) and declarative field mapping (FieldSpec)."""
|
|
|
|
from dataclasses import dataclass, field
|
|
from typing import List, Optional
|
|
|
|
|
|
@dataclass
|
|
class FieldSpec:
|
|
"""Declarative mapping: raw record field name -> Sample field name.
|
|
|
|
Use this when the raw records are already well-shaped; no custom
|
|
``record_to_sample`` function is needed then.
|
|
"""
|
|
|
|
input: str = 'input'
|
|
target: str = 'target'
|
|
choices: str = 'choices'
|
|
id: Optional[str] = None
|
|
metadata: List[str] = field(default_factory=list)
|
|
|
|
|
|
@dataclass
|
|
class DatasetSpec:
|
|
"""Everything the framework needs to know about a dataset *without*
|
|
loading it. Drives the cache key, the CLI listing, and (later) the
|
|
deployment-time dependency resolution via ``requires``.
|
|
"""
|
|
|
|
name: str
|
|
source: str # hub id ('AI-ModelScope/gsm8k') or local path
|
|
split: str = 'test'
|
|
subset: str = 'default'
|
|
version: Optional[str] = None
|
|
task_type: str = 'qa' # qa | mcq | math | coding | agent | vqa | fc
|
|
tags: List[str] = field(default_factory=list)
|
|
requires: List[str] = field(default_factory=list) # e.g. ['docker']
|
|
description: str = ''
|
|
params: dict = field(default_factory=dict) # extra load params, part of cache key
|
|
few_shot_split: Optional[str] = None # e.g. 'dev' (paper-faithful exemplars)
|
|
few_shot_num: int = 0 # paper default shots (mmlu=5, bbh=3, ...)
|
|
gen_config: dict = field(default_factory=dict) # per-bench generation params
|
|
prompt_suffix: str = '' # appended to the question (e.g. boxed{} CoT directive)
|
|
# (temperature/max_tokens/top_p), consumed
|
|
# by run_eval unless overridden
|