GPTSwarm
๐ The First Self-Improving Agentic Solution
Install / Use
/learn @metauto-ai/GPTSwarmREADME
๐ 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.
About GPTSwarm
<img src="assets/gpt_swarm.png" alt="Framework" width="799">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 |
Visualizations of the graphs
<img src="assets/swarm_vis.png" alt="Edge optimization" width="800">News
-
๐ [10/12] Respect ๐ OpenAI's Swarm, but ๐ GPTSwarm is the better option if consider the ๐Swarm Intelligence๐.
-
๐ฅ [08/07] Mingchen attended an invited seminar with Shanghai AI Lab.
-
๐ฅ [07/25] Louis and Francesco gave the oral presentation in ICML 2024.
-
๐ฅ [07/17] Mingchen introduced GPTSwarm to Meta.
-
๐ฅ [07/05] Mingchen gave an invited talk to WAIC.
-
๐ฅ [06/21] Mingchen gave an invited talk to IA-CAS.
-
๐ฅ [06/20] Dmitrii gave an invited talk to Sberbank.
-
๐ฅ [06/03] SDAIA invited GPTSwarm team (Wenyi, Francesco, Dmitrii) for a 5 hour seminar.
-
๐ฅ [06/02] GPTSwarm has been selected as Oral Presentation (top 1.5%, 144 in 9,473) by ICML2024! Congratulation!
-
๐ฅ [05/01] GPTSwarm has been accepted by ICML2024.
-
๐ฅ [04/18] Mingchen gave the invited talk to ByteDance.
-
๐ฅ [03/20] Mingchen gave the invited talk to HUAWEI.
-
๐ฅ [03/13] MITTR China Exclusive Interview with Mingchen.
-
๐ฅ [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).
<img src="assets/edge_opt.gif" alt="Edge optimization" width="300">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
BING_API_KEY="" # for Bing Web Search
GOOGLE_API_KEY="" # for Google Web Search
SEARCHAPI_API_KEY="" # for SearchAPI Web Search
Selecting the Search Engine
The system will automatically select the appropriate search engine based on the following priority:
- Bing API: If
BING_API_KEYis provided - Search API: If
SEARCHAPI_API_KEYis provided - Google API: If
GOOGLE_API_KEYis provided
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: .
See how to create a custom Agent and run a Swarm with it here: .
Here is a Youtube video on how to run the demo notebooks:
<img src="assets/youtube_preview.png" width="75%">
๐ฅ๐ฅ๐ฅ See our experiments for more advanced use of our framework.
Class diagram
<img src="assets/class_diagram.png" alt="Edge optimization" width="700">Example of the Swarm
<img src="assets/swarm_v3.png" alt="Edge optimization" width="500">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.
Contributors
<a href="https://github.com/metauto-ai/gptswarm/graphs/contributors"> <img src="https://contrib.rocks/image?repo=metauto-ai/gptswarm&max=200" /> </a>- Mingchen Zhuge (PhD Student@KAUST; Project Initiator)
- Wenyi Wang (PhD Student @ KAUST; Initial Participant)
- Dmitrii Khizbullin (Research Engineer Lead @ KAUST; Project Engineer Lead)
- Louis Kirsch (PhD Student @ IDSIA)
- Francesco Faccio (PostDoc@IDSIA; Visiting Researcher@KAUST)
- Jรผrgen Schmidhuber (Director @ KAUST AI Initiative; Scientific Director @ IDSIA)
- William FH (Engineering @ LangChain)
- Lukas Vierling (BS Student @ RWTH & HKUST)
- Sandro Hanea (Senior SDE @ Microsoft)
Please read our developer document if you are interested in contributing.
Citation
Please cite our paper if you find the library useful or interesting.
@inproceedings{zhugegptswarm,
title={GPTSwarm: Language Agents as Optimizable Graphs},
author={Zhuge, Mingchen and Wang, Wenyi and Kirsch, Louis and Faccio, Francesco and Khizbullin, Dmitrii and Schmidhuber, J{\"u}rgen},
booktitle={Forty-first International Conference on Machine Learning}
}
Related Skills
claude-opus-4-5-migration
83.9kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
model-usage
339.5kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
mcp-for-beginners
15.7kThis open-source curriculum introduces the fundamentals of Model Context Protocol (MCP) through real-world, cross-language examples in .NET, Java, TypeScript, JavaScript, Rust and Python. Designed for developers, it focuses on practical techniques for building modular, scalable, and secure AI workflows from session setup to service orchestration.
TrendRadar
49.9kโญAI-driven public opinion & trend monitor with multi-platform aggregation, RSS, and smart alerts.๐ฏ ๅๅซไฟกๆฏ่ฟ่ฝฝ๏ผไฝ ็ AI ่ๆ ็ๆงๅฉๆไธ็ญ็น็ญ้ๅทฅๅ ท๏ผ่ๅๅคๅนณๅฐ็ญ็น + RSS ่ฎข้ ๏ผๆฏๆๅ ณ้ฎ่ฏ็ฒพๅ็ญ้ใAI ๆบ่ฝ็ญ้ๆฐ้ป + AI ็ฟป่ฏ + AI ๅๆ็ฎๆฅ็ดๆจๆๆบ๏ผไนๆฏๆๆฅๅ ฅ MCP ๆถๆ๏ผ่ต่ฝ AI ่ช็ถ่ฏญ่จๅฏน่ฏๅๆใๆ ๆๆดๅฏไธ่ถๅฟ้ขๆต็ญใๆฏๆ Docker ๏ผๆฐๆฎๆฌๅฐ/ไบ็ซฏ่ชๆใ้ๆๅพฎไฟก/้ฃไนฆ/้้/Telegram/้ฎไปถ/ntfy/bark/slack ็ญๆธ ้ๆบ่ฝๆจ้ใ
