A unified framework for building agent-based models with Large Language Model integration
Project description
LAMB: LLM Agent Model Base
A unified framework for building agent-based models with Large Language Model integration, supporting multiple simulation paradigms and behavioral engines.
Note: This is a work-in-progress project by the OASIS-Fudan Complex System AI Social Scientist Team. Documentation and features are being actively developed.
Installation
pip install lamb-abm
Optional Dependencies
For LLM integration:
pip install lamb-abm[llm]
For full functionality including visualization:
pip install lamb-abm[all]
Quick Start
from lamb import ResearchAPI, SimulationConfig
# Create a simple grid simulation
api = ResearchAPI()
api.create_simulation(
paradigm="grid",
num_agents=100,
engine_type="rule",
max_steps=1000
)
# Run simulation
results = api.run_simulation()
print(f"Simulation completed with {len(results)} steps")
Key Features
- Multi-Paradigm Support: Grid, Physics, and Network simulation paradigms
- LLM Integration: Seamless Large Language Model agent behavior
- Composition Architecture: Modular design for easy extension
- High Performance: Optimized for 10,000+ agents
- Research Ready: Built-in metrics, visualization, and analysis tools
- Academic Focus: Designed for social science and complexity research
Core Concepts
Paradigms
- Grid: Discrete space models (Sugarscape, Schelling)
- Physics: Continuous space models (Boids, Social Force)
- Network: Graph-based models (SIR, Opinion Dynamics)
Engines
- Rule Engine: Traditional rule-based behavior
- LLM Engine: Large Language Model decision making
- Hybrid Engine: Combines multiple approaches
Composition Pattern
LAMB uses a composition-based architecture where simulations are built by combining independent components (Environment, Agents, Engine, Executor) rather than inheritance hierarchies.
Basic Usage
Beginner: Simple Grid Simulation
from lamb import ResearchAPI
api = ResearchAPI()
api.create_simulation(
paradigm="grid",
num_agents=50,
engine_type="rule",
max_steps=500
)
results = api.run_simulation()
Intermediate: LLM-Powered Agents
from lamb import ResearchAPI, SimulationConfig
config = SimulationConfig(
paradigm="grid",
num_agents=20,
engine_type="llm",
llm_config={
"model": "gpt-3.5-turbo",
"temperature": 0.7,
"max_tokens": 150
}
)
api = ResearchAPI()
api.create_simulation(config=config)
results = api.run_simulation()
Advanced: Custom Model
from lamb import ResearchAPI, GridAgent, GridEnvironment
from lamb.engines import RuleEngine
class CustomAgent(GridAgent):
def decide(self, observation, engine):
# Custom decision logic
return Action(agent_id=self.agent_id, action_type="move")
# Build custom simulation
environment = GridEnvironment(dimensions=(100, 100))
agents = [CustomAgent(i, (i%10, i//10)) for i in range(100)]
engine = RuleEngine()
simulation = Simulation(environment, agents, engine)
results = simulation.run(max_steps=1000)
Documentation
Documentation is currently being developed. For now, please refer to the examples in the examples/ directory and the inline code documentation.
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- OASIS-Fudan Complex System AI Social Scientist Team
- The agent-based modeling community
- OpenAI for LLM API access
- Contributors and users
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lamb_abm-0.1.0.tar.gz.
File metadata
- Download URL: lamb_abm-0.1.0.tar.gz
- Upload date:
- Size: 152.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a860a7bd061f3a80d57b9e52712f8da18d16943b063a5700ac837fbd8bcc9d20
|
|
| MD5 |
654006d523235cc255fb7b5837c12378
|
|
| BLAKE2b-256 |
814751fdcc00638189da29fea47c121f0f4178344d1e1747e62405cda06a3151
|
File details
Details for the file lamb_abm-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lamb_abm-0.1.0-py3-none-any.whl
- Upload date:
- Size: 141.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe349a1a797312549419557e4c6a201a64f1ee8a3b65f1727fcabee65890985f
|
|
| MD5 |
62631114c36a1a3d1b780b93cc14a255
|
|
| BLAKE2b-256 |
c2839a94092f8f1811efdc4497298208fc245220c6f1b46b4629197ed42e1706
|