SuperAPIAI Directory

moa

github.com · AI developer platforms

Leverage the collective strengths of multiple LLMs to improve accuracy.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsLinux · API

About this tool

Overview

Mixture of Agents (MoA) is a novel method that leverages the collective strengths of multiple LLMs to improve performance and achieve state-of-the-art results. It adopts a layered architecture, with each layer containing multiple LLM agents. Using only open-source models, MoA achieved a score of 65.1% on AlpacaEval 2.0, significantly outperforming GPT-4 Omni's 57.5%.

Quick Start: Implement MoA in About 50 Lines of Code

To use MoA in your own application, please refer to moa.py. In this simple example, we will use 2 layers and 4 LLMs. You need to:

  1. Install the Together Python library: pip install together
  2. Get a Together API Key and export it: export TOGETHER_API_KEY=
  3. Run the python file: python moa.py

Multi-Layer MoA Example

In the previous example, we introduced how to implement MoA with 2 layers (4 LLMs answer, one LLM aggregates). However, one advantage of MoA is the ability to go through multiple layers to obtain better responses. In this example, we will introduce how to run MoA with more than 3 layers in advanced-moa.py.

Interactive CLI Demo

This interactive CLI demo showcases a simple multi-turn chatbot whose final response is aggregated from various reference models.

To run the interactive demo, follow these 3 steps:

  1. Export your API Key: export TOGETHER_API_KEY={your_key}
  2. Install dependencies: pip install -r requirements.txt
  3. Run the script: python bot.py

The CLI will prompt you to enter instructions interactively:

  • Enter your instruction at the ">>>" prompt.
  • The system will process your input using predefined reference models.
  • It will generate a response based on the aggregated output of these models.
  • You can continue the conversation by entering more instructions, and the system will maintain the context of the multi-turn interaction.

[Optional] Additional Configuration

The demo will ask you to specify certain options, but if you want to perform additional configuration, you can specify the following parameters:

  • --aggregator: The primary model used for final response generation.
  • --reference_models: A list of models to use as references.
  • --temperature: Controls the randomness of response generation.
  • --max_tokens: The maximum number of tokens in the response.
  • --rounds: The number of rounds to process the input for refinement (rounds == MoA layers - 1).
  • --num_proc: The number of processes to run in parallel to speed up execution.
  • --multi_turn: A boolean value used to toggle multi-turn interaction capability.

Evaluation

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

Run AlpacaEval 2 To run AlpacaEval 2, execute the following script: For a minimal example of MT-Bench evaluation, run: For a minimal example of FLASK evaluation, run:

Results

We achieved leading positions on both the AlpacaEval 2.0 leaderboard and MT-Bench. Notably, on AlpacaEval 2.0, using only open-source models, we achieved a 7.6% absolute improvement from 57.5% (GPT-4 Omni) to 65.1% (MoA).

FLASK provides fine-grained evaluation of models across multiple dimensions. Our MoA method significantly outperforms the original Qwen1.5-110B-Chat in harmlessness, robustness, correctness, efficiency, factuality, common sense, insightfulness, and completeness. In addition, MoA also outperforms GPT-4 Omni in correctness, factuality, insightfulness, completeness, and metacognition.

If you encounter difficulties when reproducing the results, please feel free to contact us.

Notably, this work benefited from the collaborative spirit and contributions of active organizations in the AI field. We thank Meta AI, Mistral AI, Microsoft, Alibaba Cloud, and DataBricks for developing the Llama 3, Mixtral, WizardLM 2, Qwen 1.5, and DBRX models. In addition, we thank Tatsu Labs, LMSYS, and KAIST AI for developing the AlpacaEval, MT-Bench, and FLASK evaluation benchmarks.

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

If you find this work helpful, please consider citing: Together Mixture-Of-Agents (MoA) – 65.1% on AlpacaEval with OSS models

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools