Autonomous ML agent with cognitive loop
Project description
ML-Ralph
ML-Ralph is an autonomous ML agent (Claude or Codex) that thinks like an experienced MLE. It works through a cognitive loop: ORIENT → RESEARCH → HYPOTHESIZE → EXECUTE → ANALYZE → VALIDATE → DECIDE. Based on Ralph.
What you need
- Claude Code or Codex CLI
- A git repo for your ML project
- Python with
uvpackage manager - Weights & Biases account (for experiment tracking)
Install
uv tool install ml-ralph
Quick Start
1. Initialize Ralph in your project
ml-ralph init
This creates:
your-project/
├── .ml-ralph/ # Ralph state directory
│ ├── RALPH.md # Full agent instructions
│ ├── prd.json # PRD (draft)
│ ├── ralph.json # Execution state
│ ├── backlog.json # Hypotheses
│ ├── log.jsonl # Thinking log
│ ├── chat.jsonl # Conversation history
│ └── inbox.json # User commands
├── .claude/skills/ralph/ # Claude skill
├── .codex/skills/ralph/ # Codex skill
├── CLAUDE.md # Claude instructions
└── AGENTS.md # Agent instructions
2. Start a Conversation (SETUP Mode)
ml-ralph chat
Ralph will ask clarifying questions to understand your ML problem and create a PRD together. When the PRD is ready, say /start to begin execution.
3. Run Autonomous Execution
ml-ralph run
Ralph works through the cognitive loop until success criteria are met.
Commands
| Command | Purpose |
|---|---|
ml-ralph init |
Initialize Ralph in current project |
ml-ralph chat |
Interactive SETUP mode to create PRD |
ml-ralph run |
Autonomous EXECUTION through cognitive loop |
ml-ralph status |
Show current state (PRD, execution, backlog) |
ml-ralph log |
View thinking log entries |
ml-ralph hint "msg" |
Send guidance during execution |
ml-ralph pause |
Pause autonomous execution |
ml-ralph resume |
Resume after pause |
ml-ralph reset |
Remove state files (keeps CLAUDE.md, AGENTS.md) |
ml-ralph reset --full |
Remove everything including CLAUDE.md, AGENTS.md |
Options
# Use a different tool (default: claude)
ml-ralph chat --tool codex
ml-ralph run --tool codex
# Set max iterations (default: 100)
ml-ralph run --max-iterations 250
# Force overwrite on init
ml-ralph init --force
Setup Weights & Biases (Required Before Running)
Set up wandb before running ML-Ralph:
# Install wandb
uv add wandb
# Login (opens browser)
wandb login
# Set project name
export WANDB_PROJECT="your-project-name"
State Files
All Ralph state is stored in .ml-ralph/:
| File | Purpose |
|---|---|
.ml-ralph/prd.json |
The approved PRD (contract) |
.ml-ralph/ralph.json |
Execution state |
.ml-ralph/backlog.json |
Hypotheses queue |
.ml-ralph/log.jsonl |
Thinking log |
.ml-ralph/chat.jsonl |
Conversation history |
.ml-ralph/inbox.json |
User commands |
.ml-ralph/RALPH.md |
Full agent instructions |
The Cognitive Loop
ORIENT → RESEARCH → HYPOTHESIZE → EXECUTE → ANALYZE → VALIDATE → DECIDE
↑ │
└─────────────────────────────────────────┘
- ORIENT: Understand the problem, constraints, failure modes
- RESEARCH: Learn from existing knowledge, find SOTA approaches
- HYPOTHESIZE: Form testable bets with expected outcomes
- EXECUTE: Implement minimal changes, run experiments
- ANALYZE: Understand results, examine failures, find patterns
- VALIDATE: Check for leakage, ensure results are trustworthy
- DECIDE: Keep/revert/pivot based on evidence
Debugging
ml-ralph status
ml-ralph log --tail 5
cat .ml-ralph/prd.json | jq '.success_criteria'
Using as a Library
from ml_ralph_cli import PRD, RalphState, Backlog, Hypothesis
from ml_ralph_cli.schemas import EvaluationConfig, Phase, ProjectStatus
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ml_ralph-0.2.0.tar.gz.
File metadata
- Download URL: ml_ralph-0.2.0.tar.gz
- Upload date:
- Size: 22.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee8b66d358e20f1e0e8abf630a7e5d22cce3dddc0a1700f39d4097ad995e5555
|
|
| MD5 |
eeab26b713f88544edfcf252905e33e5
|
|
| BLAKE2b-256 |
a47445338be29deb770bfe33a92fdf998d39bd2623a51feb8f2184e031724d60
|
Provenance
The following attestation bundles were made for ml_ralph-0.2.0.tar.gz:
Publisher:
publish.yml on pentoai/ml-ralph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ml_ralph-0.2.0.tar.gz -
Subject digest:
ee8b66d358e20f1e0e8abf630a7e5d22cce3dddc0a1700f39d4097ad995e5555 - Sigstore transparency entry: 864327578
- Sigstore integration time:
-
Permalink:
pentoai/ml-ralph@a6d2d7dfbd021c13b50f0f5f47eab563698ee9d2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pentoai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a6d2d7dfbd021c13b50f0f5f47eab563698ee9d2 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file ml_ralph-0.2.0-py3-none-any.whl.
File metadata
- Download URL: ml_ralph-0.2.0-py3-none-any.whl
- Upload date:
- Size: 26.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28be5dc3653326f461fbbc5db13e5cf42616e1b995072b3f8903472ac1d75b0e
|
|
| MD5 |
93f746b7c271e2afd0d7417bba0c3c1e
|
|
| BLAKE2b-256 |
dd767da50582c660b0dea7a1b768287710e7a2c597c9568fa3b2ff07dddf6409
|
Provenance
The following attestation bundles were made for ml_ralph-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on pentoai/ml-ralph
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ml_ralph-0.2.0-py3-none-any.whl -
Subject digest:
28be5dc3653326f461fbbc5db13e5cf42616e1b995072b3f8903472ac1d75b0e - Sigstore transparency entry: 864327582
- Sigstore integration time:
-
Permalink:
pentoai/ml-ralph@a6d2d7dfbd021c13b50f0f5f47eab563698ee9d2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pentoai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a6d2d7dfbd021c13b50f0f5f47eab563698ee9d2 -
Trigger Event:
workflow_dispatch
-
Statement type: