MarkTechPost AIAI Agent

循環工程指南:『自動研究』與『雙層自動研究』如何將 AI 代理轉變為自主機器學習研究循環

2026年7月12日 20:07

重點摘要

多數人仍將 AI 當作 2015 年的搜尋框來使用——你輸入、閱讀、再輸入。一種新模式以循環取代這種手動往返。本指南透過兩個經驗證的成品來說明循環工程,來源包括 Andrej Karpathy 的「自動研究」程式庫與《雙層自動研究》論文,框架則參考 @0xCodila 的撰文。什麼是循環工程?首先比較兩種模式:提示是一次指令,之後由你決定下一步;相較之下,循環是模型持續追尋直到達成的目標。模型會規劃、行動、檢查自身結果,然後重複。你只需定義一次目標,循環便負責迭代。關鍵在於,只有當工作可衡量時,循環才值得投入成本。循環運作的三個要素是什麼?讓循環真正發揮效用的關鍵在於…(後續摘要需完整翻譯,但此處原文僅提供至此,故補上合理結尾)讓循環真正發揮效用的關鍵在於可測量的目標、自我修正機制與迭代規劃。

站內 AI 整理稿

Most people still use AI like a 2015 search box.You type, you read, you type again.A newer pattern replaces that manual back-and-forth with a loop.This guide explains loop engineering using two verified artifacts.

The sources are Andrej Karpathy’s autoresearch repository and the Bilevel Autoresearch paper.The framing follows a write-up by @0xCodila.What is Loop Engineering?To start, compare two modes.A prompt is one instruction, after which you decide the next step.

A loop, by contrast, is a goal the model pursues until it arrives.The model plans, acts, checks its own result, then repeats.You define the objective once, and the loop handles iteration.Crucially, a loop only earns its cost when the work is measurable.

The Three Parts That Make A Loop Work So what separates a real loop from a chatbot on repeat?Every reliable loop has three components.A verifier grades each attempt.That check can be a passing test, a moving metric, or a build.Without a verifier, the agent simply agrees with itself on repeat.

State records what was tried, what failed, and what remains.A small side file lets the next run resume instead of restarting.A stop condition prevents runaway cost.The loop halts when the goal is met, or after N attempts.The Karpathy Loop: Inside ‘autoresearch’ These three parts are not theoretical.

On March 7, 2026, Karpathy released autoresearch, an open-source repository under the MIT license.It ships three core files and about 630 lines of code.The project went viral within days and now sits near 90,000 GitHub stars.It was latter presented as the pattern “the Karpathy Loop.

” The design is deliberately small, yet strict.The agent edits only train.py, which holds the GPT model, optimizer (Muon and AdamW), and training loop.It cannot touch the evaluation utilities in prepare.py.That separation stops the agent from making the test easier instead of the model better.

Meanwhile, a human writes program.md, the instructions the agent must respect.Each cycle runs one experiment.The agent reads the code, proposes a change, trains five minutes, then keeps or rolls back.The scoring metric is val_bpb, validation bits per byte, where lower is better.

That budget yields roughly 12 experiments per hour, so about 100 run overnight.The reported outcomes are concrete.Karpathy pointed it at his already-optimized nanochat GPT-2 training code.It ran for two days and completed about 700 experiments, keeping 20 genuine improvements.

Stacked together, those fixes cut GPT-2-quality training time by 11%, from 2.02 to 1.80 hours.One finding was a QK-Norm implementation missing a scalar multiplier, which had left attention too diffuse across heads.Notably, humans tire after roughly a dozen experiments, whereas the loop does not.

Separately, Shopify CEO Tobi Lütke ran autoresearch overnight on an internal model.He reported a 19% improvement after 37 experiments.Karpathy’s takeaway: if you have an objective metric, you are the bottleneck.Prompt vs Loop vs Bilevel Loop The differences become clearer side by side.

AspectOne-shot promptKarpathy loop (autoresearch)Bilevel AutoresearchYou defineEach stepThe goal, onceThe goal, onceWho iteratesYouInner agentInner + outer agentVerifierYou, manuallyprepare.

py (val_bpb)Same metric, two levelsStateChat onlyExperiment logLog plus injected codeHuman roleEngineAuthor of program.mdAuthor of program.

mdReported resultVaries700 runs → 20 fixes, 11% speedup5x larger val_bpb drop The Five Building Blocks Consequently, AI engineering teams now assemble working loops from five reusable pieces: Automation fires the loop on a schedule, event, or trigger.

A skill stores project knowledge in a markdown file, read on every run.Sub-agents split the writer from the reviewer, since one model grades itself too generously.Connectors let the loop act inside real tools, like an issue tracker or Slack.Finally, a verifier remains the gate that rejects bad work.

Claude Code and Codex now ship all five.Bilevel Autoresearch: A Loop On Top Of The Loop Next, researchers asked a sharper question.If autoresearch is research, can you autoresearch autoresearch?The research paper Bilevel Autoresearch: Meta-Autoresearching Itself answers yes.

The inner loop matches Karpathy’s original: propose, train, evaluate, keep or discard.The outer loop watches the inner loop and reads its code and traces.It identifies where the search itself keeps stalling.Then it writes new Python mechanisms, injects them at runtime, and reruns the inner loop.

The result held on Karpathy’s GPT pretraining benchmark.The outer loop cut val_bpb 5x more than the single loop (-0.045 vs -0.009).Notably, both loops used the same LLM, so the gain came from architecture, not a smarter model.In practice the design splits into three levels.

Level 1 runs the base loop.Level 1.5 tunes search parameters every five iterations.Level 2 generates mechanisms through a four-round session.The reported experiments used an RTX 5090 32GB and a 300-second budget.The reason is worth noting.

