Multi-Agent LLM : How I Use Camel And Langroid Libraries

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this short video I'll play around with camel and Lang roid so what is a multi-agent llm system first off what is an agent you can think of an agent as a rapper around the llm an agent is kind of like the agent in reinforcement learning it decides what actions to take in this case the agent's brain is the llm a multi-agent system is just an ensemble or a collection of multiple agents a popular example is metag GPT A multi-agent system that takes a oneline requirement as input and outputs user stories competitive analysis requirements data structures apis documents I've looked a bit into the open- source world for multi-agent libraries and of those I'd like to highlight two today camel and langro camel is a novel communicative agent framework in other words it's a multi-agent framework it is both a research paper and a python library before we try out the library let's get a brief overview of of what the paper is about so what is camel well technically it's the name of their repository and paper but the actual framework they introduce is called the role playing framework here's how it works you have an idea and you type it into let's say for now camel you define the roles one for the AI assistant and one for the AI user these roles will be explained later the idea is passed to the task specifier which adds or specifies a whole lot more about your task this specified detailed task is then handed off to the user and assistant the AI user is in charge of providing the necessary instructions and timelining to eventually reach the specified task objective the AI assistant is in charge of implementing these things in a way it's like a team leader and a team member only in this case it's a team of two so it is multi-agent but there are only two agents involved below is an example set of prompts they use for their AI Society case on an unrelated note why does it need to be task specific how does the prompt look for another case ah after having taken a look into the prompts folder on their repository I realized they have different sets of prompts mainly because they want to showcase other scenarios where the Inception prompting is not task oriented definitely stay tuned throughout the end of this video If you guys haven't followed me I highly recommend that you do so so you can stay up to dat with latest AI news lastly make sure you guys subscribe turn notification Bell like this video and check out previous videos because there is a lot of content that you will definitely benefit from so that thought let's get right back into the video hey great now let's try out their Library let install make sure you're using python 3.9 plus as of writing this camel doesn't have a great set of examples on their documentation page all their examples are in their their repository in this folder they have an agents subm module and prompts subm module though all of the examples for role playing primarily use Society subm module apart from the examples provided it is not immediately clear how the agents and prompts mesh with the rest of the package below are the following folders of examples they provide let's poke around one of the AI Society examples we first import our libraries color is For Colored text output we will use role playing which simulates a role playing session and abstracts Away the conversation and internals print text animated simply streams the output then we insert our open AI API key next we assign our role names to the user and assistant the model type is none with task specify means a task specifier will be used the last component is the task prompt or idea you can find more about the role playing class in the description afterwards we use colorama to print out the AI assistant and AI user system messages and task prompts the output should look something like this finally We Run The simulation this involves a bit of work on our end but this is made very easy because of the examples this is a lot of code but before we run it I'll walk through it and show that it's really not that bad we basically have a counter n that keeps counting every step of the conversation a step is the AI user instructing the assistant and the assistant responding once it reaches the turn limit chat ja turn limit then it stops that or camel task done a special token in the Inception prompting is outputed by the assistant we have two if statements to check if either party unexpectedly terminated and a bunch of print statements and formatting plus streaming besides the basic code for looping and terminating the multi-agent conversation the main method is roleplay session. step that's it below is a snapshot of a bit of the output it gets pretty long this single run cost about zero do5 bear in mind it will cost quite a bit more if the turn limit is higher and the task is more complex but that's it there are a ton more examples in their examples folder that I encourage you to check out this is the gist of a camel it's a lightweight highlevel compact library to get a multi-agent two agent specifically up and running in only 30ish lines of code there are the subm modules I mentioned earlier but the bulk of what you might use is in the examples time for Lang roid first we'll cover a little bit about Lang roid it's a lightweight intuitive library for building multi-agent llm apps with ease they also provide support for Vector stores cudr and chroma as of this writing and a set of tools for function call for reference the breakdown of langro subm modules is below at its core you're essentially setting up an agent on a particular task and executing that task here's how a barebones version of this looks check out their redmy they have some great starter examples and their documentation also has a good getting started section and check out their blog interestingly they are not made with Lang chain or llama index let's install Lang roid is much easier for brevity in this blog post I'll cover just a simple demo from their page I'll be covering the three communicating agents example a toy numbers game where when given a number n repeater agents llm simply returns and even agents llm returns N2 if n is even L says do not no the first thing we do is of course set our open AI API key langro checks for Lang roid checks for the EnV folder so that's why you see it structured this way instead next we import our relevant modules okay there's a lot going on here no answer is just a constant string placeholder it's convenient for your prompts as you will soon see for more on constants check out this folder in the repo for almost all of your uses in Lang rid you will want to import chat agent and chat agent config essentially you're defining a chat agent with a config that arguments you pass into this config are from langro language chart models. openi GPT specifically you're passing in open AI chat model and open AI GPT config then we Define our three agents notice how regardless of what role the agent has it's always defined in the same format chat aent with a specified config in this case we use the same config for all agents then we Define a task and assigning the agent to that that task pass in a system message and assign a name running this task is as simple as to have these agents communicate we assign the two tasks to be a subtask of the repeater task that's it you just learned how to set up a multi-agent system in Lang roid in just a couple of lines of Code Bear in mind that Lang roid is still a work in progress and the library is expanding as of now this lightweight framework is a great tool for setting up a multi-agent system in a few lines of code it provides more flexibility than a camel in that sense as the camel library is specific to their paper Lang roid also provides support for chatting with documents and tabular data let's wrap up in this short blog post I showcased Lang roid and camel two lightweight highlevel multi-agent libraries both of these libraries have a lot more customization under the hood and I encourage you to delve further into them happy experimenting I will leave all these links in the description below so that you can easily access them it's a great read and it'll give you a lot more understanding as to how they basically accomplish this so with that thought I genuinely hope you found it informative and valuable if you did please give it a thumbs up and consider subscribing for more content like this don't forget to click the notification Bell so you never miss an update from us if you have any questions or thoughts drop them in the comments below I always love hearing from you until next time stay stay curious and keep learning
Info
Channel: Gao Dalie (高達烈)
Views: 2,054
Rating: undefined out of 5
Keywords: LLM, AI, langchain, Openai, autogen
Id: 5LhvT1TZig0
Channel Id: undefined
Length: 9min 31sec (571 seconds)
Published: Thu Nov 02 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.