메뉴
HN
Hacker News 14일 전

AI를 강화학습시켜 AI를 강화학습시키는 에이전트 개발 (약 1,300달러)

IMP
9/10
핵심 요약

개발자가 강화학습(RL)을 통해 다른 AI 모델을 효과적으로 학습시키는 방법을 스스로 터득하는 메타 에이전트를 구축했습니다. 이 에이전트는 주어진 과제에 맞춰 데이터셋과 보상 코드 등을 작성해 실제 GPU 환경에서 소형 모델을 학습시키며, 모델의 성능이 오를수록 에이전트 자체도 강화학습으로 발전합니다. 코드와 모델 가중치 등 모든 과정이 오픈소스로 공개되어, 자가 개선(self-improving)이 가능한 AI 시스템의 실질적 구현 및 저비용 검증이라는 점에서 매우 중요합니다.

번역된 본문

🤓 AI가 AI를 학습시킵니다: 강화학습(RL)을 사용해, 강화학습으로 AI를 학습시키는 AI 에이전트를 훈련시켰습니다.

🔓 다음의 모든 것이 오픈소스로 공개되었습니다: 학습된 에이전트의 가중치(🤗 HF의 LoRA 어댑터), 에이전트 하네스, 과제 패밀리(task families), 보상 코드, GPU 오케스트레이션, Tinker RL 학습 스크립트, 그리고 모든 파일럿 과정에 대한 회고록(실패한 내용 포함). 시작하기(Getting started)로 이동 ↓

TL;DR: 제가 구축한 파이프라인에서 AI 에이전트는 다음과 같이 동작합니다:

  1. 학습 과제("모델에게 X를 하도록 가르쳐라")를 전달받습니다.
  2. 환경, 보상, 데이터셋, 하이퍼파라미터를 포함한 완전한 prime-rl 학습 작업을 작성합니다.
  3. 이를 실제 Runpod GPU에 제출하여 학습을 진행합니다.
  4. Tinker를 활용하여, 에이전트가 더 나은 모델을 학습시킬 때 보상을 주는 방식으로 에이전트 자체를 RL로 학습시켰습니다.

54번의 학습 스텝 동안 보상은 약 0.0에서 약 0.63의 최고치로 상승했습니다. 그리고 학습에 사용되지 않은 완전히 새로운 과제 패밀리에도 이 기술이 이전(Transfer)되었습니다. RL 루프 안에 있는 AI(A), 그 AI(A)의 행위는 또 다른 RL 루프 안에 있는 AI(B)를 학습시키는 것입니다. (출처: assets/hero.svg)

📚 목차 🔁 작동 방식 | 한 에피소드의 과정 | ⚖️ 보상 설계 | 🧩 과제 패밀리 | 📈 결과 | 🖥️ 인프라 | 💰 비용 | 🤗 모델 가중치 | 🚀 시작하기 | 🔮 향후 개선 사항 | 감사의 말

🔁 작동 방식 두 개의 완전히 분리된 학습 스택을 가진 두 개의 RL 루프입니다.

  • 외부 루프 (Outer loop):

    • 학습 대상: 트레이너 에이전트 (Qwen3.6-35B-A3B, LoRA)
    • 학습 형태: 학습 작업을 작성하는 에피소드들; 에피소드 보상이 정책 경사도(policy-gradient) 신호가 됩니다.
    • 스택: Tinker + tinker-cookbook (중요도 샘플링 GRPO)
  • 내부 루프 (Inner loop):

    • 학습 대상: 소형 베이스 모델 (Qwen3-0.6B / 1.7B)
    • 학습 형태: 에이전트가 작성한 작업: verifiers 환경 + 채점 기준(rubric), 그리고 [prime_rl] 구성 테이블
    • 스택: Runpod GPU에서 동작하는 prime-rl (GRPO)

