Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Darwin Gödel Machine:
Open-Ended Evolution of Self-Improving Agents

Repository for Darwin Gödel Machine (DGM), a novel self-improving system that iteratively modifies its own code (thereby also improving its ability to modify its own codebase) and empirically validates each change using coding benchmarks.

Setup

# API keys, add to ~/.bashrc
export OPENAI_API_KEY='...'
export ANTHROPIC_API_KEY='...'
# Verify that Docker is properly configured in your environment.
docker run hello-world
 
# If a permission error occurs, add the user to the Docker group
sudo usermod -aG docker $USER
newgrp docker
# Install dependencies
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

# Optional: for running analysis
sudo apt-get install graphviz graphviz-dev
pip install -r requirements_dev.txt
# Clone SWE-bench
cd swe_bench
git clone https://github.com/princeton-nlp/SWE-bench.git
cd SWE-bench
git checkout dc4c087c2b9e4cefebf2e3d201d27e36
pip install -e .
cd ../../

# Prepare Polyglot
# Make sure git is properly configured in your environment with username and email
python -m polyglot.prepare_polyglot_dataset

Running the DGM

python DGM_outer.py

By default, outputs will be saved in the output_dgm/ directory.

File Structure

  • analysis/ scripts used for plotting and analysis
  • initial/ SWE-bench logs and performance of the initial agent
  • initial_polyglot/ Polyglot logs and performance of the initial agent
  • swe_bench/ code needed for SWE-bench evaluation
  • polyglot/ code needed for Polyglot evaluation
  • prompts/ prompts used for foundation models
  • tests/ tests for the DGM system
  • tools/ tools available to the foundation models
  • coding_agent.py main implementation of the initial coding agent
  • DGM_outer.py entry point for running the DGM algorithm

Local, single-LLM trading self-improvement (no seed strategy)

This repo includes a minimal ProFiT-style loop that lets one local LLM design and self-improve trading strategies from scratch (no fixed template).

  1. Place data (copy locally; large files stay ignored):
  • Put tick CSVs under data/raw/ (same layout as your external folders).
  1. Ingest + resample ticks to bars:
python trading_data.py --raw-root data/raw --freq 1min --tz Asia/Kolkata --output-dir data/processed
  1. Run self-improvement (local LLM only; default hf-local:hf_models/Qwen2.5-7B-Instruct):
python trading_self_improve.py --data data/processed/NIFTY-I.NFO_1min.parquet --iterations 3 --cash 100000 --commission 0.0005

Outputs land in output_selfimprove_local/<run_id>/ with per-iteration strategy code and metrics. The LLM must invent a full GeneratedStrategy using backtesting.py; no seed strategy is provided.

Evolutionary tree with UCB/MCTS pruning (container-capable)

  • Evolution engine: trading_evo.py builds a population/generational tree, uses UCB1 (MCTS-style) for parent selection, and prunes low-value branches. Lineage and metrics are saved to output_selfimprove_local_evo/<run_id>/lineage.json.
  • Host run (fastest):
python trading_evo.py --data data/processed/NIFTY-I.NFO_1min.parquet --pop-size 20 --generations 15 --ucb-c 2.0
  • Container eval (uses DGM Docker image; mounts data and hf_models):
python trading_evo.py --data data/processed/NIFTY-I.NFO_1min.parquet --pop-size 20 --generations 15 --ucb-c 2.0 --container
  • Ensure hf_models/ exists locally (quantized to fit 24GB) and Docker with GPU is available. Data is read from data/processed (ignored by Git).

Logs from Experiments

This google drive folder contains all the foundation model output logs from the experiments shown in the paper.

Safety Consideration

Warning

This repository involves executing untrusted, model-generated code. We strongly advise users to be aware of the associated safety risks. While it is highly unlikely that such code will perform overtly malicious actions under our current settings and with the models we use, it may still behave destructively due to limitations in model capability or alignment. By using this repository, you acknowledge and accept these risks.

Acknowledgement

The evaluation framework implementations are based on the SWE-bench and polyglot-benchmark repositories.

Citing

If you find this project useful, please consider citing:

@article{zhang2025darwin,
  title={Darwin Godel Machine: Open-Ended Evolution of Self-Improving Agents},
  author={Zhang, Jenny and Hu, Shengran and Lu, Cong and Lange, Robert and Clune, Jeff},
  journal={arXiv preprint arXiv:2505.22954},
  year={2025}
}

About

Darwin Gödel Machine: Open-Ended Evolution of Self-Improving Agents

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages