#
Have several agents collaborate in a multi-agent hierarchy 🤖🤝🤖

Authored by: Aymeric Roucher

> This tutorial is advanced. You should have notions from this other cookbook first!

In this notebook we will make a multi-agent web browser: an agentic system with several agents collaborating to solve problems using the web!

It will be a simple hierarchy, using a `ManagedAgent` object to wrap the managed web search agent:

                  +----------------+
                  | Manager agent  |
                  +----------------+
                           |
            _______________|______________
           |                              |
      Code interpreter   +--------------------------------+
           tool          |         Managed agent          |
                         |      +------------------+      |
                         |      | Web Search agent |      |
                         |      +------------------+      |
                         |         |            |         |
                         |  Web Search tool     |         |
                         |             Visit webpage tool |
                         +--------------------------------+

Let’s set up this system.

⚡️ Our agent will be powered by meta-llama/Meta-Llama-3.1-70B-Instruct using `HfApiEngine` class that uses HF’s Inference API: the Inference API allows to quickly and easily run any OS model.

Run the line below to install the required dependencies:

    !pip install markdownify duckduckgo-search "git+https://github.com/huggingface/transformers.git#egg=transformers[agents]" python-dotenv

    >>> from huggingface_hub import login
    >>> from dotenv import load_dotenv
    >>> import os

    >>> load_dotenv()

    >>> login(os.getenv("HUGGINGFACEHUB_API_TOKEN"))

    >>> model = "meta-llama/Meta-Llama-3.1-70B-Instruct"

    The token has not been saved to the git credentials helper. Pass `add_to_git_credential=True` in this function directly or `--add-to-git-credential` if using via `huggingface-cli` if you want to set the git credential as well.
    Token is valid (permission: fineGrained).
    Your token has been saved to /Users/aymeric/.cache/huggingface/token
    Login successful

###
🔍 Create a web search tool

For web browsing, we can already use our pre-existing `DuckDuckGoSearchTool` tool to provide a Google search equivalent.

But then we will also need to be able to peak into the page found by the `DuckDuckGoSearchTool`. To do so, we could import the library’s built-in `VisitWebpageTool`, but we will build it again to see how it’s done.

So let’s create our `VisitWebpageTool` tool from scratch using `markdownify`.

    from transformers import Tool
    import requests
    from markdownify import markdownify as md
    from requests.exceptions import RequestException
    import re

    class VisitWebpageTool(Tool):
        name = "visit_webpage"
        description = "Visits a webpage at the given url and returns its content as a markdown string."
        inputs = {
            "url": {
                "type": "text",
                "description": "The url of the webpage to visit.",
            }
        }
        output_type = "text"

        def forward(self, url: str) -> str:
            try:
                # Send a GET request to the URL
                response = requests.get(url)
                response.raise_for_status()  # Raise an exception for bad status codes

                # Convert the HTML content to Markdown
                markdown_content = md(response.text).strip()

                # Remove multiple line breaks
                markdown_content = re.sub(r"\n{3,}", "\n\n", markdown_content)

                return markdown_content

            except RequestException as e:
                return f"Error fetching the webpage: {str(e)}"
            except Exception as e:
                return f"An unexpected error occurred: {str(e)}"

