{"id":28376524,"url":"https://github.com/foundationagents/aflow","last_synced_at":"2025-09-15T07:32:43.947Z","repository":{"id":282367621,"uuid":"947108760","full_name":"FoundationAgents/AFlow","owner":"FoundationAgents","description":"🔥🔥🔥 ICLR 2025 Oral. Automating Agentic Workflow Generation.","archived":false,"fork":false,"pushed_at":"2025-05-27T03:44:51.000Z","size":1946,"stargazers_count":93,"open_issues_count":5,"forks_count":20,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-27T04:34:40.206Z","etag":null,"topics":["agentic-workflow","agents","multiagent-systems","optimization"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2410.10762","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FoundationAgents.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-12T06:59:49.000Z","updated_at":"2025-05-27T03:44:54.000Z","dependencies_parsed_at":"2025-03-14T08:30:56.956Z","dependency_job_id":"41978381-5086-4414-ba37-b9d71d64f551","html_url":"https://github.com/FoundationAgents/AFlow","commit_stats":null,"previous_names":["foundationagents/aflow"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/FoundationAgents/AFlow","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FoundationAgents%2FAFlow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FoundationAgents%2FAFlow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FoundationAgents%2FAFlow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FoundationAgents%2FAFlow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FoundationAgents","download_url":"https://codeload.github.com/FoundationAgents/AFlow/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FoundationAgents%2FAFlow/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262047824,"owners_count":23250422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agentic-workflow","agents","multiagent-systems","optimization"],"created_at":"2025-05-30T00:07:08.572Z","updated_at":"2025-09-15T07:32:43.932Z","avatar_url":"https://github.com/FoundationAgents.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AFlow: Automating Agentic Workflow Generation\n\n[![Arxiv](https://img.shields.io/badge/arXiv-AFlow-b31b1b)](https://arxiv.org/abs/2410.10762)\n[![PR Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen)](https://github.com/FoundationAgents/AFlow/pulls)\n\n\u003e If you encounter any difficulties in using or reproducing the code, please contact me directly (Email: didi4goooogle@gmail.com, Wechat: 18831933368). Some Operators may have bugs during the migration from MetaGPT to this repository.\n\n\nAFlow is a framework for automatically generating and optimizing Agentic Workflows. It uses Monte Carlo tree search in a code-represented workflow space to find effective workflows, replacing manual development with machine effort. Our approach shows potential to outperform handcrafted workflows on various tasks. \n\nWe're building it to support more benchmarks and open-ended tasks! If you have any questions, please open an issue or email us!\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"\"\u003e\u003cimg src=\"assets/AFLOW-performance.jpg\" alt=\"Performance Of AFlow\" title=\"Performance of AFlow\u003csub\u003e1\u003c/sub\u003e\" width=\"80%\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Framework Components\n\n- **Node**: Basic unit of LLM invocation. See `metagpt_core/action_nodes/action_node.py` for a flexible interface to control LLM, temperature, format, and prompt.\n- **Operator**: Predefined combinations of Nodes to enhance search efficiency. Encapsulates common operations like Generate, Format, Review, Revise, Ensemble, Test, and Programmer. See `operator.py` for details. You can customize your own Operator by referencing the implementations in this code.\n- **Workflow**: A sequence of LLM-invoking nodes connected by edges. Can be represented as graphs, neural networks, or code to express various execution structures. See `workflow.py` for our implementation.\n- **Optimizer**: Uses LLMs within a Monte Carlo Tree Search variant to explore and refine workflows. Iteratively selects, expands, evaluates, and updates workflows based on performance. See `optimizer.py` for details.\n- **Evaluator**: Assesses workflow performance on given tasks. Provides feedback to guide the optimization process towards more effective workflows. See `evaluator.py` for details.\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"\"\u003e\u003cimg src=\"assets/AFLOW-method.jpg\" alt=\"Framework of AFlow\" title=\"Framework of AFlow \u003csub\u003e1\u003c/sub\u003e\" width=\"80%\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Datasets\n\n### Experimental Datasets\nWe conducted experiments on six datasets (HumanEval, MBPP, GSM8K, MATH, HotpotQA, DROP) and provide their evaluation code. The data can be found in this [datasets](https://drive.google.com/uc?export=download\u0026id=1DNoegtZiUhWtvkd2xoIuElmIi4ah7k8e) link, or you can download them using `metagpt/ext/aflow/data/download_data.py`\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"\"\u003e\u003cimg src=\"assets/AFLOW-experiment.jpg\" alt=\"Performance Of AFlow\" title=\"Performance Of AFlow \u003csub\u003e1\u003c/sub\u003e\" width=\"80%\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n### Custom Datasets\nFor custom tasks, you can reference the code in the `benchmark` folder. Inherit the `BaseBenchmark` class and implement `evaluate_problem`, `calculate_score`, and `get_result_columns` to add your custom dataset benchmark. Then, add your benchmark name in `evaluator.py` and `optimizer.py` to find effective workflows for your custom dataset.\n\n## Quick Start\n\n1. Set up the Python environment:\n   ```bash\n   # Create and activate a Python 3.9 virtual environment\n   conda create -n \u003cyour_env_name\u003e python=3.9\n\n   # Install dependencies\n   pip install -r requirements.txt\n   ```\n\n2. Configure optimization parameters:\n   - Use command line arguments or modify default parameters in `run.py`:\n     ```python\n     --dataset              # (Required) Dataset type (HumanEval/MBPP/GSM8K/MATH/HotpotQA/DROP)\n     --sample 4             # Sample count - number of workflows to be resampled\n     --optimized_path PATH  # Optimized result save path\n     --initial_round 1      # Initial round\n     --max_rounds 20        # Max iteration rounds for AFLOW\n     --check_convergence    # Whether to enable early stop\n     --validation_rounds 5  # Validation rounds for AFLOW\n     --if_force_download    # Force dataset download if set to True\n     ```\n\n3. Configure LLM parameters in `config/config2.yaml` (see `config/config2.example.yaml` for reference)\n\n4. Set up operators in `run.py` and in `operator.py`, `optimized_path/template/operator.json`. You can reference our implementation to add operators for specific datasets\n\n5. For first-time use, download datasets and initial rounds by setting `download([\"datasets\"])` in `run.py`\n\n6. (Optional) Add your custom dataset and corresponding evaluation function following the [Custom Datasets](#custom-datasets) section\n\n7. (Optional) If you want to use a portion of the validation data, you can set `va_list` in `evaluator.py`\n\n8. Run the optimization:\n   ```bash\n   # Using default parameters\n   python run.py --dataset MATH\n   \n   # Or with custom parameters\n   python run.py --dataset MATH --sample n --optimized_path xxx ...\n   ```\n\n## Reproduce the Results in the Paper\n1. We provide the raw data obtained from our experiments in this [link](https://drive.google.com/uc?export=download\u0026id=1Sr5wjgKf3bN8OC7G6cO3ynzJqD4w6_Dv), including the workflows and prompts generated in each iteration, as well as their trajectories on the validation dataset. We also provide the optimal workflow for each dataset and the corresponding data on the test dataset. You can download these data using `data/download_data.py`. \n2. You can directly reproduce our experimental results by use different `ExperimentConfig` of `run.py`.\n\n## Roadmap\n\n- Support multiple search algorithms\n- Support multi model search in workflow\n- Support LeaderBoard\n- Support more benchmarks\n- Support multimodality tasks\n\n## Citation\n\nIf you use AFlow in your research, please cite our paper:\n\n```\n@inproceedings{\n   zhang2025aflow,\n   title={{AF}low: Automating Agentic Workflow Generation},\n   author={Jiayi Zhang and Jinyu Xiang and Zhaoyang Yu and Fengwei Teng and Xiong-Hui Chen and Jiaqi Chen and Mingchen Zhuge and Xin Cheng and Sirui Hong and Jinlin Wang and Bingnan Zheng and Bang Liu and Yuyu Luo and Chenglin Wu},\n   booktitle={The Thirteenth International Conference on Learning Representations},\n   year={2025},\n   url={https://openreview.net/forum?id=z5uVAKwmjf}\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoundationagents%2Faflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoundationagents%2Faflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoundationagents%2Faflow/lists"}