This repository contains code for our GECCO paper: Competition and Attraction Improve Model Fusion (arxiv).
Using this repository you can reproduce the results in the image below, which shows that M2N2 (Model Merging with Natural Niches) can achieve comparable results to CMA-ES when evolving MNIST classifiers from scratch, and it is the best method to evolve pre-trained models.
conda env create -f environment.yml
This will create a new Conda environment named natural_niches with all required packages.
conda activate natural_niches
You can run different methods by specifying the --method parameter. Replace with one of the following options: natural_niches
, map_elites
, cma_es
, or ga
.
python main.py --method <method>
Example: Run the ga
without crossover:
python main.py --method ga --no_crossover
The default is to run evolution from scratch. To start from pre-trained add the --use_pre_trained
argument.
Example: Run the map_elites
starting from pre-trained models:
python main.py --method map_elites --use_pre_trained
To visualize the results, open the Jupyter notebook plotting.ipynb
and run all the cells.
If you use this code or the ideas from our paper, please cite our work:
@article{sakana2025m2n2,
title={Competition and Attraction Improve Model Fusion},
author={Abrantes, Jo\~{a}o and Lange, Robert and Tang, Yujin},
booktitle={Proceedings of the 2025 genetic and evolutionary computation conference},
pages={1217--1225},
year={2025}
}