Tinker가 에이전트를 학습시킵니다. 에이전트는 verifiers 환경, 채점 기준, prime-rl 구성을 작성합니다. prime-rl은 소형 모델을 학습시킵니다. 내부 모델의 숨겨진 평가(hidden-eval) 점수가 다시 올라가 외부 루프의 보상이 됩니다.

한 에피소드의 과정 하나의 에피소드는 처음부터 끝까지 진행되는 하나의 시도입니다. (출처: assets/episode.svg) 하나의 에피소드 = 주어진 과제에 대해 유효하고 고품질의 학습 작업을 생성하려는 트레이너 에이전트의 단일 시도:

  • 과제 명세(Task spec) — 무엇을 학습시킬지에 대한 설명("소형 모델에게 다중 홉 페르소나 쿼리를 해결하도록 가르쳐라"), 엄격한 제약 조건, 평가 도구 인터페이스, 그리고 약간의 개발 예제들.
  • 에이전트의 작업 — read_file / write_file / edit_file / list_files를 통해 샌드박스가 적용된 작업 공간을 편집하며, get_baseline_scores를 호출하여 학습되지 않은 베이스 모델의 숨겨진 평가 점수를 확인할 수 있습니다.
  • submit_job — 유효성 검사 프로브를 트리거합니다. 실패가 반환되면 에이전트에게 재시도 횟수 제한이 주어집니다.
  • 디스패치(Dispatch) — 검증된 작업은 대기열에 들어가 대기 중이던 Runpod GPU 파드 풀에서 선택됩니다. 이 파드들은 prime-rl로 GRPO 학습을 실행하고 숨겨진 평가에서 학습 전/후의 체크포인트를 채점합니다.
  • 보상(Reward) — 검증 효율성과, 학습되지 않은 최고의 베이스라인 대비 학습된 모델의 성능 향상분(uplift)을 결합합니다. 그런 다음 외부 루프는 에피소드 보상을 사용하여 Tinker를 통해 에이전트 자체를 RL로 학습시킵니다. 외부 루프의 모든 배치는 최대 16개의 GPU 파드에 걸쳐 40개의 실제 내부 학습 작업을 생성합니다.

⚖️ 보상 설계 에피소드 보상은 가중치 합산(실제 가중치 0.35 / 0.60 / 0.05)으로 이루어집니다:

  • 검증(Validation) — 첫 번째 시도에 유효한 제출을 하면 1.0점이며, 추가 시도 횟수에 따라 점수가 감소합니다; 에피소드가 끝내 검증되지 않으면 0점입니다. (별도로, 에이전트가 파싱 가능한 제출물을 제출하지 못한 경우 외부 루프는 에피소드에 -0.1점을 부여합니다. CSV에서 볼 수 있는 -1.0 값은 "사후 점수 없음"을 의미하는 로깅 센티넬(기준값)이지 보상이 아닙니다.)
  • 작업 품질(Job quality) — 학습된 모델의 절대적 학습 후 점수와 학습되지 않은 최고 모델의 고정된 베이스라인(best_pre) 대비 부호가 있는 성능 향상분(uplift_term)의 하이브리드입니다: '0.25·post + 0.75·uplift_term'. GPU에서 작업이 중단되면 여기서 0점을 받습니다 (에피소드는 검증 항목 점수는 유지합니다).
  • 학습 속도(Train speed) — 더 빠른 작업에 대한 작은 동점 처리자(tie-breaker)이며, 작업 성공 여부에 따라 발동합니다.

주의 (꼼꼼히 읽는 독자를 위한 참고 사항): 에이전트가 보는 프롬프트(template/INSTRUCTIONS.md)는 에이전트에게 단순화된 관점을 제공합니다. 즉, 전체 0.35/0.60/0.05 비율이 아닌, 작업 품질 내에서 75/25 비율의 성능 향상분/절대 점수를 보여주고, 시도를 덜 하도록 유도하는 장치만을 제공합니다.

