Introduction to the Lagent Project
The Lagent project provides a sophisticated multi-agent framework for creating applications that mimic the layered structures of neural networks. Drawing inspiration from PyTorch, Lagent offers a clear and intuitive way for users to focus on constructing layers and defining message exchanges between them, all within a Python environment. By utilizing this framework, developers can efficiently build multi-agent applications with ease and precision.
Installation
To set up Lagent from the source, you need to perform the following commands in your terminal:
git clone https://github.com/InternLM/lagent.git
cd lagent
pip install -e .
Core Concepts
Models as Agents
In Lagent, models are treated as agents that communicate using a structure called AgentMessage
. Each agent can be initialized with different language models and can be given specific instructions for interaction. For instance:
from lagent.agents import Agent
from lagent.schema import AgentMessage
from lagent.llms import VllmModel, INTERNLM2_META
llm = VllmModel(path='Qwen/Qwen2-7B-Instruct', meta_template=INTERNLM2_META, tp=1, top_k=1, temperature=1.0, stop_words=['