File size: 5,578 Bytes
96abbd8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | # Agora-Opt Code Package
## What This Directory Contains
`./code/Agora-Opt/` is the source directory for the Agora-Opt method. It
retains two categories of assets:
- the Agora-Opt implementation
- prebuilt memory assets used by the method
Historical run outputs are not stored here.
For compatibility with the original stage naming, the main reproduction script
maintains two convenience paths:
- `generated_with_memory`
- `debate_runs`
## Important Subdirectories
The most important components are:
- `src/debate_memory/`: core Agora-Opt implementation
- `scripts/`: command-line wrappers
- `memory_storage/`: solution memory
- `debug_case_memory/`: debug memory retrieval bank
- `debate_memory_storage/`: debate memory retrieval bank
- `memory_variants/`: retained alternative memory variants
- `memory_backups/`: retained memory backups
Multiple memory versions are intentionally kept. They were prepared during
different stages of the project and can all be treated as available assets for
generation, debugging, and debate.
## Core Workflow
Agora-Opt runs in two stages.
### Stage 1: Generate Initial Solutions
`generate_with_memory.py` generates candidate solutions, optionally using
solution memory and debug memory.
Primary entry script:
- `scripts/generate_with_memory.py`
This stage:
- reads benchmark problems
- retrieves similar solved cases from `memory_storage/`
- generates candidate modeling code
- uses debug memory during self-repair when execution fails
### Stage 2: Run Debate
`run_memory_debate.py` takes two sets of initial solutions and runs the
decentralized debate stage.
Primary entry script:
- `scripts/run_memory_debate.py`
This stage:
- loads both sides' initial solutions
- retrieves historical debate cases from `debate_memory_storage/`
- performs iterative comparison, revision, and convergence
- executes and evaluates the final consensus solution
## Memory Types
### 1. Solution Memory
Directory:
- `memory_storage/`
Purpose:
- retrieves similar successful modeling cases during generation
- supplies formulation templates and structural priors
Build path:
- extract `(problem description, correct code, objective value)` from correctly
evaluated runs
- build `cases.jsonl` plus its retrieval index
Related script:
- `scripts/build_memory_from_eval_results.py`
### 2. Debug Memory
Directory:
- `debug_case_memory/`
Purpose:
- retrieves similar execution failures and repair experience
- supports automatic self-debugging during generation
Build path:
- extract unique error signatures from `debug_memory.jsonl` and its backups
- normalize the error text, repair hints, and metadata into a retrieval bank
Related script:
- `scripts/build_debug_memory.py`
Note:
- raw debug logs are stored in `memory_storage/debug_memory.jsonl`
- that log file is one of the inputs used to build debug memory
### 3. Debate Memory
Directory:
- `debate_memory_storage/`
Purpose:
- stores examples of how disagreements were resolved during debate
- helps later debates converge more efficiently
Build path:
- select historical runs where the two initial solutions disagreed
- keep cases where debate eventually converged successfully
- extract the dispute, key arguments, and final converged code
Related scripts:
- `scripts/build_debate_memory.py`
- `scripts/process_all_debate_cases.sh`
## Suggested Memory Construction Order
When preparing memory from scratch, the recommended order is:
1. run generation and evaluation to obtain `evaluation_results`
2. build solution memory from correct cases
3. build debug memory from accumulated `debug_memory.jsonl`
4. build debate memory from historical debate runs
The dependency flow is:
- `evaluation_results` -> `solution memory`
- `debug_memory.jsonl` -> `debug memory`
- debate run artifacts -> `debate memory`
## Retained Memory Assets
This directory intentionally keeps:
- the three primary memory stores
- memory variants
- memory backups
These are treated as static method assets.
Historical run outputs are not retained here, which keeps source code, memory
assets, and new results clearly separated.
To rebuild the three memory types, use:
```bash
bash ./code/Agora-Opt/scripts/build_memory_assets.sh /path/to/eval_dir1 /path/to/eval_dir2
```
That script attempts to:
- rebuild solution memory from evaluation directories
- rebuild debug memory from `debug_memory.jsonl` and its backups
- rebuild debate memory from debate run artifacts
## Recommended Entry Points
For paper reproduction, use the outer scripts rather than manually assembling
commands in this directory:
- main table: `./code/scripts/run_agora.sh`
- 5.1: `./code/experiments/5.1_compatibility_backbone_llms/`
- 5.2: `./code/experiments/5.2_ablation_study/`
- 5.3.1: `./code/experiments/5.3.1_centralized_judge_selection/`
- 5.3.2: `./code/experiments/5.3.2_impact_of_debate_rounds/`
- 5.3.3:
`./code/experiments/5.3.3_generalization_of_decentralized_debate_protocol/`
## Direct Source-Level Usage
For direct method-level use, the main wrappers are:
```bash
python scripts/generate_with_memory.py
python scripts/run_memory_debate.py
python scripts/execute.py
python scripts/build_memory_from_eval_results.py
python scripts/build_debug_memory.py
python scripts/build_debate_memory.py
```
## Path Conventions
Within the open-source package, the intended layout is:
- benchmark data: `./data/benchmarks/`
- Agora-Opt source code and memory: `./code/Agora-Opt/`
This separation makes the boundaries between code, memory assets, and newly
generated outputs explicit.
|