GithubHelp home page GithubHelp logo

metauto-ai / gptswarm Goto Github PK

View Code? Open in Web Editor NEW
366.0 6.0 18.0 19.27 MB

🐝 GPTSwarm: LLM agents as (Optimizable) Graphs

Home Page: https://gptswarm.org

License: MIT License

Jupyter Notebook 4.59% Python 95.41%
agent ai gpt python reinforcement-learning self-improvement swarm-intelligence multi-agent society-of-mind

gptswarm's Introduction

Page arXiv License Issues Twitter Follow Wechat Coverage Status

GPTSwarm

🐝 GPTSwarm is a graph-based framework for LLM-based agents, providing two high-level features:

  • It lets you build LLM-based agents from graphs.
  • It enables the customized and automatic self-organization of agent swarms with self-improvement capabilities.

News

  • πŸ”₯ [05/01] GPTSwarm has been accepted by ICML2024.

  • πŸ”₯ [03/01] GPTSwarm can be installed via pip now: pip install gptswarm

  • πŸ”₯ [02/27] Our academic paper: Language Agents as Optimizable Graphs is released.

Edge optimization example

Here is the edge optimization process that updates edge probabilities toward improvement of the benchmark score. Notice that within an agent, the edges are fixed, whereas the inter-agent connections are getting optimized towards either edge pruning (value 0, blue) or creation (value 1, red).

Edge optimization

About GPTSwarm

Framework

At a granular level, GPTSwarm is a library that includes the following components:

Module Description
swarm.environment Domain-specific operations, agents, tools, and tasks
swarm.graph Graph-related functions for creating and executing agent graphs and swarm composite graphs
swarm.llm Interface for selecting LLM backends and calculating their operational costs
swarm.memory Index-based memory
swarm.optimizer Optimization algorithms designed to enhance agent performance and overall swarm efficiency

Quickstart

Clone the repo

git clone https://github.com/metauto-ai/GPTSwarm.git
cd GPTSwarm/

Install packages

conda create -n swarm python=3.10
conda activate swarm
pip install poetry
poetry install

You should add API keys in .env.template and change its name to .env

OPENAI_API_KEY="" # for OpenAI LLM backend
SEARCHAPI_API_KEY="" # for Web Search

Getting started with GPTSwarm is easy. Quickly run a predefined swarm

from swarm.graph.swarm import Swarm

swarm = Swarm(["IO", "IO", "IO"], "gaia")
task = "What is the capital of Jordan?"
inputs = {"task": task}
answer = await swarm.arun(inputs)

or make use of tools, such as the file analyzer

from swarm.graph.swarm import Swarm
swarm = Swarm(["IO", "TOT"], "gaia")
task = "Tell me more about this image and summarize it in 3 sentences."
files = ["./datasets/demos/js.png"]
inputs = {"task": task, "files": files}
danswer = swarm.run(inputs)

Check out the minimal Swarm example in Colab here: Open In Colab.

See how to create a custom Agent and run a Swarm with it here: Open In Colab.

Here is a Youtube video on how to run the demo notebooks:

πŸ”₯πŸ”₯πŸ”₯ See our experiments for more advanced use of our framework.

Class diagram

Edge optimization

Example of the Swarm

Edge optimization

More Visualizations

Edge optimization

Running with a local LLM

We support local LM inference via LM Studio. Download their desktop app for Mac or Windows, choose a model from the Huggingface repository and start the server. Use model_name='lmstudio' in GPTSwarm code to run with the local LLM.

Edge optimization

Contributors

Please read our developer document if you are interested in contributing.

Citation

Please cite our paper if you find the library useful or interesting.

@article{zhuge2024language,
  title={Language Agents as Optimizable Graphs},
  author={Zhuge, Mingchen and Wang, Wenyi and Kirsch, Louis and Faccio, Francesco and Khizbullin, Dmitrii and Schmidhuber, Jurgen},
  journal={arXiv preprint arXiv:2402.16823},
  year={2024}
}

gptswarm's People

Contributors

hinthornw avatar lukasvierling avatar mczhuge avatar obs01ete avatar wenyi-ai-wang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gptswarm's Issues

Retry Error When running the example

2024-05-01 17:00:25.721 | ERROR | swarm.graph.node:execute:141 - Node DirectAnswer failed to execute due to: RetryError: RetryError[<Future at 0x314e4fcd0 state=finished raised OpenAIError>]
2024-05-01 17:03:04.397 | ERROR | swarm.graph.node:execute:141 - Node DirectAnswer failed to execute due to: RetryError: RetryError[<Future at 0x314e4ff40 state=finished raised OpenAIError>]
2024-05-01 17:07:03.721 | ERROR | swarm.graph.node:execute:141 - Node DirectAnswer failed to execute due to: RetryError: RetryError[<Future at 0x314e84100 state=finished raised OpenAIError>]


Showing the above error when running the examples, the local openai connection is okay.

Issue with Asynchronous Multi-Agent Commands using LMStudio API Causing Incorrect Output Assignment

Hi,

Thanks for this useful framework!

There is an issue while running multi-agent commands that require asynchronous use of LMStudio API. For instance, running PYTHONPATH=. python experiments/run_mmlu.py --num-truthful-agents=3 --mode=OptimizedSwarm, the outputs of LMStudio seem to be not assigned to the relevant question but to random input questions.

I have not tested this with Open AI API to see if this is specifically an incompatibility issue of LMStudio.

My current temporary solution is not to use the asynchronous implementation but this is annoyingly very slow. Have you encountered this? Is there a way to still use your asynchronous implementation and not experience this issue?

Thanks so much!

[BUG] List instead of str in FinalDecision

    output: Foo Bar Asy
2024-02-27 15:46:46.445 | ERROR    | swarm.graph.node:execute:141 - Node FinalDecision failed to execute due to: AttributeError: 'list' object has no attribute 'strip'
2024-02-27 15:46:46.446 | INFO     | swarm.graph.node:log:160 - Memory Records for ID 3BUm:
    operation: GenerateQuery
    files: ['datasets/demos/agi.txt']
    subtask: # Information Gathering for Question Resolution

Double check the initial release

@Obs01ete @Wenyi-AI-Wang Hi, Dmitrii and Wenyi. Thanks for your effort!

These are the remain work for us.

  • Please help with the dataset upload (git-lfs)
  • Check the GitHub setting of project (automated test)
  • Upload the ArXiv link and right format of paper citation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.