Upload 163 files
Browse files
hugging/td_fuse/selfimprove.py
CHANGED
|
@@ -787,14 +787,17 @@ def improve_with_lora(model_path: str, target_layers: List[int],
|
|
| 787 |
if len(train_texts) >= total:
|
| 788 |
break
|
| 789 |
print(f" Loaded {len(train_texts)} targeted samples")
|
| 790 |
-
if len(train_texts) <
|
| 791 |
-
print(f" WARNING: Only got {len(train_texts)}
|
| 792 |
-
print(f" Supplementing with generic data
|
| 793 |
# Fall through to hardcoded data loading below to fill the gap
|
| 794 |
else:
|
| 795 |
-
# Got
|
| 796 |
-
#
|
| 797 |
-
|
|
|
|
|
|
|
|
|
|
| 798 |
|
| 799 |
# Only load hardcoded datasets if we don't have enough targeted data
|
| 800 |
# Only load generic datasets if targeted data wasn't enough
|
|
|
|
| 787 |
if len(train_texts) >= total:
|
| 788 |
break
|
| 789 |
print(f" Loaded {len(train_texts)} targeted samples")
|
| 790 |
+
if len(train_texts) < 200:
|
| 791 |
+
print(f" WARNING: Only got {len(train_texts)} targeted samples (very low).")
|
| 792 |
+
print(f" Supplementing with generic data...")
|
| 793 |
# Fall through to hardcoded data loading below to fill the gap
|
| 794 |
else:
|
| 795 |
+
# Got targeted data β DON'T dilute with easy generic data
|
| 796 |
+
# Even 500 hard targeted samples > 8000 easy samples the model already knows
|
| 797 |
+
# Training loss was 0.0000 when we mixed targeted + generic (model knew the generic data)
|
| 798 |
+
print(f" Using {len(train_texts)} targeted samples ONLY (no generic filler)")
|
| 799 |
+
print(f" Reason: generic data causes loss=0 because model already knows it")
|
| 800 |
+
total = len(train_texts) # Adjust total so we don't try to supplement
|
| 801 |
|
| 802 |
# Only load hardcoded datasets if we don't have enough targeted data
|
| 803 |
# Only load generic datasets if targeted data wasn't enough
|
hugging/td_fuse/td_data_finder.py
CHANGED
|
@@ -377,44 +377,53 @@ def _format_hf_item(item: Dict, category: str, source: str) -> Optional[Formatte
|
|
| 377 |
# Verified dataset names on HuggingFace (March 2026)
|
| 378 |
# Each tuple: (dataset_name, config_or_subset)
|
| 379 |
# If a dataset fails to load, it moves to the next one silently
|
|
|
|
|
|
|
|
|
|
| 380 |
FALLBACK_DATASETS = {
|
| 381 |
"math": [
|
| 382 |
-
("openai/gsm8k", "main"),
|
| 383 |
-
("lighteval/MATH", "all"),
|
| 384 |
-
("
|
| 385 |
-
("
|
| 386 |
-
("
|
| 387 |
],
|
| 388 |
"code": [
|
| 389 |
-
("
|
| 390 |
-
("
|
| 391 |
-
("
|
| 392 |
-
("
|
|
|
|
| 393 |
],
|
| 394 |
"reasoning": [
|
| 395 |
-
("allenai/ai2_arc", "ARC-Challenge"),
|
| 396 |
-
("Rowan/hellaswag", None),
|
| 397 |
-
("allenai/openbookqa", "main"),
|
| 398 |
-
("allenai/winogrande", "winogrande_xl"),
|
| 399 |
-
("
|
| 400 |
],
|
| 401 |
"creativity": [
|
| 402 |
-
("teknium/OpenHermes-2.5", None),
|
| 403 |
-
("
|
| 404 |
-
("tatsu-lab/alpaca", None),
|
| 405 |
-
("
|
| 406 |
],
|
| 407 |
"knowledge": [
|
| 408 |
-
("
|
| 409 |
-
("cais/mmlu", "all"),
|
| 410 |
-
("truthfulqa/truthful_qa", "generation"), #
|
| 411 |
-
("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 412 |
],
|
| 413 |
"instruction_following": [
|
| 414 |
-
("
|
| 415 |
-
("
|
| 416 |
-
("Intel/orca_dpo_pairs", None),
|
| 417 |
-
("argilla/ultrafeedback-binarized-preferences", None
|
| 418 |
],
|
| 419 |
}
|
| 420 |
|
|
@@ -474,16 +483,22 @@ def find_training_data(
|
|
| 474 |
except ImportError:
|
| 475 |
print(" Warning: datasets library not installed β cannot load datasets")
|
| 476 |
fallbacks = [] # Skip the fallback loop
|
| 477 |
-
for
|
| 478 |
if len(category_samples) >= needed:
|
| 479 |
break
|
| 480 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 481 |
remaining = needed - len(category_samples)
|
| 482 |
try:
|
| 483 |
if config:
|
| 484 |
-
ds = load_dataset(ds_name, config, streaming=True, split=
|
| 485 |
else:
|
| 486 |
-
ds = load_dataset(ds_name, streaming=True, split=
|
| 487 |
|
| 488 |
count = 0
|
| 489 |
stall = 0
|
|
@@ -531,7 +546,7 @@ def find_training_data(
|
|
| 531 |
break
|
| 532 |
|
| 533 |
# Skip datasets we already used as fallbacks
|
| 534 |
-
if any(result.name ==
|
| 535 |
continue
|
| 536 |
|
| 537 |
remaining = needed - len(category_samples)
|
|
|
|
| 377 |
# Verified dataset names on HuggingFace (March 2026)
|
| 378 |
# Each tuple: (dataset_name, config_or_subset)
|
| 379 |
# If a dataset fails to load, it moves to the next one silently
|
| 380 |
+
# Each tuple: (dataset_name, config_or_subset, split_override)
|
| 381 |
+
# split_override: if None, uses "train". Set to specific split name if needed.
|
| 382 |
+
# If a dataset fails to load, it moves to the next one silently.
|
| 383 |
FALLBACK_DATASETS = {
|
| 384 |
"math": [
|
| 385 |
+
("openai/gsm8k", "main", None), # 8.8K, question/answer with ####
|
| 386 |
+
("lighteval/MATH", "all", None), # 12.5K, competition math (HARD)
|
| 387 |
+
("AI-MO/NuminaMath-CoT", None, None), # 860K chain-of-thought math
|
| 388 |
+
("TIGER-Lab/MathInstruct", None, None), # 262K math instruction pairs
|
| 389 |
+
("microsoft/orca-math-word-problems-200k", None, None), # 200K word problems
|
| 390 |
],
|
| 391 |
"code": [
|
| 392 |
+
("m-a-p/CodeFeedback-Filtered-Instruction", None, None), # 157K code instructions β WORKS
|
| 393 |
+
("openai/openai_humaneval", None, "test"), # 164 problems β FIX: split is "test"
|
| 394 |
+
("google-research-datasets/mbpp", None, "test"), # FIX: split is "test"
|
| 395 |
+
("bigcode/starcoderdata", None, None), # StarCoder training data
|
| 396 |
+
("sahil2801/CodeAlpaca-20k", None, None), # 20K code instruction pairs
|
| 397 |
],
|
| 398 |
"reasoning": [
|
| 399 |
+
("allenai/ai2_arc", "ARC-Challenge", None), # 2.6K challenge set
|
| 400 |
+
("Rowan/hellaswag", None, None), # 40K commonsense
|
| 401 |
+
("allenai/openbookqa", "main", None), # Science reasoning
|
| 402 |
+
("allenai/winogrande", "winogrande_xl", None), # 40K commonsense reasoning
|
| 403 |
+
("TIGER-Lab/MathInstruct", None, None), # Also good for reasoning chains
|
| 404 |
],
|
| 405 |
"creativity": [
|
| 406 |
+
("teknium/OpenHermes-2.5", None, None), # 1M instruction pairs β diverse
|
| 407 |
+
("WizardLMTeam/WizardLM_evol_instruct_V2_196k", None, None), # 196K evolved (HARDER)
|
| 408 |
+
("tatsu-lab/alpaca", None, None), # 52K instructions
|
| 409 |
+
("Open-Orca/OpenOrca", None, None), # 4.2M conversations
|
| 410 |
],
|
| 411 |
"knowledge": [
|
| 412 |
+
("cais/mmlu", "all", "test"), # FIX: split is "test" not "train"
|
| 413 |
+
("cais/mmlu", "all", "validation"), # Also try validation split
|
| 414 |
+
("truthfulqa/truthful_qa", "generation", "validation"), # FIX: split is "validation"
|
| 415 |
+
("lukaemon/mmlu", "anatomy", "test"), # Individual MMLU subject
|
| 416 |
+
("lukaemon/mmlu", "world_religions", "test"), # More knowledge topics
|
| 417 |
+
("lukaemon/mmlu", "geography", "test"), # Geography specifically (weak spot!)
|
| 418 |
+
("lukaemon/mmlu", "astronomy", "test"), # Science knowledge
|
| 419 |
+
("lukaemon/mmlu", "global_facts", "test"), # General knowledge
|
| 420 |
+
("Stevross/Erehwon-20k", None, None), # 20K diverse knowledge QA
|
| 421 |
],
|
| 422 |
"instruction_following": [
|
| 423 |
+
("tatsu-lab/alpaca", None, None), # 52K instructions β WORKS
|
| 424 |
+
("HuggingFaceH4/ultrafeedback_binarized", None, "train_prefs"), # FIX: correct split name
|
| 425 |
+
("Intel/orca_dpo_pairs", None, None), # 12K DPO pairs
|
| 426 |
+
("argilla/ultrafeedback-binarized-preferences", None, None),
|
| 427 |
],
|
| 428 |
}
|
| 429 |
|
|
|
|
| 483 |
except ImportError:
|
| 484 |
print(" Warning: datasets library not installed β cannot load datasets")
|
| 485 |
fallbacks = [] # Skip the fallback loop
|
| 486 |
+
for fallback_entry in fallbacks:
|
| 487 |
if len(category_samples) >= needed:
|
| 488 |
break
|
| 489 |
|
| 490 |
+
# Unpack: (name, config, split_override) β split_override can be None
|
| 491 |
+
ds_name = fallback_entry[0]
|
| 492 |
+
config = fallback_entry[1]
|
| 493 |
+
split_override = fallback_entry[2] if len(fallback_entry) > 2 else None
|
| 494 |
+
use_split = split_override or "train"
|
| 495 |
+
|
| 496 |
remaining = needed - len(category_samples)
|
| 497 |
try:
|
| 498 |
if config:
|
| 499 |
+
ds = load_dataset(ds_name, config, streaming=True, split=use_split)
|
| 500 |
else:
|
| 501 |
+
ds = load_dataset(ds_name, streaming=True, split=use_split)
|
| 502 |
|
| 503 |
count = 0
|
| 504 |
stall = 0
|
|
|
|
| 546 |
break
|
| 547 |
|
| 548 |
# Skip datasets we already used as fallbacks
|
| 549 |
+
if any(result.name == fb_entry[0] for fb_entry in fallbacks):
|
| 550 |
continue
|
| 551 |
|
| 552 |
remaining = needed - len(category_samples)
|