The model that didn't exist, so you made it yourself
https://huggingface.co/blog/building-with-ml-intern📌 找不到的模型,自己叫Agent做一個:HuggingFace的ML Intern實驗
TL;DR:用agent自動規劃、訓練、評估並發布客製小模型,六個專案總成本都在幾十美元內。
當Hub上找不到你想要的那個「小」模型,多數人會將就用壓縮版湊合。HuggingFace的兩位工程師選擇了另一條路:在HuggingChat裡打開ML-intern,描述需求,隔天就拿到一個能在CPU上跑、99.7%輸出有效的客製模型,整個專案花費16美元。
🤔 從一個找不到的模型開始
作者想要Qwen-Image 2.1內建的prompt rewriter的小型版本。官方版本是9B參數,需要約20GB記憶體,而且要先「想」上千個token才會寫出第一段文字。Hub上能找到的,只有同一個9B模型的壓縮版本,沒有真正重新訓練過的小模型。於是作者直接把需求描述給ML-intern。
🧩 ML-intern怎麼運作:先報價,再動手
ML-intern的工作流程是:先規劃工作內容,在花錢之前先向使用者要預算,接著跑一個小規模測試驗證可行性,確認沒問題才進入正式訓練、評估,最後把結果發布到Hugging Face。每個專案都是從HuggingChat裡的一則訊息開始,結束時變成Hub上一個公開模型,評估結果就寫在model card裡。
作者分享了自己的提示工程心得:第一則提示最重要,從450字(第一個citrus模型)寫到後來近2000字(第六個專案),因為每個專案都會教她下一次該多寫什麼。所有七份提示都公開在GitHub的yvrjsharma/ml-intern-prompts。提示的固定結構包括:一行講清楚想法與動機;明確點名資料集、基礎模型、訓練腳本;把已經確認過的事實放進標題寫著「Verified facts, do not re-derive」的區塊,讓agent的預算花在真正的工作上而不是重新查證。她特別強調兩行提示最關鍵:一是要求訓練前先跑基礎模型的zero-shot分數作基準,否則「你會得到一個訓練好的模型,卻不知道它到底有沒有比原來好」;二是要求先用小規模(例如50步)做smoke test並檢查權重真的有變化,再付費跑正式訓練。提示最後會寫清楚交付項目與花費上限,例如「總花費上限USD 12,超過要先問我」。因為ML-intern每個任務都是從零預算開始,沒有授權就不會執行要花錢的工作,這個上限會被嚴格遵守;如果沒設定預算,agent則會依專案規模提出幾個方案讓使用者選。
📊 六天做了多個模型,花費都是個位數到幾十美元
| 專案 | 內容 | 關鍵數據 | 成本 |
|---|---|---|---|
| Pocket Rewriter | Qwen-Image 2.1 prompt rewriter縮小版 | 0.8B,99.7%輸出有效,token用量約為9B教師模型的四分之一 | 全專案約USD 16(含用9B模型標註8,797筆請求) |
| Citrus disease VLM | 柑橘病害診斷,微調Qwen3.5-2B | 335張測試照片,基礎模型準確率14.9%→微調後52.8%(2 epoch,1張A10G) | 約USD 1.90 |
| Huggy LoRA | FLUX.2 klein base 4B上的角色LoRA | 84張標註圖,第200步就on-model,第500步後風格開始外溢 | 約USD 7.60 |
| 相機視角LoRA | Qwen-Image 2.1的物件視角變換 | 1,030個物件x24角度=24,722張透明圖,最終461物件訓練/40測試,2,000步約90分鐘(1張A100) | 約USD 16(48個job) |
| Doodle-in LoRA | 用塗鴉取代後生成指定物件 | 6,042組訓練對+160組測試(40組來自23個未見過的類別),2,000步1小時38分(1張A100),偵測率67.5%、4.7秒/次編輯,未見類別65.0% vs 已見64.2% | 約USD 24(59個job) |
每個專案的資料集與模型都公開在Hub上,citrus模型甚至還做了一個Citrus Doctor App可以直接試用。
💡 把「驗證過的事實」寫進提示,比多寫需求更重要
作者提到,第一次嘗試(citrus模型)其實沒有寫「verified facts」區塊,ML-intern依然做出一個準確率比基礎模型翻三倍以上的成果;但後續專案把這個區塊補上之後,agent不需要重新摸索哪個訓練腳本剛加了透明圖支援、哪個GitHub issue讓備援訓練器變得不穩,工作效率明顯提升。這也呼應她反覆強調的兩個關鍵提示:沒有基準分數,訓練結果就沒有意義;沒有smoke test,正式訓練的錢可能白花。
🎯 對工程師的實務啟示
這整套方法把「自主訓練agent」的風險收斂成三個可控機制:預算上限、zero-shot基準、小規模smoke test。對任何想用agentic workflow做客製化小模型蒸餾的團隊來說,這組提示範本(尤其是「Verified facts, do not re-derive」與花費上限兩個設計)值得直接搬進自己的prompt。
🔗 來源
- 標題:The model that didn’t exist, so you made it yourself
- 作者/機構:Yuvraj Sharma、Abubakar Abid,Hugging Face
- 連結:https://huggingface.co/blog/building-with-ml-intern
#HuggingFace #ModelDistillation #LoRA #AIAgent #FineTuning #OpenSource #QwenImage #MachineLearning #MLOps #GenerativeAI
原始資料 HuggingFace Blog · 收集於 2026-10-09
摘要原文
Back to Articles The model that didn't exist, so you made it yourself Published October 8, 2026 Update on GitHub Upvote 22 +16 yuvraj sharma ysharma Follow Abubakar Abid abidlabs Follow Last week, I wanted a small version of the prompt rewriter that ships with Qwen-Image 2.1. The official one is a 9B model that needs about 20 GB of memory and thinks for thousands of tokens before writing a single paragraph. On the Hub, I found only compressed copies of that same 9B model. So I described what I wanted to ML Intern , and the next day I had a 0.8B version that runs on a CPU. It returns valid output 99.7% of the time and uses about a quarter of the teacher's tokens. The compute for the whole project, including having the 9B model label 8,797 example requests, came to USD 16. Over the course of the next few days, I made five more models the same way. Each one started as a message in HuggingChat with ML-intern switched on, and each one ended as a public model on the Hub with its evaluation in the model card. ML-intern plans the work, asks me for a budget before it spends anything, runs a small test before the real job, then trains, evaluates and publishes on Hugging Face hardware. How I prompt ML Intern The first message is where I spend my effort. My first prompt, for the citrus model shared below, was about 450 words. By my 6th project it was closer to 2,000, because each project taught me something I wanted in the next one. All seven prompts are on GitHub at yvrjsharma/ml-intern-prompts , exactly as I wrote them. A prompt starts with the idea in one line and why I want it. Then it names the exact pieces: the dataset, the base model, the training script. Anything I have already checked goes under a heading that literally says "Verified facts, do not re-derive", so the agent spends its budget on the work instead of rediscovering what I know. For the camera-angle LoRA that section listed which trainer had just added transparent-image support, and which open GitHub issues made the fallback trainer risky. Two lines in the prompt are critical . The first asks for a baseline before any training. For example, the citrus prompt says: "Also report the base model's zero-shot score on the same metric before training so we can see the gain." Without it you get a trained model and no idea whether it is better than what you started with. The second is a smoke test with a check attached. For the image LoRAs I asked for 50 training steps, then a check that the saved weights had actually changed, before paying for the full run. At the end of the prompt, I lay out the expected deliverables and limit the cost. I define what belongs in the model card and include a instruction like: "Cap total spend at USD 12 and ask me before exceeding it." Because ML-intern begins every task with zero dollar budget and needs permission before executing paid jobs, this spending limit stays strictly enforced. When you leave out a budget, the agent suggests a couple of paths depending on project size and asks which one you prefer. You don't necessarily need all of that on your first attempt. For example, I didn't have the verified-facts section in my citrus brief and ML Intern still produced a model that more than tripled the accuracy of the Qwen3.5-2B model. Let me walk you through 6 things I built with Ml-Intern in just a couple of days. 1. A model that knows your field A general vision model can describe a yellowing citrus leaf. However, telling you whether it is a mite problem or a magnesium deficiency, and the bio and non-bio remedies to treat the plant is very hard. Using Claude, I put together a training dataset merged from three sources hosted by the Project-AgML organization on the Hub. The resulting citrus-disease-vlm-instruct is a dataset containing 3,017 annotated images across 21 distinct pests, illnesses, nutritional gaps, and treatment approaches. ML-intern handled the fine-tuning of Qwen3.5-2B using these examples, making sure to benchmark the foundation model beforehand. On the 335 test photos, the base model named the right problem 14.9% of the time. After two epochs on one A10G, the fine-tuned model got 52.8%. Compute cost, about USD 1.90. Check out: Model · Dataset · Citrus Doctor App 2. A model that draws your character Image models know plenty of characters. Huggy, drawn in the flat style of the Hugging Face brand assets, was not one of them. I asked ML-Intern for a LoRA on FLUX.2 klein base 4B , trained on 84 captioned drawings from Chunte/huggy_for_training dataset. The agent saved a checkpoint every 100 steps and drew the same set of prompts with each one, which made choosing easy. Step 200 was the first where Huggy was fully on-model . From step 500 on, Huggy's style started bleeding into prompts that had nothing to do with Huggy! The trained LoRA also works on the distilled klein model at 4 steps. Compute cost, about USD 7.60. Check out: Model · Dataset · Huggy Generator App 3. A model that does a new trick Camera-angle LoRAs are among the most-liked community add-ons for earlier Qwen-Image models. You can give the model a picture of an object and ask to see it 45 degrees from the left. When I checked a few days after the Qwen-Image 2.1 model release, nobody had made one, so I tasked ML-intern to build it. ML-intern rendered 1,030 scanned household objects from Google Scanned Objects at 24 angles each, 24,722 transparent images, on a CPU job that cost a few cents. It later finalised 461 objects for training and 40 held out for testing, and 1,844 before-and-after training pairs spread evenly over 23 camera instructions. Training ran 2,000 steps in about 90 minutes on one A100 (~USD 3.75). The whole project took about half a day and 48 jobs, counting the ones that failed on missing packages or wrong paths and had to be resubmitted by ML-Intern. Total compute cost, about USD 16. Check out: Model · Dataset · Viewpoint Orbit App Doodle-in LoRA is another cool idea. Upload a photo with a magenta scribble on it and add a short prompt naming an object. The LoRA replaces the scribble with that object while keeping the original lighting and composition consistent. No dataset existed for this, so my prompt described how to make one. Start from a real photo in Open Images, remove one object with the LaMa inpainting model, and draw a scribble where the object used to be. The untouched photo is the target. ML-intern wrote and tested the pair-building scripts in a CPU sandbox, then ran them as GPU jobs, recording the author and license of every source photo along the way. It built 6,042 training pairs and a 160-pair test set, where 40 of the test pairs come from 23 object classes kept out of training entirely. Before training, it measured the base model on its own and with the Viggle turbo LoRA, and checked that running edits in batches produced identical images, which made the evaluation cheaper. Training ran 2,000 steps in 1 hour 38 minutes on one A100 (~USD 4), and a comparison of the saved checkpoints on 48 test pairs picked step 500. Paired with the Viggle turbo LoRA at 6 steps the LoRA performed really well. 67.5% of objects detected where they were drawn, at 4.7 seconds per edit. Objects from the 23 unseen classes landed as reliably as the rest (65.0% versus 64.2%). The project took a little over a day and 59 jobs. Total compute cost, about USD 24. Check out: Model · Dataset · Doodle-in App 4. A model that fits your device The Pocket Rewriter from the top of this post is the first one. ML-intern started by generating 8,797 short image requests with a small instruct model through Inference Providers, following a mix set in my prompt: photos, posters, logos, infographics and more, about a third of them asking for exact text in quotes, and many in languages other than English. The 9B teacher then rewrote all of them on one A100 in 2 hours 37 minutes (~USD 6.50). After filtering for quality, 1,840 examples were selected for training dataset. Training the 0.
由 claude-code/sonnet 自動生成