New - Easy to Learn - AI Agents: Smolagents (by HuggingFace)
6.1k views5026 WordsCopy TextShare
Discover AI
HuggingFace surprise the AI community with a new, simple and easy-to-learn new AI Agent framework: S...
Video Transcript:
hello Community 2025 and you see finally finally I want to implement some AI atantic system I want to work with agents much more so there's some brand new development but more about this in two minutes time at first I want to show you there are free courses that you can take you know here for example AI agentic design patterns with autogen with Microsoft enroll for free remember Auto Chan here from September of 2023 where we had for the first time this agent idea customization multi-agent conversation here in a very simple form or we have discourse here if you want to go with Amazon badrock here on AWS so as a gantic workflow or maybe you prefer to focus your more on the agent memory functionality here beautiful course here or if you want to go here with multii agent system with a particular implementation by a startup company why not join here a free course and get familiar with see here 2 hours 42 minutes you will learn a lot of but all of this are rather specific talking about specific you even have from Nvidia building here rag agents now you might say R agent still in 2025 well yeah this is an Nvidia course but you know what it is free for a limited time only but currently it is free and you'll learn here about everything about here the age and the tools necessary for the Nvidia Hardware environment and the course outline if you're interested your Lang chain gr your Lang surf dialogue embedding semantic similarity Guard railing implementing your Factor stores what interesting you can pay for those isn't this great but now let's come to the brand new topic and there is a brand new idea because imagine we would have a company like hug andace huging face you know 400,000 500,000 AI models here online for you open source and you know whenever we choose a model like here Al llama 370b instruct it is so easy to deploy but just we click here INF ference API and here let's go with python or JavaScript I go with python for the hugging face Hub you just copy this code and this is it you can use it on your system you just need here an API Key by hugging face this is free of charge no credit card nothing you just put it here and you can use here for example here the Lama 3. 37 be instruct isn't that great or you go with deploy here for inference Endo if you want to have the inference deployment here for your production ready you Noti this looks like here we have our q1 2. 5 Coda I went with and then the hardware configuration you can choose from AWS you can go either to Microsoft or you go with the Google platform whatever you like let's go here you have American yeah let's say with an America and you see here all everything is ready for you to be implemented and you pay for I don't know 48 gab here of fre Ram you pay close to $2 per hour and if you not go up to 100 you pay five bucks an hour interestingly in Ireland here you can go up to 640 gab here but then it's really expensive 32 bucks an hour but if you need this if you need 640 GB of free Ram 8 a100 gpus you see it is all completely implemented here in hugging face environment and there's nothing complicated anymore so imagine this company would now say you know what we look now for one and a half year at the different agents that are using the core llms and now we decide we want to provide for the community also our own agent a very simple library to build agents and they decided to publish this just two days ago and really December 21st 2024 so brand new thing they call it small agents great you know what they have now the beautiful strategic position they know all the mistakes that were done maybe by all the other implementation because if you start with a particular set of implementing rules you have to be compatible if you go next month next month next month but if you start brand new like yesterday you you know exactly what it was working where are the problems and how you do here an optimization right from the start and this is the beauty here by this implementation hugging phase I will show you the GitHub it is an Apache 2.
0 it is open source you can use it immediately so if you want to learn 2025 now and you want to say I want to implement now operational agent and you say is there a simple library that is on the latest level of technology in the implementation and where I have examples and a beautiful explanation I think you should definitely have a look at small agents is it fair to all the other implementations where you have seen here so many beautiful courses and everything you know this is the latest Ami technology implemented here knowing all the problems and I will show you here now the technology because especially if you're working here on a scientific domain this will have significant advantages for you let's just jump right into it so we are here at day one of those small agents so therefore this is really the very beginning but there are some beautiful documentation there's some beautiful examples so yes let's have a look together I just want to give you here in 30 seconds why I like it because we have a rather compressive guide that is available if you want to learn you about the small agent schema for building running and and this is the nice part customizing here your intelligent agent in a real simple way this here you can go with a minimal agent configuration or you can manage multi-agent system in a way that is really exceptional of course you can create custom tools for all your agents you can have a task hierarchy you can have specialized agent and I want to show you this because if you have more complex task this is really nice for some particular reasons and yeah you have visualization interactive communication because yeah it's a Radio based interface available for you right at the start you have a real precise task guidance because there is a special um system prompt to two integration I want to show you but there is something nice you can have here an agent adaptability regarding the tools that you will choose you can build a hierarchical multi-i just system right out of the start you can specialize for all the different subtask and whatever optimize for performance and research usage and you can create and integrate custom tools easily and especially if you like coding and or you have an a scientific application and you have custom tools you need custom tools this is so easy to do this and I want to show this to you we have gr showed you this yeah you visualize here the agent reasoning the execution and the memory retention enabling here a beautiful intuitive debugging if you remember your Lang chain at the very beginning there was a little bit of a trouble but this is now all implemented right out of the start and if you do some specialization maybe not in this video but there is something like a managed agent object that I will show you and this encapsulate here to build agent with specific group rules and specific tools there's a high degree of specialization also if you want to have here with memory and if you remember my last two three videos where I showed you there we were working with some memory optimization yes exactly this is now the right tool for this so let's start here with an introduction and here we go and you know hugging face is so nice they thought hey what our agents you know come on let's start from the beginning and they say hey our agents our small agents are are multi-step intelligence so they have an llm at the core agents so it's not just rule-based agents and they are designed to perform task through the react framework and you notice this is the reasoning and acting framework step by step so each step consists of a sort by our llm followed by a specific tool call by our llm and then the execution with intermediate observations feeding into the action now they Define here if you want two main classes I want to introduce you but first we have the multi-step agent the base class and then we have the managed agent for multi-agent system but I saying let's stay with the base class as a first start and we have multiple models that we can have here now and they start with three so we can use hugging phase inference API that I just showed you at the beginning of this video for an easy integration everything is on the hugging face platform you don't have to do anything everything is done unloaded automatically for you this is just beautiful if you are going with the Transformer idea you remember the old transformer. agent this will now this is now depreciated now we go here with this form of small agents so you can use the Transformer Library locally and if you go with light llm more than 100 miles are already supported with light llm models so user can also in addition Define custom models to fit specific needs in a very simple procedure and this is why I would say hey all this other agent implementation one and a half year ago a year ago half a year ago you know they were only going another step another step better more performance easier and now I know it is kind of unfair to show you this but this is the the reason why I have this Channel I want to show you the very latest technology and this is now available for you so I kind of feel sorry to the other models but hey if you want to go with the latest with the most and I will show you how you can optimize this for your custom models I think and it's so easy so why not show you this here it differs from the traditional agent based system you know the other systems I just showed you it has a better flexibility a better multi-agent cooporation better modularity we have an enhanced safety feature interactivity always is there but let's start now here with the multi-step agent with the base class and more or less if you start I would say you have to focus on two agents the code agents and the tool calling agents and you know what just between you and me the beauty the real beauty is here in the code agent and then we have our beautiful tool calling agent connect to the internet connector in the database everything where we need a Jason schema but you know we don't have Jason at all in a code agent and this is great so let's have a look at this officially it follows here the reasoning and acting framework so the agent iteratively sys acts Now by generating a python code it observes the result and refines its strategy until the task is complete and there are a lot of parameters we can optimize I will show you this in a minute but here is the simplest form this is our class here of our code agent and we have now tools the mod the system prompt the specific grammar additional authorized Imports planning interval and some safety features let's have a look at this the tools tell us here from the small agent tools it's a list of tools available to our agent default I told you this is hugging face so whatever model you want that is on hugging face I think close to 500,000 models so I'm sure you find one mall that you like willower that agent nothing conversation nothing whatever it is right there for you system prompt the system prompt is the secret Powerhouse here because you can customizable initial prompt structures and that provide you the agent with the context the rules and the instructions we'll talk about this in a minute then we have he additional authorized Imports and this is what I like here because a list of additional python models that the agent is permitted to import in it's generating the code sequences and yes yes you get it this is it yes this is if you are working here with any other python library in science imagine you just say import yeah grammar set of rules for constraining the code generation properly formated output everything yeah this is so nice but look at this code agent so what it does this small agent here generates and execute python code Snippets dynamically and this now enables and this is kind of the beauty here the integration with the Python's extensive libraries I don't know how many libraries in Python exist and all the python tool sets but you just can integrate it with a very simple command let's have a look at this so we say hey from small AG on here we have our code agents and we go with the hugging phas API model so we just say hey hugging face API model the model ID is exactly from hugging phase llamas repr 370b instruct and then we this is our model and then we say hey let's build the agent so we have our code agent from the small agents the tools we leave at the beginning we say well let's leave it empty the model is defined here and then we say additional authorized import python specific let's have a mathematical module that we import and then we run a task this is it you know it just say agent. run and there are multiple modes I show you but you task is now hey what is the square root of a particular number and we have here the integration and this I think you remember the llms we were talking about and I was telling you you know especially causal reasoning or mathematical reasoning it is so difficult for an llm even for I don't know 600 billion parameter model to solve a mathematical task just by large language modeling it would be so better if you simply have a calculator attached if you simply have another python Library attached to do all the calculations and now we can build this and look this is one line in total you have I don't know five line of codes and now our llm has a mathematical calculator attached you see I like this new technology it is so simple but I think it's beautiful so it uses python libraries you can import your pandas you can import your numpy you you can do an analysis of the data set whatever you know and now this is an agent and you don't have to do anything with any Jason format whatever it automates here the workflow by integrating and managing automatically python based tools I think great gorgeous and this is especially if you work in technical domains where you have already a python ecosystem where your computer simulation or maybe in python or C++ or whatever you know this offers you significant advantages because you just put in additional authorized import and you have your computer simulation or your a numerical whatever and it is just integrated into your agent if it is somehow compatible to Python and now I going say okay so if this is only python but I have to make external calls no I have to have here my function calling and this is only in adjacent format and you're right and therefore we have to Tool calling agent this particular tool calling agent from The Base Class of small agent specializes now in generating an execution Json like tool calls and you know whatever you need for an API interaction for a database query everywhere where you expect structured input and structured output so two agent that work beautifully together let's have a simple example here or a class here from the small agent a tool calling agent we have here a list of possible tools we have a particular model we have a system prompt I will show you the dynamic of the system prompt a little bit later and this is it so the agent now writes its real tool calls and it's structured Jason format instead of the classical python but I just showed you this is now more or less standard makes it easier to integrate with external system like rest apis or structured data pipelines that you know and this tool C ing agent now together in tandem with the lm's ability to choose the the appropriate tools formulates now their particular calls in a Jason format so the llm now more or less decides what tool to use and formulate now the calls in the particular required Jason format so you see you have now a dynamic that is not there if you have a chent template this is why working together is now so powerful let me show you this in a simple comparison here we have our code agent that's this in Python and here we have then the tool calling agent second one in Chas and like calls so execution style direct python structure tool invocation the use case anything computational or code based task anything you can code any newer numerical simulation anything in code runs now here in the code agent Direct ly and the tool calling agent has a structure task it's API integration that we know we have here now another add-on another bonus is the flexibility we have here the complete python ecosystem access and with the tool calling agents we have our clear predefined structures we know exactly how to connect to external system we have predefined clear communicated data formats safety you have an restricted import you have a secure PN show you maybe there are some environments you can use and for the tool calling agent classical structured Jason reducing your to risk for anything else so kind of summary this tool calling agent now complements the new code agent that is now the new diamond here because it really codes immediately by focusing on the structure Json based workflow and together those two agents demon rate now the flexibility and the extensibility of the multi-step agent class within our small agent framework so the particular new technology implementation that it directly codes opens up completely new Dynamic agent systems modularity means other specialized implementation here could be developed easily what you know as a chat agent what you know as a data pipeline agent designed for multi-step data transformation or a classical ETL task and you build a vision agent real simple and all the models are available on hugging face they have on hugging face talking about hugging face a beautiful documentation I highly recommend as the entry point small agents here you have the link tutorials then you have everything building good agents you have here the code the code examples they give you you have here coab notebook for you works great out of the box if you have in cups and problems you have an additional and introduction to agents have a look at this this is real nice and then you have a guided tour of small agents where you get all code examples that become more complicated and more complicated every step and you say the best agend systems are the simplest one so simple does not mean that it's not powerful but if you you design a simple system that is based on a new technology implementation because it really makes sense to provide your core llm in your agent with additional python ecosystems other libraries or whatever you have the system becomes although it is simple so much more powerful you have to experience this and you remember it's just day one but never mind if you want then there are some examples if you want to have a more Deep dive as I showed you real nice esq1 2.