Skip to main content

An LLM Multi-Agent framework.

Project description

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.

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

multi_agent_llm-0.1.3.tar.gz (24.3 kB view details)

Uploaded Source

Built Distribution

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

multi_agent_llm-0.1.3-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file multi_agent_llm-0.1.3.tar.gz.

File metadata

  • Download URL: multi_agent_llm-0.1.3.tar.gz
  • Upload date:
  • Size: 24.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.15

File hashes

Hashes for multi_agent_llm-0.1.3.tar.gz
Algorithm Hash digest
SHA256 635fd3d177e001d5b833c2b1ce118a7abb1aaa272f3b6900279ec6a540120fa8
MD5 2a87233fcca59f55c1fbeeeff836d94c
BLAKE2b-256 5bd3296b09c779b95f2e9f11ab0b7fec15845a4cd57025535c81fefee1a23f28

See more details on using hashes here.

File details

Details for the file multi_agent_llm-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for multi_agent_llm-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4a7ef9a1b7b37ffd395404a6f41969be9f9fc060cf629a272f8be1242da26c57
MD5 b24fc068e1494ca8890bba9b6ea0b2c7
BLAKE2b-256 378277faa2cb7236c5b814c4468ae0caf441c70a6c956248a6316b0fa1628033

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