본문으로 건너뛰기
Skillpedia
머신러닝14k · #11162

ml-training-recipes

하는 일

이 스킬은 언어, 비전, 생의학 모델을 포함한 여러 분야의 신경망 학습 패턴을 모읍니다. 안정적인 학습 결과를 원하는 머신러닝 실무자를 위한 스킬입니다.

사용하는 경우

  • ✓데이터의 종류와 양에 맞는 모델과 학습 방법을 고르고 있을 때.
  • ✓학습에서 손실 급등이 나타나거나 메모리가 부족해서, 디버깅해야 할 때.
  • ✓새 학습 실행을 위해 옵티마이저나 학습률 스케줄을 고르고 싶을 때.

스킬 링크

https://github.com/Orchestra-Research/AI-Research-SKILLs/blob/main/10-optimization/ml-training-recipes/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/Orchestra-Research/AI-Research-SKILLs/blob/main/10-optimization/ml-training-recipes/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“학습 손실이 갑자기 치솟다가 실행이 메모리 부족으로 멈춥니다. 무엇을 바꿔야 할지 알려 줄 수 있나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 데이터 종류와 규모에 맞는 아키텍처와 학습 설정을 고르고, 손실 급등이나 메모리 오류 같은 흔한 문제의 원인을 하나씩 살펴봅니다. 옵티마이저, 분야별 세부 사항, 확장에 대한 참고 자료를 활용합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

ML Training Recipes

Battle-tested patterns for PyTorch training across domains. Drawn from production codebases (Karpathy's autoresearch/nanochat, torchvision, HuggingFace) and modern training practice.

Reference files (read when needed)

  • references/architecture.md — Transformer/LLM architecture code patterns, weight init
  • references/optimizers.md — Muon, AdamW hybrid, per-group LR, compiled optimizer steps
  • references/domain-specific.md — Vision, diffusion, contrastive, distributed, checkpointing, data loading
  • references/scaling-and-selection.md — Scaling laws, compute budget tables, decision trees, DGX Spark
  • references/biomedical.md — Drug discovery, protein models, medical imaging, genomics, clinical NLP
  • references/experiment-loop.md — Autonomous experiment loop (autoresearch keep/discard/revert)

Architecture Selection

Pick the right model by data type and data scale:

Data Type < 10K samples 10K-100K > 100K
Images Pretrained CNN + fine-tune Fine-tune ViT or CNN ViT from scratch
Text (gen) Few-shot prompting Fine-tune GPT/LLaMA (LoRA) Pretrain from scratch
Tabular XGBoost/LightGBM Still XGBoost Neural viable
Audio Pretrained Whisper Fine-tune AST Train from scratch
Molecules Pretrained GNN Fine-tune molecular LM Train GNN from scratch
Proteins ESM-2 embeddings + head Fine-tune ESM-2 Train protein LM
Medical img Pretrained CNN nnU-Net (auto-config) Swin-UNETR / MedSAM

Key principle: architecture matters less than training recipe at equal compute. A well-tuned ResNet beats a poorly-tuned ViT (ref: "ResNet Strikes Back", Wightman 2021).

For biomedical domains, see references/biomedical.md. For sequence model selection and compute planning, see references/scaling-and-selection.md.


Scaling Laws

Chinchilla rule (Hoffmann et al., 2022)

Compute-optimal training: ~20 tokens per parameter.

Model Size Compute-Optimal Inference-Optimal (100×)
125M 2.5B tokens 12.5B tokens
1B 20B tokens 100B tokens
7B 140B tokens 700B tokens

FLOPs ≈ 6 × N × D (N=params, D=tokens). Data repetition limit: ~4 epochs before diminishing returns.


Training Loop

import gc, time, torch

torch.manual_seed(42)
torch.set_float32_matmul_precision("high")  # TF32 on Ampere+
autocast_ctx = torch.amp.autocast(device_type="cuda", dtype=torch.bfloat16)

grad_accum_steps = total_batch_size // (batch_size * seq_len)
step = 0

while not done:
    t0 = time.time()
    for micro_step in range(grad_accum_steps):
        with autocast_ctx:
            loss = model(x, y)
        (loss / grad_accum_steps).backward()
        x, y = next(train_loader)

    update_lr(optimizer, progress)
    optimizer.step()
    model.zero_grad(set_to_none=True)  # frees memory vs zeroing

    if loss.item() > 100:  # fast-fail on divergence
        print("FAIL: loss exploded"); exit(1)

    torch.cuda.synchronize()
    if step == 0:
        gc.collect(); gc.freeze(); gc.disable()  # avoid ~500ms GC stalls
    step += 1

Key principles

  • Gradient clipping: clip_grad_norm_(params, 1.0) — near-universal for Transformers. Exception: Muon optimizer normalizes updates via orthogonalization, so clipping is optional.
  • Tensor Core alignment: batch size, hidden dims should be multiples of 8 (bf16) or 64 (A100).
  • Time-based budgets make experiments comparable across hardware.
  • cudnn.benchmark = True for fixed-size vision inputs.

Optimizer Configuration

Modern LLM training uses different optimizers per parameter group:

Parameter Type Optimizer LR (base) Weight Decay
2D weight matrices Muon 0.04 0.2
Token embeddings AdamW 0.6 × scale 0.0
Unembedding (lm_head) AdamW 0.004 × scale 0.0
Per-layer scalars AdamW 0.005 × scale 0.0

LR scaling by dimension: lr * (d_model / 768)^(-0.5) — keeps dynamics stable across sizes.

Rules of thumb

  • Embeddings need higher LR (sparse updates). Never weight-decay embeddings.
  • Weight decay scheduling: linearly decay WD to 0 over training.
  • AdamW defaults:
자주 묻는 질문

언어 모델만 다루나요?

아니요. 비전, 확산 모델, 의료 영상, 단백질과 신약 개발, 유전체도 다룹니다.

어떤 옵티마이저를 언급하나요?

AdamW와 Muon이며, 파라미터 그룹마다 학습률을 설정하는 방법도 포함합니다.

많은 실험을 돌리는 데 도움이 되나요?

네. 효과가 있는 변경은 유지하고 효과가 없는 변경은 되돌리는 실험 루프가 포함되어 있습니다.

상세 정보

작성자의 원본 설명

Battle-tested PyTorch training recipes for all domains — LLMs, vision, diffusion, medical imaging, protein/drug discovery, spatial omics, genomics. Covers training loops, optimizer selection (AdamW, Muon), LR scheduling, mixed precision, debugging, and systematic experimentation. Use when training or fine-tuning neural networks, debugging loss spikes or OOM, choosing architectures, or optimizing GPU throughput.

repo: Orchestra-Research/AI-Research-SKILLs

인기도

GitHub 스타
14k
순위
#11162
라이선스
MIT
업데이트
2026. 10. 10.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