Skip to content
/ MoA Public
forked from togethercomputer/MoA

Together Mixture-Of-Agents (MoA) – 65.1% on AlpacaEval with OSS models

License

Notifications You must be signed in to change notification settings

jiuu8888/MoA

Repository files navigation

Mixture-of-Agents

Introduction

Mixture of Agents (MoA) is a novel approach that leverages the collective strengths of multiple LLMs to enhance performance, achieving state-of-the-art results. By employing a layered architecture where each layer comprises several LLM agents, MoA significantly outperforms GPT-4 Omni’s 57.5% on AlpacaEval 2.0 with a score of 65.1%, using only open-source models!

icon

Interactive Demo

The interactive demo showcases a simple multi-turn chatbot where the response is aggregated from various reference models.

Setup

  1. Export Your API Key:

    Ensure you have your Together API key and export it as an environment variable:

    export TOGETHER_API_KEY={your_key}
  2. Install Requirements:

    pip install -r requirements.txt

Running the Demo

To run the interactive demo, execute the following script with Python:

python bot.py

The script will prompt you to input instructions interactively. Here's how to use it:

  1. Start by entering your instruction at the ">>>" prompt.
  2. The system will process your input using the predefined reference models.
  3. It will generate a response based on the aggregated outputs from these models.
  4. You can continue the conversation by inputting more instructions, with the system maintaining the context of the multi-turn interaction.
  5. enter exit to exit the chatbot.

Configuration

You can configure the demo by specifying the following parameters:

  • --aggregator: The primary model used for final response generation.
  • --reference_models: List of models used as references.
  • --temperature: Controls the randomness of the response generation.
  • --max_tokens: Maximum number of tokens in the response.
  • --rounds: Number of rounds to process the input for refinement. (num rounds == num of MoA layers - 1)
  • --num_proc: Number of processes to run in parallel for faster execution.
  • --multi_turn: Boolean to toggle multi-turn interaction capability.

Evaluation Benchmarks

We provide scripts to quickly recreate some of the results presented in our paper For convinence, we have included the code from AlpacaEval, MT-Bench, and FLASK, with necessary modifications. We extend our gratitude to these projects for creating the benchmarks.

Preparation:

# install requirements
pip install -r requirements.txt
cd alpaca_eval
pip install -e .
cd FastChat
pip install -e ".[model_worker,llm_judge]"
cd ..

# setup api keys
export TOGETHER_API_KEY=<TOGETHER_API_KEY>
export OPENAI_API_KEY=<OPENAI_API_KEY>

Run AlpacaEval 2

To run AlpacaEval 2, execute the following scripts:

bash run_generation.sh
bash run_eval.sh

Run MT-Bench

For a minimal example of MT-Bench evaluation, run:

bash run_eval_mt_bench.sh

Run FLASK

For a minimal example of FLASK evaluation, run:

bash run_eval_flask.sh

Please feel free to contact us if you have difficulties in reproducing the results.

Credits

Notably, this work was made possible by the collaborative spirit and contributions of active organizations in the AI field. We appreciate the efforts of Meta AI, Mistral AI, Microsoft, Alibaba Cloud, and DataBricks for developing the Llama 3, Mixtral, WizardLM 2, Qwen 1.5, and DBRX models. Additionally, we extend our gratitude to Tatsu Labs, LMSYS, and KAIST AI for developing the AlpacaEval, MT-Bench, and FLASK evaluation benchmarks.

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.

Citation

If you find this work helpful, please consider citing:

@article{wang2024mixture,
  title={Mixture-of-Agents Enhances Large Language Model Capabilities},
  author={Wang, Junlin and Wang, Jue and Athiwaratkun, Ben and Zhang, Ce and Zou, James},
  journal={arXiv preprint arXiv:2406.04692},
  year={2024}
}

About

Together Mixture-Of-Agents (MoA) – 65.1% on AlpacaEval with OSS models

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 92.1%
  • Jupyter Notebook 6.3%
  • Other 1.6%