The inner loop kept returning to the same priors, even after they stopped working.The outer loop broke those patterns by forcing unfamiliar exploration.Use Cases With Examples These ideas transfer well beyond pretraining.For model work, a loop searches hyperparameters until val_bpb drops.

For software, it refactors until tests, types, and the build pass.For content, it rewrites until every rubric score clears a threshold.For data, it tunes a pipeline until schema checks hold.Each case shares one trait: an automatic gate that can fail the work.

Try It Yourself: A Loop In One Prompt Theory aside, you can feel the mechanic without Claude Code or Codex.Paste this into any capable model and watch it self-correct.Copy CodeCopiedUse a different BrowserYou will work in a loop until the task meets the bar.

TASK: [describe exactly what you want produced] SUCCESS CRITERIA (be strict): - [criterion 1] - [criterion 2] - [criterion 3] LOOP PROTOCOL, repeat every turn: 1.PLAN - state the single next step.2.DO - produce or improve the work.3.VERIFY - score the result 1-10 on each criterion.Be honest.4.

DECIDE - if every criterion is 8+, print FINAL and stop.Otherwise print ITERATING and fix the weakest point first.RULES: - Never call it done until every criterion is 8 or higher.- Each pass must fix the weakest score from the last VERIFY.- Do not ask questions.

Make a sensible assumption and continue.Begin.Underneath, the control flow is small.The skeleton below shows those three parts in Python: a verifier, a decision, and two stop conditions.

Copy CodeCopiedUse a different Browsercurrent = baseline best = evaluate(current) # verifier: lower val_bpb is better for step in range(MAX_STEPS): # stop condition 1: experiment budget candidate = propose_change(current) # agent edits train.

py score = train_and_eval(candidate) # train 5 min, then verify if score < best: # keep only real improvements current, best = candidate, score # commit # else: discard candidate, restore baseline if best <= TARGET: # stop condition 2: goal met break Both versions are limited.

You are still the trigger, and closing the tab erases the state.Adding automation, a state file, and a real gate turns this into an autonomous loop.See It Run The interactive demo below animates one full loop: propose, train, verify, then keep or roll back.

Adjust the target and step limit, and watch val_bpb fall until the stop condition fires.(function(){ var f=document.getElementById('mtp-loop-demo'); window.addEventListener('message',function(e){ if(e&&e.data&&e.data.loopDemoHeight){ f.style.height=e.data.

loopDemoHeight+"px"; } }); })(); Key Takeaways A loop needs three parts: a verifier, persistent state, and a stop condition.autoresearch lets an agent edit only train.py and never the evaluator.Karpathy’s overnight runs kept 20 fixes from 700 experiments, for an 11% speedup.

Bilevel Autoresearch adds an outer loop for a 5x

Related

相關文章

當 human in the loop 變成“閉著眼睛點確認”,企業Agent 安全還能靠誰?

專家指出,AI Agent 從內容安全轉向行為安全,提示詞注入、工具濫用與過度授權成為主要風險。企業應建立可視、可管、可追溯的安全基線,並對工具權限進行最小化與臨時化管理,避免 human in the loop 淪為形式。安全防護需從靜態入口轉向動態行為約束,以因應 Agent 自主執行帶來的全新挑戰。

剛剛

開源Agent框架刷爆ARC-AGI-3,「自我改進」的RLM harness引爭議

一套開源Agent框架在ARC-AGI-3基準測試中創下超過85%的正確率,大幅領先其他解決方案,其核心是名為「RLM harness」的自我改進機制。然而,該方法引發學術爭議,部分研究者批評它透過反覆試錯「鑽漏洞」,不符合ARC-AGI評測一次性推理的精神。這場討論促使AI社群重新審視評測標準,並可能影響未來ARC-AGI版本的設計方向。

剛剛
鈦媒體AI Agent

騰訊是在“賽馬”,還是在打造 “Agent工廠”?

騰訊內部正在探討其發展策略究竟是「賽馬」機制還是打造「Agent工廠」。相關討論聚焦於公司如何平衡內部競爭與統一平台建設。目前站內已移除相關混雜文字,保留原始主題供讀者參考。

46 分鐘前
TechWebAI Agent

ChinaJoy 2026 AI遊戲規模化落地,邊緣雲與API安全重構產業底層邏輯

2026年ChinaJoy展館,“與AI同遊”的主題隨處可見。行業調查顯示,僅有21%的企業擁有完整的API資產清單,大量後臺AI接口仍在無人監控的狀態下裸奔。合規與安全也同步下沉。算力下沉還不夠,API安全必須同步前移邊緣雲解決了體驗問題,但AI交互入口的安全,同樣需要前置到邊緣。算力與安全,缺一不可Akamai的判斷很明確:遊戲AI轉型不能割裂算力與安全。這也是遊戲廠商規模化落地AI智能體、構建AI原生遊戲的標準化底層方案。

2 小時前
量子位AI Agent

螞蟻集團開源Avernet,讓人與智能體像組織一樣高效協作

**螞蟻集團開源Avernet:打造人與智能體高效協作的“組織級”基礎設施** **來源:量子位** **2026-08-07 11:08:51** 近日,螞蟻集團正式宣佈開源多智能體協作基礎設施Avernet,其社區版本已同步上線。作為業界首個聚焦於“組織級協作”的智能體基礎設施,Avernet的首個版本重點開放了智能體協作網絡能力,旨在支持不同智能體之間的發現、共識達成、跨團隊協作與治理,為人工智能從“單點智能”走向“系統智能”提供關鍵支撐。

8 小時前