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:
- Install the LlamaPack.
- 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
Built Distribution
File details
Details for the file llama_index_packs_mixture_of_agents-0.3.0.tar.gz
.
File metadata
- Download URL: llama_index_packs_mixture_of_agents-0.3.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.10 Darwin/22.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f87d731e09cf41114b5ac64ee5bffe04123796b4bda0a4a3e83ee553739f38c6 |
|
MD5 | ed725ec3a3120d71a22b794af8ad627f |
|
BLAKE2b-256 | a84fb4921b52deb89eabf15e7b4f131019fd0f195c7afae00968c23c2ff516c7 |
File details
Details for the file llama_index_packs_mixture_of_agents-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: llama_index_packs_mixture_of_agents-0.3.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.10 Darwin/22.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0a44de37ddbf7873e4cbcef5cba00f3becc90e42f5d9c0b41a09b52e5e1620f |
|
MD5 | 3029da8b0da2dcf76a781ac05e373ae1 |
|
BLAKE2b-256 | 27b0325924ee70c8efb7bd491cf58ba667e5f693207423490f22ea9cf646b96a |