Coder Social home page Coder Social logo

hmaw's Introduction

HMAW: Hierarchical Multi-Agent Workflow for Prompt Optimization

Yuchi Liu, Jaskirat Singh, Wen Gao, Ali Payani, Liang Zheng

License: MIT

This repository contains the implementation of the Hierarchical Multi-Agent Workflow (HMAW) for prompt optimization in large language models (LLMs).

Figure 1


Prerequisites

Before running the scripts, ensure you have Python installed along with the necessary packages. You can install these packages using the provided requirements file.

Required Packages

  • fire==0.5.0
  • ipython==8.12.3
  • numpy==1.26.4
  • openai==1.30.4
  • pandas==2.2.2
  • setuptools==68.2.2
  • tqdm==4.66.1

๐Ÿ”ง Installation

To install the required packages, execute the following command:

pip install -r requirements.txt

๐Ÿ”ง vLLM Model Installation

For installing and running the Mixtral model using vLLM, refer to the official vLLM documentation.


Directory Structure Preparation

To utilize the provided scripts effectively, please organize your data according to the following directory structure:

โ”œโ”€โ”€ data
โ”‚   โ”œโ”€โ”€ Education
โ”‚   โ”œโ”€โ”€ FED
โ”‚   โ”œโ”€โ”€ GSM8K
โ”‚   โ”œโ”€โ”€ ATLAS
โ”‚   โ””โ”€โ”€ CodeNet
โ”œโ”€โ”€ log
โ”‚   โ”œโ”€โ”€ compare_ATLAS_HMAW_base_mixtral_gpt3.5.json
โ”‚   โ”œโ”€โ”€ response_ATLAS_HMAW_mixtral.json
โ”‚   โ”œโ”€โ”€ response_ATLAS_base_mixtral.json
โ”‚   โ”œโ”€โ”€ compare_Education_HMAW_base_mixtral_gpt3.5.json
โ”‚   โ”œโ”€โ”€ response_Education_HMAW_mixtral.json
โ”‚   โ”œโ”€โ”€ response_Education_base_mixtral.json
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ eval_ATLAS.py
โ”œโ”€โ”€ ...
โ”œโ”€โ”€ eval_compare.py
โ”œโ”€โ”€ eval_correctness.py
โ””โ”€โ”€ ...

Log Files Description

  • compare_ATLAS_HMAW_base_mixtral_gpt3.5.json: Contains comparison results of evaluator preferences between responses generated using HMAW prompts and basic user queries. The mixtral model is the LLM agent, and gpt3.5 is the evaluator.

  • response_Education_HMAW_mixtral.json: Contains responses generated using the HMAW method with the mixtral model as the agent.

Note

  • The log directory contains detailed comparison and response logs for various models and methods.
  • The root directory includes essential evaluation scripts (eval_ATLAS.py, eval_compare.py, eval_correctness.py, etc.).

By maintaining this structure, you ensure that the scripts can locate and process the data and logs correctly, facilitating seamless evaluation and comparison of model responses.


How to Run

๐Ÿ”ง Generate Responses

To execute prompt optimization and response generation, use the following command:

python eval_{dataset}.py

Replace {dataset} with one of the following options to represent different datasets: ATLAS, education, fed, codenet, or GSM.

๐Ÿ”ง Test

Testing on ATLAS, education, fed, and codenet:

Run the following command:

python eval_compare.py

Please ensure to update the related file names in eval_compare.py to test under various settings.

Testing on GSM๏ผš

Run the following command:

python eval_correctness.py

Customizing Prompting Methods

For details on how to change the prompting methods used in response generation, please refer to the prompter.py file.


Citation

If you find our code helpful, please consider citing our paper:

@misc{liu2024hierarchical,
      title={Towards Hierarchical Multi-Agent Workflows for Zero-Shot Prompt Optimization}, 
      author={Yuchi Liu and Jaskirat Singh and Gaowen Liu and Ali Payani and Liang Zheng},
      year={2024},
      eprint={2405.20252},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}

License

This project is open source and available under the MIT License.

hmaw's People

Contributors

liuyvchi avatar

Stargazers

Crates McDade avatar Shuai Zhao avatar Liang Zheng avatar Lei Wang avatar Yang Yang avatar Zeyu Zhang avatar yue yao avatar  avatar Xingjian Leng avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.