# Getting Began With ML Intern
Have you ever ever gotten caught in that acquainted scenario the place you may have a mannequin concept, however the hole between “I learn the paper” and “I’ve a educated checkpoint on the Hub” nonetheless eats up a whole weekend? ML Intern is Hugging Face‘s try to shrink that hole. It’s an open-source command-line interface (CLI) agent from Hugging Face that permits you to describe machine studying duties in plain English.
As an alternative of manually piecing all the pieces collectively, you possibly can ask it to fine-tune a mannequin, discover a analysis paper, or begin a coaching run. It handles the type of work a junior machine studying engineer would normally do: studying docs, looking GitHub, writing scripts, kicking off jobs, checking outcomes, and iterating.
It’s constructed on the Hugging Face stack finish to finish. It will probably search papers on the Hub and arXiv, work with datasets, launch graphics processing unit (GPU) coaching jobs utilizing HF Jobs, log experiments with Trackio, and publish educated fashions again to the Hub when all the pieces is finished. Beneath the hood, it makes use of the smolagents framework and routes mannequin calls via Hugging Face Inference Suppliers or native endpoints for those who would fairly not burn API credit.
It’s much less like “ChatGPT for code” and extra like a analysis intern who truly has shell entry and a Hugging Face account. The repository is huggingface/ml-intern. You possibly can experiment with it, adapt it to your wants, and even make it a part of your steady integration (CI) workflow.
# Understanding Why ML Intern Helps
Actual machine studying analysis isn’t linear. You learn one thing, chase a quotation, discover a dataset that just about matches, rewrite the info loader twice, practice, understand your analysis was mistaken, repair it, and practice once more. ML Intern is designed to automate a lot of this repetitive work so you possibly can give attention to analysis selections as a substitute of repeatedly writing setup code.
In contrast to conventional chatbots, it doesn’t cease after producing one reply. As an alternative, it follows an iterative workflow.

