Skip to main content

LLM based Multi-Agent methods

Welcome to the LLM based Multi-Agent repository! This repository provides a lean implementation of cutting-edge techniques and methods for leveraging multi-agent architectures with Large Language Models (LLMs) for various tasks. This includes methods developed by Agnostiq Inc. as well as other state-of-the-art methods. The repository is designed to be modular and easy to use, allowing for quick experimentation and please use it with caution for production purposes.

Installation

pip install -U multi-agent-llm

Quick example

import os; os.environ['OPENAI_API_KEY'] = "your_openai_api_key"

from multi_agent_llm import OpenAILLM, AGOT
from pydantic import BaseModel, Field

llm = OpenAILLM(model_name="gpt-4o-mini", temperature=0.3)
# Currently we only have wrapper for OpenAI, but it can be easily extended to other LLMs

# Define the answer schema
class QueryAnswer(BaseModel):
    explanation: str = Field(description="Explanation of the answer.")
    answer: str = Field(description="Final multiple-choice answer.")
    answer_label: str = Field(description="Label of the answer. Either A, B, C, or D.")

# Initialize AIOT with the LLM and run a sample query
agot = AGOT(
    llm=llm,
    max_depth=1,
    max_num_layers=3,
    max_new_tasks=3,
    max_concurrent_tasks=10,
)

question = """
Observations of a quasar across the electromagnetic spectrum are being carried out.
Focusing on the near infrared and optical spectrum, there is a peak at a wavelength of about 790 nm,
and at shorter wavelengths < 790 nm the flux drops significantly.

If we lived in a universe defined by a Lambda-CDM model such that the current Hubble constant is 70 km / s / Mpc,
the matter density parameter is 0.3, the dark energy density parameter is 0.7, and the universe is flat,
what can be assumed about the value of the comoving distance (for scale factor a=1) of this quasar from
the Earth?

A. 6 Gpc
B. 7 Gpc
C. 8 Gpc
D. 9 Gpc
"""

response = await agot.run_async(question, schema=QueryAnswer)

answer = response.final_answer

print(f"ANSWER: {answer.answer_label} - {answer.answer}\n")
print(f"EXPLANATION: {answer.explanation}")
ANSWER: C - 8 Gpc

EXPLANATION: The analysis of the quasar's distance was based on comoving distance calculations employing the Lambda-CDM model parameters. Given the quasar's peak emission wavelength at 790 nm and estimated redshift effects from existing literature, the comoving distance is derived using integration over the redshift, leading to a calculated distance consistent with values observed in other quasars. Previous studies have established that quasars with similar characteristics typically lie at distances ranging from 6 to 9 Gpc. The comprehensive review of analyses culminated in a well-supported final distance assessment placing the quasar at approximately 8 Gpc.

Implemented Methods

Method Description
AIoT Autonomous Iteration of Thought (AIoT) dynamically adapts its reasoning paths based on the evolving state of the conversation without generating alternate explorative thoughts that are ultimately discarded. Quick Example
GIoT Guided Iteration of Thought (GIoT) forces the LLM to continue iterating for a predefined number of steps, ensuring a thorough exploration of reasoning paths. Quick Example
AGoT Adaptive Graph of Thoughts (AGoT) dynamically constructs a directed acyclic graph (DAG) using layer-wise strategies and recursive self-application to decompose conceptual complexity. Quick Example

This repository also contains the results for the paper Iteration of Thought and Adaptive Graph of Thoughts. You can find the relevant experimental setups, datasets, and results. The folder contains results from various tasks. Feel free to explore these folders to reproduce the experiments or to get a deeper understanding of how the AIOT, GIOT, and AGoT frameworks work in practice.

Metadata

Release files for multi-agent-llm 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for multi-agent-llm 0.1.3
File Size Uploaded Provenance
multi_agent_llm-0.1.3.tar.gz 24.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for multi-agent-llm 0.1.3
File Interpreter ABI Platform
multi_agent_llm-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 47.6 kB

Release files / multi_agent_llm-0.1.3.tar.gz

Download URL multi_agent_llm-0.1.3.tar.gz
Size 24.3 kB
Tags Source
SHA-256 checksum
How to use checksums
635fd3d177e001d5b833c2b1ce118a7abb1aaa272f3b6900279ec6a540120fa8
BLAKE2b-256 checksum
How to use checksums
5bd3296b09c779b95f2e9f11ab0b7fec15845a4cd57025535c81fefee1a23f28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.15

Release files / multi_agent_llm-0.1.3-py3-none-any.whl

Download URL multi_agent_llm-0.1.3-py3-none-any.whl
Size 23.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a7ef9a1b7b37ffd395404a6f41969be9f9fc060cf629a272f8be1242da26c57
BLAKE2b-256 checksum
How to use checksums
378277faa2cb7236c5b814c4468ae0caf441c70a6c956248a6316b0fa1628033
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.15

Security for multi-agent-llm 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page