원문 보기
원문 보기 (영어)
🤓 AI Trains AI: Using RL to train an AI agent that trains AI using RL 🔓 Everything is open sourced including: the trained agent's weights ( LoRA adapter on 🤗 HF ), agent harness, task families, reward code, GPU orchestration, tinker RL training scripts, and retro write-ups of every pilot (including the failures). Jump to Getting started ↓ TL;DR: I built a pipeline where an AI agent: Is handed a training task ("teach a model to do X") Writes a complete prime-rl training job, including: environment, reward, dataset, hyperparameters. Submits it to real Runpod GPUs for training. Leveraging Tinker , I then RL-trained the agent itself, rewarding it when it trained better models. Reward climbed from ~0.0 to a ~0.63 peak over 54 training steps. Transferring to a held-out task family it never trained on . An AI in an RL loop, whose action is training AI in an RL loop. (Source: assets/hero.svg .) 📚 Table of Contents 🔁 How it works The episode ⚖️ Reward design 🧩 Task families 📈 Results The reward climbed in two distinct rungs The skill transfers to a held-out task family The agent learned to pick the better base model 🖥️ Infrastructure 💰 Costs 🤗 Model weights 🚀 Getting started 🔮 Future improvements Acknowledgements 🔁 How it works Two RL loops with two entirely separate training stacks. who is being trained what training looks like stack Outer loop the trainer agent ( Qwen3.6-35B-A3B , LoRA) episodes of writing training jobs; episode reward is the policy-gradient signal Tinker + tinker-cookbook (importance-sampling GRPO) Inner loop a small base model ( Qwen3-0.6B / 1.7B ) the job the agent wrote: a verifiers environment + rubric, with a [prime_rl] config table prime-rl (GRPO) on Runpod GPUs Tinker trains the agent. The agent writes verifiers envs, rubrics, and prime-rl configs. prime-rl trains the small model. The inner model's hidden-eval score flows back up as the outer loop's reward. The episode One episode, end to end. (Source: assets/episode.svg .) One episode = one attempt by the trainer agent to produce a valid, high-quality training job for a given task: Task spec — a description of what to train ("teach a small model to resolve multi-hop persona queries"), hard constraint bounds, the eval tool interface, and a handful of dev examples. The agent works — it edits a sandboxed workspace through read_file / write_file / edit_file / list_files , and can call get_baseline_scores to see the untrained base models' scores on the hidden eval. submit_job — triggers a validation probe. Any failures are returned and the agent gets capped retries. Dispatch — a validated job is queued and picked up by a warm pool of Runpod GPU pods, which run GRPO training with prime-rl and score the checkpoint pre/post on the hidden eval. Reward — combines validation efficiency with the trained model's uplift over the best untrained baseline. The outer loop then RL-trains the agent itself on episode reward, using Tinker . Every outer-loop batch spawns 40 real inner training jobs across up to 16 GPU pods. ⚖️ Reward design Episode reward is a weighted sum (live weights 0.35 / 0.60 / 0.05): Validation — 1.0 for a first-try valid submission, decaying per extra attempt; 0 if the episode never validates. (Separately, the outer loop scores an episode −0.1 when the agent never produces a parseable submission at all. The −1.0 values you'll see in the CSVs are a "no post score" logging sentinel, not a reward.) Job quality — a hybrid of the trained model's absolute post-training score and its signed uplift over best_pre , the best untrained model's frozen baseline: 0.25·post + 0.75·uplift_term . A job that dies on the GPU scores 0 here (the episode keeps its validation term). Train speed — a small tie-breaker for faster jobs, gated on job success. Note for close readers: the agent-facing prompt ( template/INSTRUCTIONS.md ) gives the agent a simplified view — the 75/25 uplift/absolute split inside job quality, plus a fewer-attempts nudge — not the full 0.35/0.60/0.05 decomposition. The published adapter was trained against that prompt; the reward actually computed is the one above. 🧩 Task families Six families of tasks, deliberately built so that the untrained models struggled without training, and all require multi-step tool use and reasoning: family shape untrained best_pre (n=200) calc_chain chained arithmetic where each step feeds the next 0.742 multi_hop persona-world queries needing multiple dependent lookups 0.654 string_pipeline composed string transformations 0.545 ledger stateful account bookkeeping via tools 0.242 dispatch conditional routing decisions 0.323 triage (held out) on-call incident triage: correlating services, incidents and deploys across tools 0.352 Five families train the agent; triage is never trained on and serves as the generalisation probe. 📈 Results Setup: Qwen3.6-35B-A3B trainer agent, LoRA rank 8, lr 4e-5, GRPO with group size 8, up to 16 concurrent GPU pods, ~40 real training jobs per batch. Runs: pilot-7 (10 steps) → 7b (24 steps, warm-started) → 7c (20 steps, warm-started) — 54 steps total. 1. The reward climbed in two distinct rungs Decomposing the reward shows what was learned, and in what order: Rung 1 — process reliability (pilot-7). The entire early gain came from converting validation failures and dead-on-GPU jobs into completed episodes. Job quality stayed flat while total reward rose to ~0.26. Showing GRPO taking the steepest gradient first. Rung 2 — making better models (pilot-7b onward). With reliability saturating (~0.75–0.80 validation), job grade rose 0.30 → 0.41 and the hidden-eval post-training score went from ~0.04 noise to a sustained 0.22–0.48. The agent started making better models, not just working ones. 2. The skill transfers to a held-out task family A task family which the agent never trained on showed performance rises with outer-loop training, then plateaus: checkpoint outer steps mean reward validated inner jobs succeeded worst episode base model 0 0.399 9/10 5/9 0.000 pilot-7 final 10 0.438 8/10 8/8 0.000 pilot-7b final 34 0.545 10/10 9/10 0.290 pilot-7c final 54 0.492 10/10 8/10 0.175 3. The agent learned to pick the better base model & better hyperparams Early training runs were model-selection blind: 77/79 episodes chose the weaker 0.6B model. After introducing the get_baseline_scores tool and uplift grading, the policy flipped and remained so during training, deepening across the arc: 1.7B share of job-writing episodes went 42% → 95% . It also adopted the exposed [prime_rl] config surface (21% → ~78% of episodes within one warm-start boundary), with a sensible key mix: sampling temperature, optimizer choice, algorithm variant, scheduler, loss. 🖥️ Infrastructure 16x warm GPU pods training at any one time: Inner loop (the jobs the agent writes): Runpod warm-pod fleet — a capped pool (up to 16) of pods, bootstrap-pinned to exact prime-rl + verifiers revisions so every node is a replica; ~2 min from provision to serving. Idle pods are reaped; the queue is file-backed ( queued/ → running/ → done/ ). GPU selection is data-driven — a benchmark matrix over GPU × base-model found 2× RTX A5000 wins cost at £0.10/job (~$0.13) ; preference ladders are walked at provision time to take whatever's in stock. What the fleet actually ran on (headline arc, ~1,750 jobs — below the nominal 54 steps × 40 because episodes that fail validation never dispatch a job): A40 64% (340 GPU-train-hours) · RTX 4090 32% (151h) · RTX A6000 3% · RTX A5000 1%. The benchmark cost-winner was rarely in stock, so the ladder spent most of the arc on A40s. prime-rl (GRPO) trains the small model; checkpoints are scored pre/post on the hidden eval with vLLM. Outer loop (training the agent): Tinker (Thinking Machines' managed RL API) trains Qwen3.6-35B-A3B with LoRA via tinker-cookbook's importance-sampling GRPO. A control-inversion bridge runs each episode as a background task behind a queue-backed policy, so the cookbook loop drives episodes turn-by-turn wh