The ML Intern workflow loop
Hugging Face revealed outcomes displaying the agent bettering from about 10% to about 32% on GPQA, a benchmark for scientific reasoning, in underneath 10 hours on a small Qwen mannequin. Whether or not or not you care about that particular benchmark, it nonetheless provides you a superb sense that this isn’t a toy that writes one script and stops. It’s constructed to maintain going.
That’s sufficient background to know why the undertaking exists. Now it’s time to use it, however first, be sure to have the required setup in place.
# Checking the Stipulations
You have to a Hugging Face account, Python, uv, and some tokens.
| Token | Why Is It Wanted? | Advisable Permission |
|---|---|---|
HF_TOKEN |
Entry the Hugging Face Hub, Inference Suppliers, GPU sandboxes, and coaching jobs. | Write (really helpful) or Learn for those who solely plan to discover and won’t add something |
GITHUB_TOKEN |
Search public GitHub repositories when the agent appears for reference implementations. | Positive-grained token with read-only entry to public repositories |
For those who skip HF_TOKEN, the CLI will ask for one on first launch until you might be operating a totally native mannequin. In case you are uncertain the best way to create both token, test the official guides for Hugging Face Entry Tokens and GitHub Private Entry Tokens.
# Putting in ML Intern
Copy and run the next instructions.
git clone git@github.com:huggingface/ml-intern.git
cd ml-intern
uv sync
uv software set up -e .
As soon as that’s completed, ml-intern works from any listing. A fast sanity test:
Add the next to your .env file, or export equal variables in your shell.
HF_TOKEN=hf_your_token_here
GITHUB_TOKEN=ghp_your_token_here
# Evaluating Interactive and Headless Modes
Earlier than beginning your first run, it helps to know the 2 modes the agent helps.
// Utilizing Interactive Mode
Run the next command to launch your machine studying agent.
This opens a chat session. You possibly can describe what you need, the agent plans the steps, asks for approval earlier than dangerous operations, and retains you up to date as it really works. You possibly can even swap fashions mid-conversation with:
Some good prompts for a newbie are:
- “Discover a small classification dataset on the Hub and present me the best way to load it with the datasets library.”
- “Summarize this paper and listing what datasets it makes use of: [arXiv link].”
- “Write a minimal low-rank adaptation (LoRA) fine-tuning script for
Qwen2.5-0.5Bon a tiny public dataset. Don’t launch coaching but, simply write the script.”
// Utilizing Headless Mode
ml-intern "fine-tune llama on my dataset"
This mode makes use of a single immediate and auto-approves actions. The agent runs till it finishes or hits the iteration restrict. That is the mode you’ll drop right into a GitHub Motion for nightly experiments.
Some helpful flags as soon as you might be comfy:
ml-intern --max-iterations 100 "your immediate" # cap the finances
ml-intern --no-stream "your immediate" # cleaner output for CI logs
ml-intern --sandbox-tools "take a look at this in a GPU sandbox"
ml-intern --model moonshotai/Kimi-K2.7-Code:novita "your immediate"
In case you are simply getting began, strive interactive mode first. As soon as you might be comfy, swap to headless mode for automation.
# Beginning Your First Run
Use the identical immediate in each modes so you possibly can see how they differ. We are going to begin with a small job that doesn’t contain coaching. The purpose is just to discover a dataset on the Hugging Face Hub and write a loader script.
The immediate:
Discover the rotten_tomatoes dataset on the Hub and write a brief Python script that masses it with datasets and prints the primary instance. Put it aside to load_dataset.py. Don't run coaching.
Ensure that your .env file contains each HF_TOKEN and GITHUB_TOKEN earlier than you start.
// Working in Interactive Mode
You open a chat session, sort the immediate, watch it work, and observe up if wanted.
Run this command:
Then sort your immediate on the > immediate:
Discover the rotten_tomatoes dataset on the Hub and write a brief Python script that masses it with datasets and prints the primary instance. Put it aside to /tmp/load_dataset_interactive.py. Don't run coaching.
Output:
Initializing agent runtime...
Person: kanwal8008
Mannequin: zai-org/GLM-5.2:novita
Device runtime: native filesystem
Instruments: 25 loaded
/assist for instructions · /mannequin to change · /give up to exit
Prepared. Let's construct one thing spectacular.
> Discover the rotten_tomatoes dataset on the Hub and write a brief Python script that masses it with datasets and prints the primary instance. Put it aside to /tmp/load_dataset_interactive.py. Don't run coaching.
The dataset is cornell-movie-review-data/rotten_tomatoes. It has a single default config with practice/validation/take a look at splits, columns are textual content and label. Writing the script now.
▸ write {"content material": """"Load the rotten_tomatoes dataset from the HF Hub and print th..."}
Finished. The script is saved to /tmp/load_dataset_interactive.py.
What it does:
- Hundreds cornell-movie-review-data/rotten_tomatoes through datasets.load_dataset
- Prints the listing of splits (practice, validation, take a look at)
- Prints the primary coaching instance (a {"textual content": ..., "label": ...} dict)
Dataset particulars:
- Columns: textual content (film evaluate sentence), label (0 = unfavourable, 1 = constructive)
- ~10.6k examples complete (5,331 constructive / 5,331 unfavourable)
You possibly can run it regionally with:
python /tmp/load_dataset_interactive.py
> /give up
Bye.
File it created (/tmp/load_dataset_interactive.py):
"""Load the rotten_tomatoes dataset from the HF Hub and print the primary instance."""
from datasets import load_dataset
# Load the total dataset (all splits) from the Hub
ds = load_dataset("cornell-movie-review-data/rotten_tomatoes")
print("Dataset splits:", listing(ds.keys()))
first_train = ds["train"][0]
print("First coaching instance:")
print(first_train)
print("nLabel which means: 0 = unfavourable, 1 = constructive")
Interactive mode provides you extra context as it really works, together with dataset particulars, what the script does, and the best way to run it. It’s also possible to ask follow-up questions earlier than typing /give up.
// Working in Headless Mode
One command, the agent runs from begin to end, then exits.
Run this command:
ml-intern --max-iterations 15 --no-stream
"Discover the rotten_tomatoes dataset on the Hub and write a brief Python script that masses it with datasets and prints the primary instance. Put it aside to /tmp/load_dataset.py. Don't run coaching."
Output:
HF token loaded
Mannequin: zai-org/GLM-5.2:novita
Device runtime: native filesystem
Max iterations: 15
Immediate: Discover the rotten_tomatoes dataset on the Hub and write a brief Python script that masses it with datasets and prints the primary instance. Put it aside to /tmp/load_dataset.py. Don't run coaching.
---
▸ hf_inspect_dataset {"dataset": "cornell-movie-review-data/rotten_tomatoes", "sample_rows": 1}
▸ write {"content material": "from datasets import load_datasetnndataset = load_dataset("rotte..."}
▸ bash {"command": "cd /tmp && python load_dataset.py", "description": "Run the dataset..."}
Finished. The script is saved at /tmp/load_dataset.py and verified working. It masses the rotten_tomatoes dataset (dataset ID: cornell-movie-review-data/rotten_tomatoes) through datasets.load_dataset and prints the primary coaching instance:
{'textual content': 'the rock is destined to be the twenty first century's new " conan " ...',
'label': 1}
The dataset has two columns -- textual content (the evaluate) and label (0 = unfavourable, 1 = constructive) -- throughout practice (8,530 rows), validation (1,066), and take a look at (1,066) splits.
--- Agent turn_complete (history_size=9) ---
File it created (/tmp/load_dataset.py):
from datasets import load_dataset
dataset = load_dataset("rotten_tomatoes", cut up="practice")
print(dataset[0])
Headless mode auto-approves all the pieces. That is helpful when you understand what you need and don’t must steer the run within the center.
# Working ML Intern With Native Fashions
For those who would fairly not use Hugging Face Inference Suppliers or pay for API utilization, ML Intern can even work with regionally hosted fashions. As an alternative of downloading and loading mannequin weights itself, ML Intern connects to an OpenAI-compatible server that’s already operating in your machine.
Meaning you need to use widespread native inference frameworks corresponding to:
For instance, in case you are utilizing Ollama, you possibly can run:
ml-intern --model ollama/llama3.1:8b "Summarize the README on this repository."
Or, in case you are operating a mannequin with vLLM:
ml-intern --model vllm/meta-llama/Llama-3.1-8B-Instruct "Your immediate"
In case your native mannequin server is operating on a customized endpoint, you possibly can configure it with setting variables:
LOCAL_LLM_BASE_URL=http://localhost:8000
LOCAL_LLM_API_KEY=optional-if-your-server-requires-it
Some suppliers additionally help their very own setting variables. For instance, in case you are utilizing Ollama, you possibly can set OLLAMA_BASE_URL, which takes priority over the generic LOCAL_LLM_BASE_URL. One necessary factor to bear in mind is {that a} tiny native mannequin will wrestle with multi-step coaching pipelines. It’s high quality for exploration and script drafting, however for severe agent loops, you will have one thing with extra reasoning headroom.
# Understanding How ML Intern Works
You don’t want to memorize the structure, however it helps to know why the agent typically pauses and asks you to approve one thing. The agent runs an iterative loop of as much as 300 turns by default. The flowchart under provides a tough concept of what occurs on every name.

How ML Intern processes every name
One in every of ML Intern’s largest strengths is the variety of instruments it might use out of the field. Constructed-in instruments cowl the HF ecosystem, together with docs, datasets, repositories, papers, and jobs, plus GitHub search, native file operations, planning helpers, and something you connect via Mannequin Context Protocol (MCP). There may be even a doom loop detector that catches repeated software calls with the identical arguments, which is a well-known drawback you probably have used coding brokers earlier than.
Each session can auto-upload to a non-public dataset in your Hub account ({username}/ml-intern-sessions) in a format the Agent Hint Viewer understands. These traces are particularly helpful for debugging as a result of they allow you to examine each reasoning step the agent took. If one thing goes mistaken, you possibly can open the session within the Agent Hint Viewer and see precisely the place the agent made a poor resolution.
It’s also possible to management how traces are shared throughout a session:
/share-traces personal
/share-traces public
Or you possibly can disable hint uploads fully via the configuration file if you do not need to save lots of session historical past.
# Avoiding Frequent Errors
- Be particular along with your prompts. “Positive-tune llama” is obscure. “Positive-tune
meta-llama/Llama-3.2-1Bonimdbwith LoRA, max 1 epoch, don’t push to Hub” is best. - Watch the approvals. Coaching jobs value cash. Sandboxes value cash. The agent will ask, so don’t blindly approve all the pieces in your first run.
- Set
--max-iterationsin case you are experimenting. The default restrict of 300 iterations is nice for advanced duties however can waste compute throughout testing. - Examine your traces. When one thing unusual occurs, your personal session dataset on the Hub is the black field recorder.
# Taking the Subsequent Steps
ML Intern is not going to substitute your judgment. You continue to must learn the coaching logs, sanity-check the analysis, and resolve whether or not 32% on GPQA is definitely what you needed. However you probably have ever stared at a clean practice.py questioning the place to start out, having an intern who already is aware of the Hub is a powerful first step.
Run ml-intern, give it one thing small, and see what it does. That’s the recreation initially. Just a few sensible subsequent steps:
- Discover the GitHub repository. Browse the supply code, try examples, and keep present with new options and enhancements.
- Create your individual customized instruments. ML Intern is constructed to be extensible. You possibly can add your individual instruments by modifying the
agent/core/instruments.pyfile and reinstalling the package deal:
uv software set up -e . --force
- Join MCP servers. In case you are utilizing MCP, you possibly can connect exterior instruments and providers by updating the
configs/cli_agent_config.jsonfile. Atmosphere variables corresponding to${YOUR_TOKEN}are robotically loaded out of your.envfile. - Allow Slack notifications. Set
SLACK_BOT_TOKENandSLACK_CHANNEL_IDin order for you ping-when-done alerts.
Kanwal Mehreen is a machine studying engineer and a technical author with a profound ardour for knowledge science and the intersection of AI with drugs. She co-authored the e-book “Maximizing Productiveness with ChatGPT”. As a Google Technology Scholar 2022 for APAC, she champions variety and educational excellence. She’s additionally acknowledged as a Teradata Range in Tech Scholar, Mitacs Globalink Analysis Scholar, and Harvard WeCode Scholar. Kanwal is an ardent advocate for change, having based FEMCodes to empower girls in STEM fields.
