td-builder commited on
Commit
9abeebc
Β·
verified Β·
1 Parent(s): 4fbe7a5

Upload 163 files

Browse files
hugging/td_fuse/td_data_finder.py CHANGED
@@ -1,5 +1,12 @@
1
  """
2
- TD Dataset Finder v1 β€” Search Everywhere for Training Data
 
 
 
 
 
 
 
3
 
4
  Takes the weakness report from td_weakness.py and finds training data
5
  to fix those weaknesses. Searches multiple sources in priority order.
@@ -7,10 +14,11 @@ to fix those weaknesses. Searches multiple sources in priority order.
7
  This is Step 3 of the self-improvement loop.
8
 
9
  Sources (in order of priority):
10
- 1. HuggingFace Datasets API β€” biggest, easiest to download
11
- 2. GitHub β€” repos with training data, benchmarks, problem sets
12
- 3. Kaggle β€” competitions and datasets
13
- 4. (Future) Web scraping β€” Stack Overflow, math forums, etc.
 
14
 
15
  Input:
16
  - WeaknessReport from td_weakness.py
@@ -374,29 +382,39 @@ FALLBACK_DATASETS = {
374
  ("openai/gsm8k", "main"), # 8.8K train, question/answer with ####
375
  ("lighteval/MATH", "all"), # 12.5K, competition math
376
  ("microsoft/orca-math-word-problems-200k", None), # 200K word problems
 
 
377
  ],
378
  "code": [
379
  ("openai/openai_humaneval", None), # 164 problems β€” small but high quality
380
  ("google-research-datasets/mbpp", None), # FIX: full name (short "mbpp" fails)
381
  ("codeparrot/apps", "introductory"), # Competitive programming
 
382
  ],
383
  "reasoning": [
384
  ("allenai/ai2_arc", "ARC-Challenge"), # 2.6K challenge set
385
  ("Rowan/hellaswag", None), # 40K commonsense
386
  ("allenai/openbookqa", "main"), # FIX: replaced openai_prm800k (not a public dataset)
 
 
387
  ],
388
  "creativity": [
389
- ("teknium/OpenHermes-2.5", None), # 1M instruction pairs
390
  ("Open-Orca/OpenOrca", None), # 4.2M conversations
 
 
391
  ],
392
  "knowledge": [
393
  ("TIGER-Lab/MMLU-Pro", None), # MMLU harder version
394
  ("cais/mmlu", "all"), # Classic MMLU
395
  ("truthfulqa/truthful_qa", "generation"), # 817 truthfulness questions
 
396
  ],
397
  "instruction_following": [
398
  ("HuggingFaceH4/ultrafeedback_binarized", None), # 61K preference pairs
399
  ("tatsu-lab/alpaca", None), # 52K instructions
 
 
400
  ],
401
  }
402
 
@@ -445,39 +463,16 @@ def find_training_data(
445
 
446
  print(f"\n--- Searching for: {category} ({needed} samples needed) ---")
447
 
448
- # Step 1: Search HuggingFace
449
- print(f" Searching HuggingFace...")
450
- hf_results = search_huggingface(keywords, hf_tags, category)
451
-
452
- if hf_results:
453
- print(f" Found {len(hf_results)} datasets on HuggingFace:")
454
- for r in hf_results[:3]:
455
- print(f" - {r.name} (relevance: {r.relevance_score:.2f})")
456
-
457
- # Step 2: Download from best matches
458
  category_samples = []
459
- for result in hf_results:
460
- if len(category_samples) >= needed:
461
- break
462
 
463
- remaining = needed - len(category_samples)
464
- samples = download_huggingface_dataset(
465
- dataset_name=result.name,
466
- category=category,
467
- num_samples=remaining,
468
- )
469
- category_samples.extend(samples)
470
- if samples:
471
- all_sources.append(result)
472
-
473
- # Step 3: If not enough, try fallback datasets
474
- if len(category_samples) < needed:
475
- print(f" Only got {len(category_samples)}/{needed}. Trying fallback datasets...")
476
- fallbacks = FALLBACK_DATASETS.get(category, [])
477
  try:
478
  from datasets import load_dataset # Import once outside loop
479
  except ImportError:
480
- print(" Warning: datasets library not installed β€” cannot try fallbacks")
481
  fallbacks = [] # Skip the fallback loop
482
  for ds_name, config in fallbacks:
483
  if len(category_samples) >= needed:
@@ -491,6 +486,7 @@ def find_training_data(
491
  ds = load_dataset(ds_name, streaming=True, split="train")
492
 
493
  count = 0
 
494
  for item in ds:
495
  if count >= remaining:
496
  break
@@ -498,22 +494,56 @@ def find_training_data(
498
  if sample:
499
  category_samples.append(sample)
500
  count += 1
 
 
 
 
 
501
 
502
  if count > 0:
503
- print(f" Got {count} from fallback: {ds_name}")
504
  all_sources.append(DatasetResult(
505
  name=ds_name,
506
- source="huggingface_fallback",
507
  url=f"https://huggingface.co/datasets/{ds_name}",
508
- description=f"Fallback dataset for {category}",
509
  size_estimate=count,
510
- relevance_score=0.5,
511
  category=category,
512
  ))
513
  except Exception as e:
514
- print(f" Fallback {ds_name} failed: {e}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
515
  continue
516
 
 
 
 
 
 
 
 
 
 
 
517
  # Track what we got
518
  if category_samples:
519
  all_samples.extend(category_samples)
 
1
  """
