MCPcopy Create free account
hub / github.com/FareedKhan-dev/train-llm-from-scratch / collect

Function collect

scripts/prepare_preference_data.py:74–85  ·  view source on GitHub ↗
(source: str, max_n: int, split: str)

Source from the content-addressed store, hash-verified

72
73
74def collect(source: str, max_n: int, split: str) -> list[dict]:
75 rows: list[dict] = []
76 if source in ("hh", "both"):
77 print(f"Loading Anthropic/hh-rlhf [{split}] ...")
78 rows += from_hh(max_n, split)
79 if source in ("ultrafeedback", "both"):
80 print(f"Loading ultrafeedback_binarized [{split}] ...")
81 try:
82 rows += from_ultrafeedback(max_n, split)
83 except Exception as e: # noqa: BLE001
84 print(f" (skipping ultrafeedback: {e})")
85 return rows
86
87
88def write_jsonl(rows: list[dict], path: str) -> None:

Callers 1

mainFunction · 0.85

Calls 2

from_hhFunction · 0.85
from_ultrafeedbackFunction · 0.85

Tested by

no test coverage detected