| 1 | # Replicating results on SWE-bench-lite |
| 2 | |
| 3 | ## Setup |
| 4 | |
| 5 | ### Docker |
| 6 | |
| 7 | > [!IMPORTANT] |
| 8 | > There can be minor improvements to the Docker image from time to time. Please pull the latest version of the image. |
| 9 | |
| 10 | > [!NOTE] |
| 11 | > The experiments were conducted on Ubuntu 20.04. Since SWE-bench evaluation may have different behavior |
| 12 | > under different host systems, it is recommened to run the provided docker on Ubuntu 20.04. |
| 13 | |
| 14 | We have built a docker image with all task instances environment in it (it's a large image ~25GB!). |
| 15 | With this image, you can directly start an experiment run. |
| 16 | |
| 17 | ``` |
| 18 | docker pull yuntongzhang/auto-code-rover:experiment |
| 19 | ``` |
| 20 | |
| 21 | ## Experiment preparation |
| 22 | |
| 23 | Start a container: |
| 24 | |
| 25 | ``` |
| 26 | docker run -it yuntongzhang/auto-code-rover:experiment |
| 27 | ``` |
| 28 | |
| 29 | Activate the conda environment in it. |
| 30 | |
| 31 | ``` |
| 32 | conda activate auto-code-rover |
| 33 | ``` |
| 34 | |
| 35 | Set some temp git info: |
| 36 | |
| 37 | ``` |
| 38 | git config --global user.email acr@nus.edu.sg |
| 39 | git config --global user.name acr |
| 40 | ``` |
| 41 | |
| 42 | In the container, specify your OpenAI key in the `OPENAI_KEY` environment variable: |
| 43 | |
| 44 | ``` |
| 45 | export OPENAI_KEY=xx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
| 46 | ``` |
| 47 | |
| 48 | ## Run! |
| 49 | |
| 50 | In the `/opt/auto-code-rover/` directory in the container, issue the following command to start |
| 51 | the experiment run using `gpt-4-0125-preview` on SWE-bench-lite. |
| 52 | (From our experience, one run with `gpt-4-0125-preview` on the 300 instances costs <150 USD on OpenAI API.) |
| 53 | |
| 54 | ``` |
| 55 | python scripts/run.py conf/vanilla-lite.conf |
| 56 | ``` |
| 57 | |
| 58 | This command runs auto-code-rover on the 300 instances in SWE-bench-lite, and runs the SWE-bench |
| 59 | evaluation on the generated patches. The final results of the experiment will be at |
| 60 | `/opt/auto-code-rover/experiment/vanilla-lite/final_report.json`. |
| 61 | |
| 62 | |
| 63 | ### Running experiments multiple times |
| 64 | |
| 65 | When running multiple experiments (sequentially), we recommend using a different `id` in the conf |
| 66 | file for each experiment. This is because the outputs for an experiment will be created in a directory |
| 67 | using `id` as the name. |
| 68 | |
| 69 | If you want to use the same `id` for multiple experiments and overwrite the previous experiment results, |
| 70 | you can use the `-f` option of `scripts/run.py`. This will remove the previous experiment results with |
| 71 | the same `id`. |
| 72 | |
| 73 | |
| 74 | ### Note on running experiments in parallel |
| 75 | |
| 76 | We do not recommend creating multiple processes running the script `scripts/run.py`. This is because |
| 77 | different tasks instances may share the same copy of local code base (e.g. `astropy-6938` and |
| 78 | `astropy-7746` share the same codebase at `setup_astropy__astropy__1.3`). |
| 79 | |
| 80 | Instead, we support parallelism of experiments in `scripts/run.py` itself. Please set the value |
| 81 | of `num_processes` in the conf file to control how many tasks can be run in parallel. The scripts |
| 82 | internally handle the parallelism issue mentioned above. |
| 83 | |
| 84 | |
| 85 | ### Changing the conf file |
| 86 | |
| 87 | You can modify the `conf/vanilla-lite.conf` file to set parameters such as model temperature etc. |
| 88 | Here are a few useful fields in the conf file: |
| 89 | |
| 90 | - id: determines the name of the experiment output folder |
| 91 | - experiment_dir: where output will be stored |
| 92 | - setup_result_dir: must point to the directory where SWE-bench setup writes its results |
| 93 | - eval_log_dir: where the SWE-bench evaluation log is written to |
| 94 | |
| 95 | - model: the model to be used by auto-code-rover |
| 96 | - temperature: model temperature |
| 97 | - conv_round_limit: rounds limit for the conversation with context retrieval agent |
| 98 | - selected_tasks_file: a file containing ids of all tasks to be run |
| 99 | - print: whether to the print more info to console |
| 100 | - num_processes: number of parallel processes when running auto-code-rover. Should not be too large, otherwise parallelly running multiple task instances can exceed OpenAI token limit and cause the task instance to fail. |
| 101 | |
| 102 | ### Contacts |
| 103 | |
| 104 | > [!NOTE] |
| 105 | > If you encounter any issue in the replication experiment, you can open an GitHub issue or contact us at {yuntong,hruan,zhiyufan}@comp.nus.edu.sg. |