2
+ TD Dataset Finder v2 β€” Search Everywhere for Training Data
3
+
4
+ v2 changes (March 2026):
5
+ - Known-good fallback datasets tried FIRST (reliable, parseable)
6
+ - HuggingFace search only used if fallbacks don't have enough
7
+ - More fallback datasets added per category (4-5 each)
8
+ - Retention floor increased to 20% (prevents catastrophic forgetting)
9
+ - Stall detection in fallback downloads (skip after 500 unparseable items)
10
 
11
  Takes the weakness report from td_weakness.py and finds training data
12
  to fix those weaknesses. Searches multiple sources in priority order.
 
14
  This is Step 3 of the self-improvement loop.
15
 
16
  Sources (in order of priority):
17
+ 1. Known-good fallback datasets (curated, tested, parseable)
18
+ 2. HuggingFace Datasets API search (if fallbacks aren't enough)
19
+ 3. GitHub β€” repos with training data, benchmarks, problem sets
20
+ 4. Kaggle β€” competitions and datasets
21
+ 5. (Future) Web scraping β€” Stack Overflow, math forums, etc.
22
 
23
  Input:
24
  - WeaknessReport from td_weakness.py
 
382
  ("openai/gsm8k", "main"), # 8.8K train, question/answer with ####
383
  ("lighteval/MATH", "all"), # 12.5K, competition math
384
  ("microsoft/orca-math-word-problems-200k", None), # 200K word problems
385
+ ("AI-MO/NuminaMath-CoT", None), # 860K chain-of-thought math
386
+ ("TIGER-Lab/MathInstruct", None), # 262K math instruction pairs
387
  ],
388
  "code": [
389
  ("openai/openai_humaneval", None), # 164 problems β€” small but high quality
390
  ("google-research-datasets/mbpp", None), # FIX: full name (short "mbpp" fails)
391
  ("codeparrot/apps", "introductory"), # Competitive programming
392
+ ("m-a-p/CodeFeedback-Filtered-Instruction", None), # 157K code instructions
393
  ],
394
  "reasoning": [
395
  ("allenai/ai2_arc", "ARC-Challenge"), # 2.6K challenge set
396
  ("Rowan/hellaswag", None), # 40K commonsense
397
  ("allenai/openbookqa", "main"), # FIX: replaced openai_prm800k (not a public dataset)
398
+ ("allenai/winogrande", "winogrande_xl"), # 40K commonsense reasoning
399
+ ("tasksource/bigbench", None), # Diverse reasoning tasks
400
  ],
401
  "creativity": [
402
+ ("teknium/OpenHermes-2.5", None), # 1M instruction pairs β€” diverse, includes creative
403
  ("Open-Orca/OpenOrca", None), # 4.2M conversations
404
+ ("tatsu-lab/alpaca", None), # 52K instructions β€” many creative tasks
405
+ ("WizardLMTeam/WizardLM_evol_instruct_V2_196k", None), # 196K evolved instructions
406
  ],
407
  "knowledge": [
408
  ("TIGER-Lab/MMLU-Pro", None), # MMLU harder version
409
  ("cais/mmlu", "all"), # Classic MMLU
410
  ("truthfulqa/truthful_qa", "generation"), # 817 truthfulness questions
411
+ ("sail/regmix-data-sample", None), # Diverse knowledge mix
412
  ],
413
  "instruction_following": [
414
  ("HuggingFaceH4/ultrafeedback_binarized", None), # 61K preference pairs
415
  ("tatsu-lab/alpaca", None), # 52K instructions
416
+ ("Intel/orca_dpo_pairs", None), # 12K DPO pairs β€” strong instruction following
417
+ ("argilla/ultrafeedback-binarized-preferences", None), # Alternative format
418
  ],