Ok, now let’s initialize and test our tool!

    >>> visit_page_tool = VisitWebpageTool()

    >>> print(visit_page_tool("https://en.wikipedia.org/wiki/Hugging_Face"))

    Hugging Face \- Wikipedia

    [Jump to content](#bodyContent)

    Main menu

    Main menu
    move to sidebar
    hide

     Navigation

    * [Main page](/wiki/Main_Page "Visit the main page [z]")
    * [Contents](/wiki/Wikipedia:Contents "Guides to browsing Wikipedia")
    * [Current events](/wiki/Portal:Current_events "Articles related to current events")
    * [Random article](/wiki/Special:Random "Visit a randomly selected article [x]")
    * [About Wikipedia](/wiki/Wikipedia:About "Learn about Wikipedia and how it works")
    * [Contact us](//en.wikipedia.org/wiki/Wikipedia:Contact_us "How to contact Wikipedia")
    * [Donate](https://donate.wikimedia.org/wiki/Special:FundraiserRedirector?utm_source=donate&utm_medium=sidebar&utm_campaign=C13_en.wikipedia.org&uselang=en "Support us by donating to the Wikimedia Foundation")

     Contribute

    * [Help](/wiki/Help:Contents "Guidance on how to use and edit Wikipedia")
    * [Learn to edit](/wiki/Help:Introduction "Learn how to edit Wikipedia")
    * [Community portal](/wiki/Wikipedia:Community_portal "The hub for editors")
    * [Recent changes](/wiki/Special:RecentChanges "A list of recent changes to Wikipedia [r]")
    * [Upload file](/wiki/Wikipedia:File_upload_wizard "Add images or other media for use on Wikipedia")

    [![](/static/images/icons/wikipedia.png)

    ![Wikipedia](/static/images/mobile/copyright/wikipedia-wordmark-en.svg)
    ![The Free Encyclopedia](/static/images/mobile/copyright/wikipedia-tagline-en.svg)](/wiki/Main_Page)

    [Search](/wiki/Special:Search "Search Wikipedia [f]")

    Search

    Appearance

    * [Create account](/w/index.php?title=Special:CreateAccount&returnto=Hugging+Face "You are encouraged to create an account and log in; however, it is not mandatory")
    * [Log in](/w/index.php?title=Special:UserLogin&returnto=Hugging+Face "You're encouraged to log in; however, it's not mandatory. [o]")

    Personal tools

    * [Create account](/w/index.php?title=Special:CreateAccount&returnto=Hugging+Face "You are encouraged to create an account and log in; however, it is not mandatory")
    * [Log in](/w/index.php?title=Special:UserLogin&returnto=Hugging+Face "You're encouraged to log in; however, it's not mandatory. [o]")

     Pages for logged out editors [learn more](/wiki/Help:Introduction)

    * [Contributions](/wiki/Special:MyContributions "A list of edits made from this IP address [y]")
    * [Talk](/wiki/Special:MyTalk "Discussion about edits from this IP address [n]")

    Contents
    --------

    move to sidebar
    hide

    * [(Top)](#)
    * [1
    History](#History)
    * [2
    Services and technologies](#Services_and_technologies)

    Toggle Services and technologies subsection

    	+ [2\.1
    	Transformers Library](#Transformers_Library)
    	+ [2\.2
    	Hugging Face Hub](#Hugging_Face_Hub)
    	+ [2\.3
    	Other libraries](#Other_libraries)
    * [3
    See also](#See_also)
    * [4
    References](#References)

    Toggle the table of contents

    Hugging Face
    ============

    18 languages

    * [Català](https://ca.wikipedia.org/wiki/Hugging_Face "Hugging Face – Catalan")
    * [Deutsch](https://de.wikipedia.org/wiki/Hugging_Face "Hugging Face – German")
    * [Español](https://es.wikipedia.org/wiki/Hugging_Face "Hugging Face – Spanish")
    * [Euskara](https://eu.wikipedia.org/wiki/Hugging_Face "Hugging Face – Basque")
    * [فارسی](https://fa.wikipedia.org/wiki/%D9%87%D8%A7%DA%AF%DB%8C%D9%86%DA%AF_%D9%81%DB%8C%D8%B3 "هاگینگ فیس – Persian")
    * [Français](https://fr.wikipedia.org/wiki/Hugging_Face "Hugging Face – French")
    * [한국어](https://ko.wikipedia.org/wiki/%ED%97%88%EA%B9%85_%ED%8E%98%EC%9D%B4%EC%8A%A4 "허깅 페이스 – Korean")
    * [Bahasa Indonesia](https://id.wikipedia.org/wiki/Hugging_Face "Hugging Face – Indonesian")
    * [עברית](https://he.wikipedia.org/wiki/Hugging_Face "Hugging Face – Hebrew")
    * [Nederlands](https://nl.wikipedia.org/wiki/Hugging_Face "Hugging Face – Dutch")
    * [日本語](https://ja.wikipedia.org/wiki/Hugging_Face "Hugging Face – Japanese")
    * [Português](https://pt.wikipedia.org/wiki/Hugging_Face "Hugging Face – Portuguese")
    * [Runa Simi](https://qu.wikipedia.org/wiki/Hugging_Face "Hugging Face – Quechua")
    * [Русский](https://ru.wikipedia.org/wiki/Hugging_Face "Hugging Face – Russian")
    * [Suomi](https://fi.wikipedia.org/wiki/Hugging_Face "Hugging Face – Finnish")
    * [Türkçe](https://tr.wikipedia.org/wiki/Hugging_Face "Hugging Face – Turkish")
    * [Українська](https://uk.wikipedia.org/wiki/Hugging_Face "Hugging Face – Ukrainian")
    * [中文](https://zh.wikipedia.org/wiki/Hugging_Face "Hugging Face – Chinese")

    [Edit links](https://www.wikidata.org/wiki/Special:EntityPage/Q108943604#sitelinks-wikipedia "Edit interlanguage links")

    * [Article](/wiki/Hugging_Face "View the content page [c]")
    * [Talk](/wiki/Talk:Hugging_Face "Discuss improvements to the content page [t]")

    English

    * [Read](/wiki/Hugging_Face)
    * [Edit](/w/index.php?title=Hugging_Face&action=edit "Edit this page [e]")
    * [View history](/w/index.php?title=Hugging_Face&action=history "Past revisions of this page [h]")

    Tools

    Tools
    move to sidebar
    hide

     Actions

    * [Read](/wiki/Hugging_Face)
    * [Edit](/w/index.php?title=Hugging_Face&action=edit "Edit this page [e]")
    * [View history](/w/index.php?title=Hugging_Face&action=history)

     General

    * [What links here](/wiki/Special:WhatLinksHere/Hugging_Face "List of all English Wikipedia pages containing links to this page [j]")
    * [Related changes](/wiki/Special:RecentChangesLinked/Hugging_Face "Recent changes in pages linked from this page [k]")
    * [Upload file](/wiki/Wikipedia:File_Upload_Wizard "Upload files [u]")
    * [Special pages](/wiki/Special:SpecialPages "A list of all special pages [q]")
    * [Permanent link](/w/index.php?title=Hugging_Face&oldid=1238858455 "Permanent link to this revision of this page")
    * [Page information](/w/index.php?title=Hugging_Face&action=info "More information about this page")
    * [Cite this page](/w/index.php?title=Special:CiteThisPage&page=Hugging_Face&id=1238858455&wpFormIdentifier=titleform "Information on how to cite this page")
    * [Get shortened URL](/w/index.php?title=Special:UrlShortener&url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FHugging_Face)
    * [Download QR code](/w/index.php?title=Special:QrCode&url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FHugging_Face)
    * [Wikidata item](https://www.wikidata.org/wiki/Special:EntityPage/Q108943604 "Structured data on this page hosted by Wikidata [g]")

     Print/export

    * [Download as PDF](/w/index.php?title=Special:DownloadAsPdf&page=Hugging_Face&action=show-download-screen "Download this page as a PDF file")
    * [Printable version](/w/index.php?title=Hugging_Face&printable=yes "Printable version of this page [p]")

     In other projects

    * [Wikimedia Commons](https://commons.wikimedia.org/wiki/Category:Hugging_Face)

    Appearance
    move to sidebar
    hide

    From Wikipedia, the free encyclopedia

    American software company
    This article is about the company. For the emoji, see [Emoji](/wiki/Emoji "Emoji").

    |  | This article **relies excessively on [references](/wiki/Wikipedia:Verifiability "Wikipedia:Verifiability") to [primary sources](/wiki/Wikipedia:No_original_research#Primary,_secondary_and_tertiary_sources "Wikipedia:No original research")**. Please improve this article by adding [secondary or tertiary sources](/wiki/Wikipedia:No_original_research#Primary,_secondary_and_tertiary_sources "Wikipedia:No original research"). *Find sources:* ["Hugging Face"](https://www.google.com/search?as_eq=wikipedia&q=%22Hugging+Face%22) – [news](https://www.google.com/search?tbm=nws&q=%22Hugging+Face%22+-wikipedia&tbs=ar:1) **·** [newspapers](https://www.google.com/search?&q=%22Hugging+Face%22&tbs=bkt:s&tbm=bks) **·** [books](https://www.google.com/search?tbs=bks:1&q=%22Hugging+Face%22+-wikipedia) **·** [scholar](https://scholar.google.com/scholar?q=%22Hugging+Face%22) **·** [JSTOR](https://www.jstor.org/action/doBasicSearch?Query=%22Hugging+Face%22&acc=on&wc=on) *(February 2023)* *([Learn how and when to remove this message](/wiki/Help:Maintenance_template_removal "Help:Maintenance template removal"))* |
    | --- | --- |

    Hugging Face, Inc.
    |  | |
    | --- | --- |
    | Company type | [Private](/wiki/Privately_held_company "Privately held company") |
    | Industry | [Artificial intelligence](/wiki/Artificial_intelligence "Artificial intelligence"), [machine learning](/wiki/Machine_learning "Machine learning"), [software development](/wiki/Software_development "Software development") |
    | Founded | 2016; 8 years ago (2016) |
    | Headquarters | [Manhattan](/wiki/Manhattan "Manhattan"), [New York City](/wiki/New_York_City "New York City") |
    | Area served | Worldwide |
    | Key people | * Clément Delangue (CEO) * Julien Chaumond (CTO) * Thomas Wolf (CSO) |
    | Products | Models, datasets, spaces |
    | Revenue | 15,000,000 United States dollar (2022\) [Edit this on Wikidata](https://www.wikidata.org/wiki/Q108943604?uselang=en#P2139 "Edit this on Wikidata") |
    | Number of employees | 170 (2023\) [Edit this on Wikidata](https://www.wikidata.org/wiki/Q108943604?uselang=en#P1128 "Edit this on Wikidata") |
    | Website | [huggingface.co](https://huggingface.co/) |

    **Hugging Face, Inc.** is an American company incorporated under the [Delaware General Corporation Law](/wiki/Delaware_General_Corporation_Law "Delaware General Corporation Law")[\[1]](#cite_note-1) and based in [New York City](/wiki/List_of_tech_companies_in_the_New_York_metropolitan_area "List of tech companies in the New York metropolitan area") that develops [computation](/wiki/Computation "Computation") tools for building applications using [machine learning](/wiki/Machine_learning "Machine learning"). It is most notable for its [transformers](/wiki/Transformer_(machine_learning_model) "Transformer (machine learning model)") [library](/wiki/Software_libraries "Software libraries") built for [natural language processing](/wiki/Natural_language_processing "Natural language processing") applications and its platform that allows users to share machine learning models and [datasets](/wiki/Dataset_(machine_learning) "Dataset (machine learning)") and showcase their work.

    History
    -------

    \[[edit](/w/index.php?title=Hugging_Face&action=edit§ion=1 "Edit section: History")]
    The company was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf in [New York City](/wiki/New_York_City "New York City"), originally as a company that developed a [chatbot](/wiki/Chatbot "Chatbot") app targeted at teenagers.[\[2]](#cite_note-:0-2) The company was named after the "hugging face" [emoji](/wiki/Emoji "Emoji").[\[2]](#cite_note-:0-2) After [open sourcing](/wiki/Open-source_software "Open-source software") the model behind the chatbot, the company [pivoted](/wiki/Lean_startup "Lean startup") to focus on being a platform for machine learning.

    In March 2021, Hugging Face raised US$40 million in a [Series B](/wiki/Series_B "Series B") funding round.[\[3]](#cite_note-3)

    On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open [large language model](/wiki/Large_language_model "Large language model").[\[4]](#cite_note-4) In 2022, the workshop concluded with the announcement of [BLOOM](/wiki/BLOOM_(language_model) "BLOOM (language model)"), a multilingual large language model with 176 billion parameters.[\[5]](#cite_note-5)[\[6]](#cite_note-6)

    In December 2022, the company acquired Gradio, an open source library built for developing machine learning applications in Python.[\[7]](#cite_note-7)

    On May 5, 2022, the company announced its [Series C](/wiki/Series_C "Series C") funding round led by [Coatue](/wiki/Coatue_Management "Coatue Management") and [Sequoia](/wiki/Sequoia_fund "Sequoia fund").[\[8]](#cite_note-8) The company received a $2 billion valuation.

    On August 3, 2022, the company announced the Private Hub, an enterprise version of its public Hugging Face Hub that supports [SaaS](/wiki/Software_as_a_service "Software as a service") or [on\-premises](/wiki/On-premises_software "On-premises software") deployment.[\[9]](#cite_note-9)

    In February 2023, the company announced partnership with [Amazon Web Services](/wiki/Amazon_Web_Services "Amazon Web Services") (AWS) which would allow Hugging Face's products available to AWS customers to use them as the building blocks for their custom applications. The company also said the next generation of BLOOM will be run on Trainium, a proprietary [machine learning chip](/wiki/Machine_learning_hardware "Machine learning hardware") created by AWS.[\[10]](#cite_note-10)[\[11]](#cite_note-11)[\[12]](#cite_note-12)

    In August 2023, the company announced that it raised $235 million in a [Series D](/wiki/Series_D "Series D") funding, at a $4\.5 billion valuation. The funding was led by [Salesforce](/wiki/Salesforce "Salesforce"), and notable participation came from [Google](/wiki/Google "Google"), [Amazon](/wiki/Amazon_(company) "Amazon (company)"), [Nvidia](/wiki/Nvidia "Nvidia"), [AMD](/wiki/AMD "AMD"), [Intel](/wiki/Intel "Intel"), [IBM](/wiki/IBM "IBM"), and [Qualcomm](/wiki/Qualcomm "Qualcomm").[\[13]](#cite_note-13)

    In June 2024, the company announced, along with [Meta](/wiki/Meta_Platforms "Meta Platforms") and [Scaleway](/wiki/Scaleway "Scaleway"), their launch of a new AI accelerator program for European startups. This initiative aims to help startups integrate open foundation models into their products, accelerating the EU AI ecosystem. The program, based at STATION F in Paris, will run from September 2024 to February 2025\. Selected startups will receive mentoring, access to AI models and tools, and Scaleway’s computing power.[\[14]](#cite_note-14)

    Services and technologies
    -------------------------

    \[[edit](/w/index.php?title=Hugging_Face&action=edit§ion=2 "Edit section: Services and technologies")]
    ### Transformers Library

    \[[edit](/w/index.php?title=Hugging_Face&action=edit§ion=3 "Edit section: Transformers Library")]
    The Transformers library is a [Python](/wiki/Python_(programming_language) "Python (programming language)") package that contains open\-source implementations of [transformer](/wiki/Transformer_(machine_learning_model) "Transformer (machine learning model)") models for text, image, and audio tasks. It is compatible with the [PyTorch](/wiki/PyTorch "PyTorch"), [TensorFlow](/wiki/TensorFlow "TensorFlow") and [JAX](/wiki/Google_JAX "Google JAX") [deep learning](/wiki/Deep_learning "Deep learning") libraries and includes implementations of notable models like [BERT](/wiki/BERT_(language_model) "BERT (language model)") and [GPT\-2](/wiki/GPT-2 "GPT-2").[\[15]](#cite_note-15) The library was originally called "pytorch\-pretrained\-bert"[\[16]](#cite_note-16) which was then renamed to "pytorch\-transformers" and finally "transformers."

    A [javascript](/wiki/JavaScript "JavaScript") version (transformers.js[\[17]](#cite_note-17)) have also been developed, allowing to run models directly in the browser.

    ### Hugging Face Hub

    \[[edit](/w/index.php?title=Hugging_Face&action=edit§ion=4 "Edit section: Hugging Face Hub")]
    The Hugging Face Hub is a platform (centralized [web service](/wiki/Web_service "Web service")) for hosting:[\[18]](#cite_note-18)

    * [Git](/wiki/Git "Git")\-based [code repositories](/wiki/Repository_(version_control) "Repository (version control)"), including discussions and pull requests for projects.
    * models, also with Git\-based version control;
    * datasets, mainly in text, images, and audio;
    * web applications ("spaces" and "widgets"), intended for small\-scale demos of machine learning applications.

    There are numerous pre\-trained models that support common tasks in different modalities, such as:

    * [Natural Language Processing](/wiki/Natural_language_processing "Natural language processing"): text classification, named entity recognition, question answering, language modeling, summarization, translation, multiple choice, and text generation.
    * [Computer Vision](/wiki/Computer_vision "Computer vision"): image classification, object detection, and segmentation.
    * Audio: automatic speech recognition and audio classification.

    ### Other libraries

    \[[edit](/w/index.php?title=Hugging_Face&action=edit§ion=5 "Edit section: Other libraries")]
    [![](//upload.wikimedia.org/wikipedia/commons/thumb/2/29/Gradio_example.png/220px-Gradio_example.png)](/wiki/File:Gradio_example.png)

    Gradio UI Example

    In addition to Transformers and the Hugging Face Hub, the Hugging Face ecosystem contains libraries for other tasks, such as [dataset processing](/wiki/Data_processing "Data processing") ("Datasets"), model evaluation ("Evaluate"), and machine learning demos ("Gradio").[\[19]](#cite_note-19)

    See also
    --------

    \[[edit](/w/index.php?title=Hugging_Face&action=edit§ion=6 "Edit section: See also")]
    * [OpenAI](/wiki/OpenAI "OpenAI")
    * [Station F](/wiki/Station_F "Station F")

    References
    ----------

    \[[edit](/w/index.php?title=Hugging_Face&action=edit§ion=7 "Edit section: References")]

    1. **[^](#cite_ref-1)** ["Terms of Service – Hugging Face"](https://huggingface.co/terms-of-service). *huggingface.co*. Retrieved 2024\-05\-24.
    2. ^ [***a***](#cite_ref-:0_2-0) [***b***](#cite_ref-:0_2-1) ["Hugging Face wants to become your artificial BFF"](https://techcrunch.com/2017/03/09/hugging-face-wants-to-become-your-artificial-bff/). *TechCrunch*. 9 March 2017\. [Archived](https://web.archive.org/web/20220925012620/https://techcrunch.com/2017/03/09/hugging-face-wants-to-become-your-artificial-bff/) from the original on 2022\-09\-25. Retrieved 2023\-09\-17.
    3. **[^](#cite_ref-3)** ["Hugging Face raises $40 million for its natural language processing library"](https://techcrunch.com/2021/03/11/hugging-face-raises-40-million-for-its-natural-language-processing-library). 11 March 2021\. [Archived](https://web.archive.org/web/20230728113102/https://techcrunch.com/2021/03/11/hugging-face-raises-40-million-for-its-natural-language-processing-library/) from the original on 28 July 2023. Retrieved 5 August 2022.
    4. **[^](#cite_ref-4)** ["Inside BigScience, the quest to build a powerful open language model"](https://venturebeat.com/2022/01/10/inside-bigscience-the-quest-to-build-a-powerful-open-language-model/). 10 January 2022\. [Archived](https://web.archive.org/web/20220701073233/https://venturebeat.com/2022/01/10/inside-bigscience-the-quest-to-build-a-powerful-open-language-model/) from the original on 1 July 2022. Retrieved 5 August 2022.
    5. **[^](#cite_ref-5)** ["BLOOM"](https://bigscience.huggingface.co/blog/bloom). *bigscience.huggingface.co*. [Archived](https://web.archive.org/web/20221114122342/https://bigscience.huggingface.co/blog/bloom) from the original on 2022\-11\-14. Retrieved 2022\-08\-20.
    6. **[^](#cite_ref-6)** ["Inside a radical new project to democratize AI"](https://www.technologyreview.com/2022/07/12/1055817/inside-a-radical-new-project-to-democratize-ai/). *MIT Technology Review*. [Archived](https://web.archive.org/web/20221204184214/https://www.technologyreview.com/2022/07/12/1055817/inside-a-radical-new-project-to-democratize-ai/) from the original on 2022\-12\-04. Retrieved 2023\-08\-25.
    7. **[^](#cite_ref-7)** Nataraj, Poornima (2021\-12\-23\). ["Hugging Face Acquires Gradio, A Customizable UI Components Library For Python"](https://analyticsindiamag.com/hugging-face-acquires-gradio-a-customizable-ui-components-library-for-python/). *Analytics India Magazine*. Retrieved 2024\-01\-26.
    8. **[^](#cite_ref-8)** Cai, Kenrick. ["The $2 Billion Emoji: Hugging Face Wants To Be Launchpad For A Machine Learning Revolution"](https://www.forbes.com/sites/kenrickcai/2022/05/09/the-2-billion-emoji-hugging-face-wants-to-be-launchpad-for-a-machine-learning-revolution/). *Forbes*. [Archived](https://web.archive.org/web/20221103121236/https://www.forbes.com/sites/kenrickcai/2022/05/09/the-2-billion-emoji-hugging-face-wants-to-be-launchpad-for-a-machine-learning-revolution/) from the original on 2022\-11\-03. Retrieved 2022\-08\-20.
    9. **[^](#cite_ref-9)** ["Introducing the Private Hub: A New Way to Build With Machine Learning"](https://huggingface.co/blog/introducing-private-hub). *huggingface.co*. [Archived](https://web.archive.org/web/20221114122333/https://huggingface.co/blog/introducing-private-hub) from the original on 2022\-11\-14. Retrieved 2022\-08\-20.
    10. **[^](#cite_ref-10)** Bass, Dina (2023\-02\-21\). ["Amazon's Cloud Unit Partners With Startup Hugging Face as AI Deals Heat Up"](https://www.bloomberg.com/news/articles/2023-02-21/amazon-s-aws-joins-with-ai-startup-hugging-face-as-chatgpt-competition-heats-up). *[Bloomberg News](/wiki/Bloomberg_News "Bloomberg News")*. [Archived](https://web.archive.org/web/20230522030130/https://www.bloomberg.com/news/articles/2023-02-21/amazon-s-aws-joins-with-ai-startup-hugging-face-as-chatgpt-competition-heats-up) from the original on 2023\-05\-22. Retrieved 2023\-02\-22.
    11. **[^](#cite_ref-11)** Nellis, Stephen (2023\-02\-21\). ["Amazon Web Services pairs with Hugging Face to target AI developers"](https://www.reuters.com/technology/amazon-web-services-pairs-with-hugging-face-target-ai-developers-2023-02-21/). *Reuters*. [Archived](https://web.archive.org/web/20230530091325/https://www.reuters.com/technology/amazon-web-services-pairs-with-hugging-face-target-ai-developers-2023-02-21/) from the original on 2023\-05\-30. Retrieved 2023\-02\-22.
    12. **[^](#cite_ref-12)** ["AWS and Hugging Face collaborate to make generative AI more accessible and cost efficient \| AWS Machine Learning Blog"](https://aws.amazon.com/blogs/machine-learning/aws-and-hugging-face-collaborate-to-make-generative-ai-more-accessible-and-cost-efficient/). *aws.amazon.com*. 2023\-02\-21\. [Archived](https://web.archive.org/web/20230825202343/https://aws.amazon.com/blogs/machine-learning/aws-and-hugging-face-collaborate-to-make-generative-ai-more-accessible-and-cost-efficient/) from the original on 2023\-08\-25. Retrieved 2023\-08\-25.
    13. **[^](#cite_ref-13)** Leswing, Kif (2023\-08\-24\). ["Google, Amazon, Nvidia and other tech giants invest in AI startup Hugging Face, sending its valuation to $4\.5 billion"](https://www.cnbc.com/2023/08/24/google-amazon-nvidia-amd-other-tech-giants-invest-in-hugging-face.html). *CNBC*. [Archived](https://web.archive.org/web/20230824141538/https://www.cnbc.com/2023/08/24/google-amazon-nvidia-amd-other-tech-giants-invest-in-hugging-face.html) from the original on 2023\-08\-24. Retrieved 2023\-08\-24.
    14. **[^](#cite_ref-14)** ["META Collaboration Launches AI Accelerator for European Startups"](https://finance.yahoo.com/news/meta-collaboration-launches-ai-accelerator-151500146.html). *Yahoo Finance*. 2024\-06\-25. Retrieved 2024\-07\-11.
    15. **[^](#cite_ref-15)** ["🤗 Transformers"](https://huggingface.co/docs/transformers/index). *huggingface.co*. [Archived](https://web.archive.org/web/20230927023923/https://huggingface.co/docs/transformers/index) from the original on 2023\-09\-27. Retrieved 2022\-08\-20.
    16. **[^](#cite_ref-16)** ["First release"](https://github.com/huggingface/transformers/releases/tag/v0.1.2). *GitHub*. Nov 17, 2018\. [Archived](https://web.archive.org/web/20230430011038/https://github.com/huggingface/transformers/releases/tag/v0.1.2) from the original on 30 April 2023. Retrieved 28 March 2023.
    17. **[^](#cite_ref-17)** ["xenova/transformers.js"](https://github.com/xenova/transformers.js). *GitHub*.
    18. **[^](#cite_ref-18)** ["Hugging Face Hub documentation"](https://huggingface.co/docs/hub/index). *huggingface.co*. [Archived](https://web.archive.org/web/20230920185949/https://huggingface.co/docs/hub/index) from the original on 2023\-09\-20. Retrieved 2022\-08\-20.
    19. **[^](#cite_ref-19)** ["Hugging Face \- Documentation"](https://huggingface.co/docs). *huggingface.co*. [Archived](https://web.archive.org/web/20230930074626/https://huggingface.co/docs) from the original on 2023\-09\-30. Retrieved 2023\-02\-18.

    | * [v](/wiki/Template:Differentiable_computing "Template:Differentiable computing") * [t](/wiki/Template_talk:Differentiable_computing "Template talk:Differentiable computing") * [e](/wiki/Special:EditPage/Template:Differentiable_computing "Special:EditPage/Template:Differentiable computing") Differentiable computing | |
    | --- | --- |
    | [General](/wiki/Differentiable_function "Differentiable function") | * **[Differentiable programming](/wiki/Differentiable_programming "Differentiable programming")** * [Information geometry](/wiki/Information_geometry "Information geometry") * [Statistical manifold](/wiki/Statistical_manifold "Statistical manifold") * [Automatic differentiation](/wiki/Automatic_differentiation "Automatic differentiation") * [Neuromorphic engineering](/wiki/Neuromorphic_engineering "Neuromorphic engineering") * [Pattern recognition](/wiki/Pattern_recognition "Pattern recognition") * [Tensor calculus](/wiki/Tensor_calculus "Tensor calculus") * [Computational learning theory](/wiki/Computational_learning_theory "Computational learning theory") * [Inductive bias](/wiki/Inductive_bias "Inductive bias") |
    | Concepts | * [Gradient descent](/wiki/Gradient_descent "Gradient descent") 	+ [SGD](/wiki/Stochastic_gradient_descent "Stochastic gradient descent") * [Clustering](/wiki/Cluster_analysis "Cluster analysis") * [Regression](/wiki/Regression_analysis "Regression analysis") 	+ [Overfitting](/wiki/Overfitting "Overfitting") * [Hallucination](/wiki/Hallucination_(artificial_intelligence) "Hallucination (artificial intelligence)") * [Adversary](/wiki/Adversarial_machine_learning "Adversarial machine learning") * [Attention](/wiki/Attention_(machine_learning) "Attention (machine learning)") * [Convolution](/wiki/Convolution "Convolution") * [Loss functions](/wiki/Loss_functions_for_classification "Loss functions for classification") * [Backpropagation](/wiki/Backpropagation "Backpropagation") * [Batchnorm](/wiki/Batch_normalization "Batch normalization") * [Activation](/wiki/Activation_function "Activation function") 	+ [Softmax](/wiki/Softmax_function "Softmax function") 	+ [Sigmoid](/wiki/Sigmoid_function "Sigmoid function") 	+ [Rectifier](/wiki/Rectifier_(neural_networks) "Rectifier (neural networks)") * [Regularization](/wiki/Regularization_(mathematics) "Regularization (mathematics)") * [Datasets](/wiki/Training,_validation,_and_test_sets "Training, validation, and test sets") 	+ [Augmentation](/wiki/Data_augmentation "Data augmentation") * [Diffusion](/wiki/Diffusion_process "Diffusion process") * [Autoregression](/wiki/Autoregressive_model "Autoregressive model") |
    | Applications | * [Machine learning](/wiki/Machine_learning "Machine learning") 	+ [In\-context learning](/wiki/Prompt_engineering#In-context_learning "Prompt engineering") * [Artificial neural network](/wiki/Artificial_neural_network "Artificial neural network") 	+ [Deep learning](/wiki/Deep_learning "Deep learning") * [Scientific computing](/wiki/Computational_science "Computational science") * [Artificial Intelligence](/wiki/Artificial_intelligence "Artificial intelligence") * [Language model](/wiki/Language_model "Language model") 	+ [Large language model](/wiki/Large_language_model "Large language model") |
    | Hardware | * [IPU](/wiki/Graphcore "Graphcore") * [TPU](/wiki/Tensor_Processing_Unit "Tensor Processing Unit") * [VPU](/wiki/Vision_processing_unit "Vision processing unit") * [Memristor](/wiki/Memristor "Memristor") * [SpiNNaker](/wiki/SpiNNaker "SpiNNaker") |
    | Software libraries | * [TensorFlow](/wiki/TensorFlow "TensorFlow") * [PyTorch](/wiki/PyTorch "PyTorch") * [Keras](/wiki/Keras "Keras") * [Theano](/wiki/Theano_(software) "Theano (software)") * [JAX](/wiki/Google_JAX "Google JAX") * [Flux.jl](/wiki/Flux_(machine-learning_framework) "Flux (machine-learning framework)") * [MindSpore](/wiki/MindSpore "MindSpore") |
    | Implementations | | Audio–visual | * [AlexNet](/wiki/AlexNet "AlexNet") * [WaveNet](/wiki/WaveNet "WaveNet") * [Human image synthesis](/wiki/Human_image_synthesis "Human image synthesis") * [HWR](/wiki/Handwriting_recognition "Handwriting recognition") * [OCR](/wiki/Optical_character_recognition "Optical character recognition") * [Speech synthesis](/wiki/Deep_learning_speech_synthesis "Deep learning speech synthesis") * [Speech recognition](/wiki/Speech_recognition "Speech recognition") * [Facial recognition](/wiki/Facial_recognition_system "Facial recognition system") * [AlphaFold](/wiki/AlphaFold "AlphaFold") * [Text\-to\-image models](/wiki/Text-to-image_model "Text-to-image model") 	+ [DALL\-E](/wiki/DALL-E "DALL-E") 	+ [Midjourney](/wiki/Midjourney "Midjourney") 	+ [Stable Diffusion](/wiki/Stable_Diffusion "Stable Diffusion") * [Text\-to\-video models](/wiki/Text-to-video_model "Text-to-video model") 	+ [Sora](/wiki/Sora_(text-to-video_model) "Sora (text-to-video model)") 	+ [VideoPoet](/wiki/VideoPoet "VideoPoet") * [Whisper](/wiki/Whisper_(speech_recognition_system) "Whisper (speech recognition system)") | | --- | --- | | Verbal | * [Word2vec](/wiki/Word2vec "Word2vec") * [Seq2seq](/wiki/Seq2seq "Seq2seq") * [BERT](/wiki/BERT_(language_model) "BERT (language model)") * [Gemini](/wiki/Gemini_(language_model) "Gemini (language model)") * [LaMDA](/wiki/LaMDA "LaMDA") 	+ [Bard](/wiki/Bard_(chatbot) "Bard (chatbot)") * [NMT](/wiki/Neural_machine_translation "Neural machine translation") * [Project Debater](/wiki/Project_Debater "Project Debater") * [IBM Watson](/wiki/IBM_Watson "IBM Watson") * [IBM Watsonx](/wiki/IBM_Watsonx "IBM Watsonx") * [Granite](/wiki/IBM_Granite "IBM Granite") * [GPT\-1](/wiki/GPT-1 "GPT-1") * [GPT\-2](/wiki/GPT-2 "GPT-2") * [GPT\-3](/wiki/GPT-3 "GPT-3") * [GPT\-4](/wiki/GPT-4 "GPT-4") * [ChatGPT](/wiki/ChatGPT "ChatGPT") * [GPT\-J](/wiki/GPT-J "GPT-J") * [Chinchilla AI](/wiki/Chinchilla_AI "Chinchilla AI") * [PaLM](/wiki/PaLM "PaLM") * [BLOOM](/wiki/BLOOM_(language_model) "BLOOM (language model)") * [LLaMA](/wiki/LLaMA "LLaMA") * [PanGu\-Σ](/wiki/Huawei_PanGu "Huawei PanGu") | | Decisional | * [AlphaGo](/wiki/AlphaGo "AlphaGo") * [AlphaZero](/wiki/AlphaZero "AlphaZero") * [Q\-learning](/wiki/Q-learning "Q-learning") * [SARSA](/wiki/State%E2%80%93action%E2%80%93reward%E2%80%93state%E2%80%93action "State–action–reward–state–action") * [OpenAI Five](/wiki/OpenAI_Five "OpenAI Five") * [Self\-driving car](/wiki/Self-driving_car "Self-driving car") * [MuZero](/wiki/MuZero "MuZero") * [Action selection](/wiki/Action_selection "Action selection") 	+ [Auto\-GPT](/wiki/Auto-GPT "Auto-GPT") * [Robot control](/wiki/Robot_control "Robot control") | |
    | People | * [Yoshua Bengio](/wiki/Yoshua_Bengio "Yoshua Bengio") * [Alex Graves](/wiki/Alex_Graves_(computer_scientist) "Alex Graves (computer scientist)") * [Ian Goodfellow](/wiki/Ian_Goodfellow "Ian Goodfellow") * [Stephen Grossberg](/wiki/Stephen_Grossberg "Stephen Grossberg") * [Demis Hassabis](/wiki/Demis_Hassabis "Demis Hassabis") * [Geoffrey Hinton](/wiki/Geoffrey_Hinton "Geoffrey Hinton") * [Yann LeCun](/wiki/Yann_LeCun "Yann LeCun") * [Fei\-Fei Li](/wiki/Fei-Fei_Li "Fei-Fei Li") * [Andrew Ng](/wiki/Andrew_Ng "Andrew Ng") * [Jürgen Schmidhuber](/wiki/J%C3%BCrgen_Schmidhuber "Jürgen Schmidhuber") * [David Silver](/wiki/David_Silver_(computer_scientist) "David Silver (computer scientist)") * [Ilya Sutskever](/wiki/Ilya_Sutskever "Ilya Sutskever") |
    | Organizations | * [Anthropic](/wiki/Anthropic "Anthropic") * [EleutherAI](/wiki/EleutherAI "EleutherAI") * [Google DeepMind](/wiki/Google_DeepMind "Google DeepMind") * Hugging Face * [OpenAI](/wiki/OpenAI "OpenAI") * [Meta AI](/wiki/Meta_AI "Meta AI") * [Mila](/wiki/Mila_(research_institute) "Mila (research institute)") * [MIT CSAIL](/wiki/MIT_Computer_Science_and_Artificial_Intelligence_Laboratory "MIT Computer Science and Artificial Intelligence Laboratory") * [Huawei](/wiki/Huawei "Huawei") |
    | Architectures | * [Neural Turing machine](/wiki/Neural_Turing_machine "Neural Turing machine") * [Differentiable neural computer](/wiki/Differentiable_neural_computer "Differentiable neural computer") * [Transformer](/wiki/Transformer_(machine_learning_model) "Transformer (machine learning model)") * [Recurrent neural network (RNN)](/wiki/Recurrent_neural_network "Recurrent neural network") * [Long short\-term memory (LSTM)](/wiki/Long_short-term_memory "Long short-term memory") * [Gated recurrent unit (GRU)](/wiki/Gated_recurrent_unit "Gated recurrent unit") * [Echo state network](/wiki/Echo_state_network "Echo state network") * [Multilayer perceptron (MLP)](/wiki/Multilayer_perceptron "Multilayer perceptron") * [Convolutional neural network](/wiki/Convolutional_neural_network "Convolutional neural network") * [Residual neural network](/wiki/Residual_neural_network "Residual neural network") * [Mamba](/wiki/Mamba_(deep_learning) "Mamba (deep learning)") * [Autoencoder](/wiki/Autoencoder "Autoencoder") * [Variational autoencoder (VAE)](/wiki/Variational_autoencoder "Variational autoencoder") * [Generative adversarial network (GAN)](/wiki/Generative_adversarial_network "Generative adversarial network") * [Graph neural network](/wiki/Graph_neural_network "Graph neural network") |
    | * Portals 	+ [Computer programming](/wiki/Portal:Computer_programming "Portal:Computer programming") 	+ [Technology](/wiki/Portal:Technology "Portal:Technology") * Categories 	+ [Artificial neural networks](/wiki/Category:Artificial_neural_networks "Category:Artificial neural networks") 	+ [Machine learning](/wiki/Category:Machine_learning "Category:Machine learning") | |

    [Portal](/wiki/Wikipedia:Contents/Portals "Wikipedia:Contents/Portals"):* ![](//upload.wikimedia.org/wikipedia/commons/thumb/2/2a/Industry5.svg/19px-Industry5.svg.png) [Companies](/wiki/Portal:Companies "Portal:Companies")

    ![](https://login.wikimedia.org/wiki/Special:CentralAutoLogin/start?type=1x1)
    Retrieved from "[https://en.wikipedia.org/w/index.php?title\=Hugging\_Face\&oldid\=1238858455](https://en.wikipedia.org/w/index.php?title=Hugging_Face&oldid=1238858455)"
    [Categories](/wiki/Help:Category "Help:Category"): * [Machine learning](/wiki/Category:Machine_learning "Category:Machine learning")
    * [Open\-source artificial intelligence](/wiki/Category:Open-source_artificial_intelligence "Category:Open-source artificial intelligence")
    * [Privately held companies based in New York City](/wiki/Category:Privately_held_companies_based_in_New_York_City "Category:Privately held companies based in New York City")
    * [American companies established in 2016](/wiki/Category:American_companies_established_in_2016 "Category:American companies established in 2016")
    * [2016 establishments in New York City](/wiki/Category:2016_establishments_in_New_York_City "Category:2016 establishments in New York City")
    Hidden categories: * [Articles with short description](/wiki/Category:Articles_with_short_description "Category:Articles with short description")
    * [Short description is different from Wikidata](/wiki/Category:Short_description_is_different_from_Wikidata "Category:Short description is different from Wikidata")
    * [Articles lacking reliable references from February 2023](/wiki/Category:Articles_lacking_reliable_references_from_February_2023 "Category:Articles lacking reliable references from February 2023")
    * [All articles lacking reliable references](/wiki/Category:All_articles_lacking_reliable_references "Category:All articles lacking reliable references")

    * This page was last edited on 6 August 2024, at 01:57 (UTC).
    * Text is available under the [Creative Commons Attribution\-ShareAlike License 4\.0](//en.wikipedia.org/wiki/Wikipedia:Text_of_the_Creative_Commons_Attribution-ShareAlike_4.0_International_License);
    additional terms may apply. By using this site, you agree to the [Terms of Use](//foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Terms_of_Use) and [Privacy Policy](//foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy). Wikipedia® is a registered trademark of the [Wikimedia Foundation, Inc.](//wikimediafoundation.org/), a non\-profit organization.

    * [Privacy policy](https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy)
    * [About Wikipedia](/wiki/Wikipedia:About)
    * [Disclaimers](/wiki/Wikipedia:General_disclaimer)
    * [Contact Wikipedia](//en.wikipedia.org/wiki/Wikipedia:Contact_us)
    * [Code of Conduct](https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Universal_Code_of_Conduct)
    * [Developers](https://developer.wikimedia.org)
    * [Statistics](https://stats.wikimedia.org/#/en.wikipedia.org)
    * [Cookie statement](https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Cookie_statement)
    * [Mobile view](//en.m.wikipedia.org/w/index.php?title=Hugging_Face&mobileaction=toggle_view_mobile)

    * [![Wikimedia Foundation](/static/images/footer/wikimedia-button.svg)](https://wikimediafoundation.org/)
    * [![Powered by MediaWiki](/w/resources/assets/poweredby_mediawiki.svg)](https://www.mediawiki.org/)

    *

##
Build our multi-agent system 🤖🤝🤖

Now that we have all the tools `search` and `visit_webpage`, we can use them to create the web agent.

Which configuration to choose for this agent?

- Web browsing is a single-timeline task that does not require parallel tool calls, so JSON tool calling works well for that. We thus choose a `ReactJsonAgent`.
- Also, since sometimes web search requires exploring many pages before finding the correct answer, we prefer to increase the number of `max_iterations` to 10.

    from transformers.agents import (
        ReactCodeAgent,
        ReactJsonAgent,
        HfApiEngine,
        ManagedAgent,
    )
    from transformers.agents.search import DuckDuckGoSearchTool

    llm_engine = HfApiEngine(model)

    web_agent = ReactJsonAgent(
        tools=[DuckDuckGoSearchTool(), VisitWebpageTool()],
        llm_engine=llm_engine,
        max_iterations=10,
    )

We then wrap this agent into a `ManagedAgent` that will make it callable by its manager agent.

    managed_web_agent = ManagedAgent(
        agent=web_agent,
        name="search_agent",
        description="Runs web searches for you. Give it your query as an argument.",
    )

Finally we create a manager agent, and upon initialization we pass our managed agent to it in its `managed_agents` argument.

Since this agent is the one tasked with the planning and thinking, advanced reasoning will be beneficial, so a `ReactCodeAgent` will be the best choice.

Also, we want to ask a question that involves the current year: so let us add `additional_authorized_imports=["time", "datetime"]`

    manager_agent = ReactCodeAgent(
        tools=[],
        llm_engine=llm_engine,
        managed_agents=[managed_web_agent],
        additional_authorized_imports=["time", "datetime"],
    )

That’s all! Now let’s run our system! We select a question that requires some calculation and

    manager_agent.run("How many years ago was Stripe founded?")

Our agents managed to efficiently collaborate towards solving the task! ✅

💡 You can easily extend this to more agents: one does the code execution, one the web search, one handles file loadings…

🤔💭 One could even think of doing more complex, tree-like hierarchies, with one CEO agent handling multiple middle managers, each with several reports.

We could even add more intermediate layers of management, each with multiple daily meetings, lots of agile stuff with scrum masters, and each new component adds enough friction to ensure the tasks never get done… Ehm wait, no, let’s stick with our simple structure.

< > Update on GitHub