Skip to main content

llama-index packs mixture_of_agents paper implementation

Project description

Mixture-Of-Agents Pack

Implementation Of Mixture-Of-Agents paper from TogetherAI as LlamaPack.

Disclaimer: While the paper named the method "Mixture of Agents", agents appear to refer to LLMs themselves, not actual agentic behaviour

Approach

The capabilities of LLMs have advanced significantly, and there is now a growing number of these models available. To maximize their potential, we need to harness the collective expertise of multiple LLMs. This is where the Mixture-of-Agents (MoA) approach comes in.

The MoA approach is a layered architecture where each layer consists of multiple LLM agents. These agents collaborate by taking the outputs of other agents in the previous layer as auxiliary information to generate their responses. This collaboration allows for the refinement and enhancement of responses, as agents build upon each other's strengths. The process can be categorized into two roles: Proposers(base LLM), who generate diverse context and perspectives, and Aggregators(reference LLMs), who synthesize these proposals into a single, high-quality output. By introducing additional aggregators and iteratively refining the responses, the MoA approach aims to maximize the collaborative potential of multiple LLMs, leading to superior outcomes.

CLI Usage

You can download llamapacks directly using llamaindex-cli, which comes installed with the llama-index python package:

llamaindex-cli download-llamapack MixtureOfAgentsPack --download-dir ./mixture_of_agents_pack

You can then inspect the files at ./mixture_of_agents_pack and use them as a template for your own project.

Code Usage

You can use LlamaPack in the following ways:

  1. Install the LlamaPack.
  2. Download the LlamaPack.

1. Install the LlamaPack:

pip install llama-index-packs-mixture-of-agents

2. Download LlamaPack:

You can download the pack to a the ./mixture_of_agents_pack directory:

from llama_index.core.llama_pack import download_llama_pack

# download and install dependencies
MixtureOfAgentsPack = download_llama_pack(
    "MixtureOfAgentsPack", "./mixture_of_agents_pack"
)

Once installed or downloaded, you can use the LlamaPack as follows:

# Necessary for async operations in Jupyter notebooks
import nest_asyncio

nest_asyncio.apply()

from llama_index.llms.openai import OpenAI
from llama_index.llms.mistralai import MistralAI

# Add OPENAI_API_KEY and MISTRAL_API_KEY to your env variable

mixture_of_agents_pack = MixtureOfAgentsPack(
    llm=OpenAI(model="gpt-4"),  # Aggregator
    reference_llms=[
        OpenAI(model="gpt-3.5-turbo"),
        MistralAI(model="mistral-medium"),
    ],  # Proposers
    num_layers=3,
    temperature=0.1,
    timeout=200,  # timeout for response from workflow
)

From here, you can use the pack, or inspect and modify the pack in ./mixture_of_agents_pack.

The run() function is a light wrapper around the proposed approach in the paper.

response = mixture_of_agents_pack.run("What is LlamaIndex?")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_packs_mixture_of_agents-0.4.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file llama_index_packs_mixture_of_agents-0.4.1.tar.gz.

File metadata

File hashes

Hashes for llama_index_packs_mixture_of_agents-0.4.1.tar.gz
Algorithm Hash digest
SHA256 96cbd24689ca12f35c8bf4e81f475a7e80dcbc4f8edc370c0f2751562c932123
MD5 967537851bf3eb9c1ce2b4d85dacf694
BLAKE2b-256 75671cd65fb3a1455856c43a165b84ce1c80aadfb8541718d3bb1ccb3f1d40ef

See more details on using hashes here.

File details

Details for the file llama_index_packs_mixture_of_agents-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_packs_mixture_of_agents-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4b7412f9b5557f2218d538e9d9d00c55694653575181a527288baafddf2c146e
MD5 4dbc302e08dc29d8ea26ac1dd2759dfa
BLAKE2b-256 a87316cddeb54d1e52ff110fbe7cdb09fc266d9cf8e313a6c8ec627afd558bd9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page