# ml-intern

> An agent that reads the papers, writes the training code and ships the model

- Category: AI Coding / Autonomous Coding Agents
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/huggingface/ml-intern
- Canonical page: https://ai-tldr.dev/tools/ml-intern/
- Updated: 2026-04-21

## In short

ml-intern is an open-source agent that does machine-learning engineering work end to end rather than answering questions about it. It sits in the Autonomous Coding Agents category of the AI Coding tools and is open-source, written in Python and licensed Apache-2.0. To get started: clone and install.

## Overview

ml-intern is an open-source agent that does machine-learning engineering work end to end rather than answering questions about it. Given a goal, it researches — reading documentation and papers, looking for datasets and existing models on the Hub — then writes the code, runs it against local or cloud compute, reads the results and iterates. The output is a trained model and the code that produced it, not a suggestion.

It runs as a terminal application, either interactively as a chat or headlessly against a single prompt, which is what makes it usable for long jobs you leave running. Authentication is a Hugging Face token plus a GitHub token; models can come from a hosted provider or from any OpenAI-compatible endpoint, so Ollama, vLLM, LM Studio and llama.cpp all work as the driving model.

Practical guardrails come from the agent runtime rather than the prompt: tools can execute in a sandbox or against the local filesystem, sensitive operations sit behind approval gates, and a doom-loop detector interrupts the agent when it starts repeating the same tool pattern. Sessions can be auto-uploaded to a private Hugging Face dataset so a long run is reviewable afterwards, and MCP servers can be attached to give the agent extra tools.

## What it does

- Runs the full loop — literature and docs research, dataset discovery, training code, execution, evaluation — as one agent
- Interactive chat mode and headless single-prompt execution for unattended runs
- Driven by a hosted model or any OpenAI-compatible local endpoint (Ollama, vLLM, LM Studio, llama.cpp)
- Sandbox or local-filesystem tool runtimes, with approval gates on sensitive operations
- Doom-loop detector that breaks the agent out of repeated tool patterns
- Optional session upload to a private Hugging Face dataset, and one-way notification gateways such as Slack
- MCP server integration for additional tools

## Getting started

The project is installed from a checkout with uv, then exposed as the `ml-intern` command.

1. Clone and install

   uv sync resolves the environment; uv tool install -e . puts the CLI on your PATH as an editable install.

```bash
git clone git@github.com:huggingface/ml-intern.git
cd ml-intern
uv sync
uv tool install -e .
```

2. Set your tokens

   A Hugging Face token gives the agent access to the Hub; a GitHub personal access token lets it work with repositories.

```bash
HF_TOKEN=<your-hugging-face-token>
GITHUB_TOKEN=<github-personal-access-token>
```

3. Run it

   With no arguments the agent starts in interactive chat mode; pass a prompt to run headlessly instead.

```bash
ml-intern
```

4. Point it at a local model

   Any OpenAI-compatible endpoint works as the driving model, so you can run the agent against Ollama, vLLM or LM Studio instead of a hosted API.

## When to use it

- Hand off a post-training experiment — pick a base model, find data, fine-tune, evaluate — and read the results later
- Sweep a family of training configurations overnight in headless mode instead of babysitting a notebook
- Turn a paper you want to reproduce into a running training script grounded in the Hugging Face ecosystem
- Run the whole loop against a local model endpoint when the data cannot leave your machine

## Version history

- 2026-04-21: Hugging Face released ml-intern as an open-source agent that runs the LLM post-training loop autonomously — literature review, dataset discovery, training and evaluation.