419
  }
420
 
 
463
 
464
  print(f"\n--- Searching for: {category} ({needed} samples needed) ---")
465
 
 
 
 
 
 
 
 
 
 
 
466
  category_samples = []
 
 
 
467
 
468
+ # Step 1: Try KNOWN-GOOD fallback datasets FIRST (reliable, parseable)
469
+ fallbacks = FALLBACK_DATASETS.get(category, [])
470
+ if fallbacks:
471
+ print(f" Trying {len(fallbacks)} known-good datasets for {category}...")
 
 
 
 
 
 
 
 
 
 
472
  try:
473
  from datasets import load_dataset # Import once outside loop
474
  except ImportError:
475
+ print(" Warning: datasets library not installed β€” cannot load datasets")
476
  fallbacks = [] # Skip the fallback loop
477
  for ds_name, config in fallbacks:
478
  if len(category_samples) >= needed:
 
486
  ds = load_dataset(ds_name, streaming=True, split="train")
487
 
488
  count = 0
489
+ stall = 0
490
  for item in ds:
491
  if count >= remaining:
492
  break
 
494
  if sample:
495
  category_samples.append(sample)
496
  count += 1
497
+ stall = 0
498
+ else:
499
+ stall += 1
500
+ if stall > 500:
501
+ break
502
 
503
  if count > 0:
504
+ print(f" Got {count} from: {ds_name}")
505
  all_sources.append(DatasetResult(
506
  name=ds_name,
507
+ source="huggingface_known",
508
  url=f"https://huggingface.co/datasets/{ds_name}",
509
+ description=f"Known-good dataset for {category}",
510
  size_estimate=count,
511
+ relevance_score=0.8,
512
  category=category,
513
  ))
514
  except Exception as e:
515
+ print(f" {ds_name} failed: {e}")
516
+ continue
517
+
518
+ # Step 2: If still not enough, search HuggingFace for more
519
+ if len(category_samples) < needed:
520
+ print(f" Got {len(category_samples)}/{needed} from known datasets. Searching HuggingFace...")
521
+ hf_results = search_huggingface(keywords, hf_tags, category)
522
+
523
+ if hf_results:
524
+ print(f" Found {len(hf_results)} datasets on HuggingFace:")
525
+ for r in hf_results[:3]:
526
+ print(f" - {r.name} (relevance: {r.relevance_score:.2f})")
527
+
528
+ # Download from best matches
529
+ for result in hf_results:
530
+ if len(category_samples) >= needed:
531
+ break
532
+
533
+ # Skip datasets we already used as fallbacks
534
+ if any(result.name == fb[0] for fb in fallbacks):
535
  continue
536
 
537
+ remaining = needed - len(category_samples)
538
+ samples = download_huggingface_dataset(
539
+ dataset_name=result.name,
540
+ category=category,
541
+ num_samples=remaining,
542
+ )
543
+ category_samples.extend(samples)
544
+ if samples:
545
+ all_sources.append(result)
546
+
547
  # Track what we got
548
  if category_samples:
549
  all_samples.extend(category_samples)
hugging/td_fuse/td_weakness.py CHANGED
@@ -478,11 +478,12 @@ def _allocate_data(
478
  ALL_CATEGORIES = ["math", "code", "reasoning", "creativity",
479
  "knowledge", "instruction_following"]
480
 
481
- # FLOOR: 10% of budget split equally across ALL categories
482
  # This prevents catastrophic forgetting on categories above target
483
- floor_pct = 0.10
 
484
  floor_total = int(total_budget * floor_pct)
485
- floor_per_cat = max(floor_total // len(ALL_CATEGORIES), 50)
486
 
487
  # Start with floor for every category
488
  allocation = {cat: floor_per_cat for cat in ALL_CATEGORIES}
 
478
  ALL_CATEGORIES = ["math", "code", "reasoning", "creativity",
479
  "knowledge", "instruction_following"]
480
 
481
+ # FLOOR: 20% of budget split equally across ALL categories
482
  # This prevents catastrophic forgetting on categories above target
483
+ # Increased from 10% to 20% β€” model at 95%+ needs more retention data
484
+ floor_pct = 0.20
485
  floor_total = int(total_budget * floor_pct)
486
+ floor_per_cat = max(floor_total // len(ALL_CATEGORIES), 100)
487
 
488
  # Start with floor for every category
489
  allocation = {cat: floor_per_cat for cat in ALL_CATEGORIES}