# AIDE ML

> An LLM agent that tree-searches ML code toward your metric

- Category: Training & Fine-Tuning / AutoML & Low-Code Training
- Language: Python
- Licence: MIT
- Repository: https://github.com/WecoAI/aideml
- Website: https://weco.ai
- Canonical page: https://ai-tldr.dev/tools/aideml/

## In short

AIDE ML is the open-source reference implementation of AIDE (AI-Driven Exploration in the Space of Code), the algorithm Weco AI describes in its paper of the same name. It sits in the AutoML & Low-Code Training category of the Training & Fine-Tuning tools and is open-source, written in Python and licensed MIT.

## Overview

AIDE ML is the open-source reference implementation of AIDE (AI-Driven Exploration in the Space of Code), the algorithm Weco AI describes in its paper of the same name. You point it at a directory of data, state a goal and an evaluation metric in plain English, and the agent writes Python solutions, runs them, reads the validation score and keeps improving the code until its step budget runs out. The best script and an interactive plot of everything it tried are written to a log folder.

The core idea is an agentic tree search over code. Each Python script is a node; LLM-generated patches that draft, debug or improve a script become its children, and the metric feedback decides which branches to keep exploring. OpenAI's MLE-bench, a set of 75 Kaggle competitions, used AIDE as a scaffold and reported that its tree search earned several times more medals than the best linear agent it compared against.

The package is aimed at two audiences: researchers studying agent architectures, who can swap in new search heuristics, evaluators or LLM back-ends, and ML practitioners who want a strong baseline pipeline for a dataset quickly. It talks to OpenAI, Anthropic, Gemini or any local model that exposes an OpenAI-compatible API. Weco's commercial product generalises the same method to other code-optimisation jobs; this repository stays the lean, research-friendly version.

## What it does

- Natural-language task spec: a data directory, a goal and a metric are all the agent needs
- LLM-guided tree search that drafts, debugs and improves scripts, pruning branches by validation score
- HTML tree visualiser that shows every node in the search and the code attached to it
- Streamlit web UI for uploading data, setting goal and metric, and watching logs and the best code live
- Model-neutral: OpenAI, Anthropic, Gemini, or local models via an OpenAI-compatible base URL, including a fully local mode
- Usable as a CLI, a Python library (`aide.Experiment`) or a Docker image

## Getting started

AIDE ML is published on PyPI as `aideml` and needs Python 3.10 or newer plus an API key for the model that writes code (or a local OpenAI-compatible server).

1. Install and set a key

   Install the package and export the key for your LLM provider.

```bash
pip install -U aideml
export OPENAI_API_KEY=<your-key>
```

2. Run an optimisation

   Point the `aide` command at a data directory and describe the goal and metric. The repository ships example tasks such as house prices and bitcoin price forecasting. When the run ends, `logs/<id>/best_solution.py` holds the best code found and `logs/<id>/tree_plot.html` lets you inspect the whole solution tree.

```bash
aide data_dir="example_tasks/house_prices" \
     goal="Predict the sales price for each house" \
     eval="RMSE between log-prices"
```

3. Tune the search

   Choose the coding model and the number of improvement steps with dotted flags; `agent.search.num_drafts` sets how many initial drafts are tried. To stay local, set `OPENAI_BASE_URL` to an OpenAI-compatible server such as Ollama and name the model for both code and feedback.

```bash
aide agent.code.model="claude-4-sonnet" agent.steps=50 data_dir=... goal=... eval=...

export OPENAI_BASE_URL="http://localhost:11434/v1"
aide agent.code.model="qwen2.5" agent.feedback.model="qwen2.5" data_dir=... goal=... eval=...
```

4. Drive it from Python

   The same search is available as a library: create an `Experiment` and run it for a number of steps, then read the best solution's validation metric and code.

```python
import aide

exp = aide.Experiment(
    data_dir="example_tasks/bitcoin_price",
    goal="Build a time series forecasting model for bitcoin close price.",
    eval="RMSLE",
)
best_solution = exp.run(steps=2)
print(best_solution.valid_metric)
print(best_solution.code)
```

5. Or use the web UI

   Clone the repository, install it in editable mode (which adds Streamlit) and start the app; paste an API key in the sidebar, upload data, set goal and metric and press Run AIDE.

```bash
git clone https://github.com/WecoAI/aideml.git
cd aideml
pip install -e .
cd aide/webui
streamlit run app.py
```

## When to use it

- Get a strong baseline model for a tabular or time-series dataset without hand-writing the pipeline
- Replicate the AIDE paper or MLE-bench-style experiments on your own tasks
- Prototype new agent search heuristics, evaluators or LLM back-ends on a small, readable codebase
- Run an ML-engineering agent entirely on local models when data cannot leave the machine
