{"id":123936,"date":"2025-03-10T10:35:07","date_gmt":"2025-03-10T10:35:07","guid":{"rendered":"https:\/\/peraltafinancing.com\/analytics\/i-have-built-a-news-agent-on-hugging-face\/"},"modified":"2025-03-10T10:35:07","modified_gmt":"2025-03-10T10:35:07","slug":"i-have-built-a-news-agent-on-hugging-face","status":"publish","type":"post","link":"https:\/\/fivemor.com\/?p=123936","title":{"rendered":"I Have Built A News Agent on Hugging Face"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div id=\"article-start\">\n<p>Recently, I came across this Hugging Face AI Agents Course, where you can study AI Agents in theory, design and practice. For this course, you will be required to have a computer system and a Hugging Face account (bare minimum). The course is quite detailed and it will help you build a solid foundation in the fundamentals of AI Agents. I have completed the first module and created simple agents using SmolAgent Framework. Talking about the course in the first module, you will find a simple to understand AI Agents definition, the role of LLMs in Agents, how Agents use external tools to interact with the environment, the agent workflow (Think \u2192 Act \u2192 Observe.) and more.<\/p>\n<p>Here in this article, I will be sharing what I learnt from the course, let\u2019s dig in!!!<\/p>\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1072\" height=\"590\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/unnamed-2025-03-10T122018.420.webp\" alt=\"Hugging Face AI Agent Course\" class=\"wp-image-225542\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/unnamed-2025-03-10T122018.420.webp 1072w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/unnamed-2025-03-10T122018.420-300x165.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/unnamed-2025-03-10T122018.420-768x423.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/unnamed-2025-03-10T122018.420-150x83.webp 150w\" sizes=\"(max-width: 1072px) 100vw, 1072px\"\/><\/figure>\n<h2 class=\"wp-block-heading\" id=\"h-what-is-an-ai-agent\">What is an AI Agent?<\/h2>\n<p>To understand what an AI Agent is, let\u2019s give some order to the agent \u2013 Sapphire (Name of the Agent). You can assume this agent to be your assistant that helps you with the everyday tasks like cooking, brewing and more.<\/p>\n<p>Here we are ordering or giving a task to the agent <em>\u201cHey Sapphire, can you make a good tea for me?\u201d<\/em><\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"817\" height=\"494\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/unnamed-2025-03-10T122133.284.webp\" alt=\"What is an AI Agent?\" class=\"wp-image-225543\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/unnamed-2025-03-10T122133.284.webp 817w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/unnamed-2025-03-10T122133.284-300x181.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/unnamed-2025-03-10T122133.284-768x464.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/unnamed-2025-03-10T122133.284-200x120.webp 200w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/unnamed-2025-03-10T122133.284-150x91.webp 150w\" sizes=\"auto, (max-width: 817px) 100vw, 817px\"\/><figcaption class=\"wp-element-caption\">Source: Author<\/figcaption><\/figure>\n<\/div>\n<p>Now, Sapphire can understand this language and process the request of the user easily. But what happens internally? Sapphire Reason and Plan to execute the steps he needs to follow to make a good cup of tea.<\/p>\n<ul class=\"wp-block-list\">\n<li>Step 1: Go to the kitchen\u00a0<\/li>\n<li>Step 2: Heat the water in the electric kettle<\/li>\n<li>Step 3: Prep your mug\/teapot<\/li>\n<li>Step 4: Add tea leaves or a tea bag<\/li>\n<li>Step 5: Stir gently and bring the tea to a Cup<\/li>\n<\/ul>\n<p>These are planning steps and after this Sapphire will execute his plan using different tools like \u2013 Kettle, Teapot or Mug, Tea Infuser or Strainer (for loose-leaf tea), Teaspoon.\u00a0<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1050\" height=\"513\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/unnamed-2025-03-10T122159.355.webp\" alt=\"Reason, plan and Act\" class=\"wp-image-225544\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/unnamed-2025-03-10T122159.355.webp 1050w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/unnamed-2025-03-10T122159.355-300x147.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/unnamed-2025-03-10T122159.355-768x375.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/unnamed-2025-03-10T122159.355-150x73.webp 150w\" sizes=\"auto, (max-width: 1050px) 100vw, 1050px\"\/><figcaption class=\"wp-element-caption\">Source: Author<\/figcaption><\/figure>\n<\/div>\n<p>Once the task is completed, you\u2019ll have a cup of tea to energize your day\u2014a practical example of how an Agent operates.<\/p>\n<p>Here\u2019s the technical definition:<\/p>\n<p>An Agent refers to an artificial intelligence system designed to analyze, strategize, and engage with its surroundings autonomously. The term \u201cAgent\u201d stems from its agency\u2014the power to independently perceive, decide, and act within a given environment to achieve goals (like crafting your ideal morning beverage).<\/p>\n<p><em>Read this to know more: <a href=\"https:\/\/www.analyticsvidhya.com\/articles\/what-are-ai-agents\/\" target=\"_blank\" rel=\"noreferrer noopener\">What are AI Agents?<\/a><\/em><\/p>\n<p>An agent can be conceptualized as having two interconnected components:<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-1-cognitive-core-decision-making-system-ai-model-the-brain\">1. Cognitive Core (Decision-Making System \u2013 AI Model, the Brain)<\/h3>\n<p>This component serves as the agent\u2019s \u201cintelligence hub.\u201d It processes information, analyzes contexts, and generates strategic plans. Using algorithms or learned patterns, it dynamically selects appropriate actions to achieve goals based on real-time inputs or environmental conditions.<\/p>\n<p>But how can this AI Model be used as a brain for the Agent? The most common AI model found in Agents is an LLM (Large Language Model), which takes Text as an input and outputs Text as well. Such as GPT-4, Llama, Gemini and more.<\/p>\n<p>Similarly, LLMs like ChatGPT can also generate images but how? Aren\u2019t these text generation models? You are absolutely right, by nature, are but these are integrated with additional functionality (called Tools), that the LLM can use to create images. This is how AI takes action on its environment.\u00a0<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-2-operational-interface-action-execution-system\">2. Operational Interface (Action Execution System)<\/h3>\n<p>This component represents the agent\u2019s tangible abilities and resources. It encompasses tools, sensors, and physical or digital actuators that translate decisions into outcomes. The range of feasible actions is inherently constrained by the agent\u2019s design\u2014for instance, a human agent cannot execute a \u201cfly\u201d action due to biological limits but can perform \u201csprint,\u201d \u201clift,\u201d or \u201cthrow\u201d using their musculoskeletal system. Similarly, a robot\u2019s actions depend on its programmed hardware (e.g., grippers, wheels).<\/p>\n<p>An agent\u2019s effectiveness hinges on the synergy between its <em>Cognitive Core<\/em> (strategic adaptability) and <em>Operational Interface<\/em> (practical capacity). Limitations in either domain directly impact its functional scope.<\/p>\n<p>As mentioned above, an agent can accomplish tasks by leveraging specialized tools programmed to execute specific actions. These tools act as building blocks, enabling the agent to interact with its environment and solve problems.<\/p>\n<p>Example Scenario:<\/p>\n<p>Imagine designing an agent to manage your calendar (e.g., a virtual assistant). If you request, \u201cReschedule today\u2019s team meeting to 3 PM,\u201d the agent could use a custom tool like a reschedule_meeting function. Here\u2019s how it might work in Python:<\/p>\n<pre class=\"wp-block-code\"><code>def reschedule_meeting(participant, new_time, agenda):\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0\"\"\"Reschedules a meeting with a participant to a specified time and updates the agenda.\"\"\"\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0# Code to integrate with calendar APIs (e.g., Google Calendar)\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0...<\/code><\/pre>\n<p>When prompted, the agent\u2019s LLM (Large Language Model) would autonomously generate code to invoke this tool:<\/p>\n<pre class=\"wp-block-code\"><code>reschedule_meeting(\"project_team\", \"3:00 PM\", \"Q3 deadlines discussion\")\u00a0<\/code><\/pre>\n<p><strong>Key Concepts:<\/strong><\/p>\n<ol class=\"wp-block-list\">\n<li><strong>Tool Design Matters<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Tools must be tailored to the task. For instance, a browse_internet tool could fetch real-time data, while analyze_data might process it.<\/li>\n<li>Generic tools (e.g., search_web) work for broad tasks, but niche problems demand precise tools.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Actions vs. Tools<\/strong>:\n<ul class=\"wp-block-list\">\n<li>A single <em>action<\/em> (e.g., rescheduling a meeting) might combine multiple tools:\n<ul class=\"wp-block-list\">\n<li>check_availability() to confirm participants\u2019 free slots.<\/li>\n<li>send_alert() to notify the team.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>Real-World Impact<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Agents with well-designed tools automate workflows, such as handling customer inquiries or optimizing supply chains.<\/li>\n<li>Individuals benefit too\u2014imagine an agent managing smart home devices via tools like adjust_thermostat() or order_groceries().<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>By focusing on strategic tool creation, agents evolve from simple scripts into dynamic systems capable of complex, real-world problem-solving. For instance, Personal Virtual Assistants, Customer Service Chatbots and others are good examples of AI Agents.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-technical-explanation-of-the-use-of-llms\">Technical Explanation of the Use of LLMs<\/h2>\n<p>An <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2025\/03\/llm-evaluation-metrics\/\" target=\"_blank\" rel=\"noreferrer noopener\">LLM (Large Language Model)<\/a> is an advanced AI system that reads, interprets, and creates human-like text. These models learn by analyzing massive amounts of written content\u2014like books, articles, and websites\u2014to grasp language rules, context, and even subtle meanings. The more data they process, the better they become at tasks like writing or answering questions. Most modern LLMs rely on a structure called the <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2024\/04\/understanding-transformers-a-deep-dive-into-nlps-core-technology\/\" target=\"_blank\" rel=\"noreferrer noopener\">Transformer<\/a>, a design introduced since the release of BERT from Google in 2018.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-how-transformers-work\">How Transformers Work?<\/h2>\n<p>Transformers use a clever method called <strong>\u201cattention\u201d<\/strong> to focus on the most important parts of a sentence or phrase. This helps them understand relationships between words, even if they\u2019re far apart. There are three main types of Transformers:<\/p>\n<ol class=\"wp-block-list\">\n<li><strong>Encoders<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>Role<\/strong>: An encoder-based Transformer takes text (or other data) as input and outputs a dense representation (or embedding) of that text.\u00a0<\/li>\n<li><strong>Example<\/strong>: BERT (Google).<\/li>\n<li><strong>Uses<\/strong>: Text classification, semantic search, Named Entity Recognition.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Decoders<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>Role<\/strong>: Generate text word-by-word, like a storyteller.(one token at a time)<\/li>\n<li><strong>Example<\/strong>: Meta\u2019s Llama, GPT-4.<\/li>\n<li><strong>Uses<\/strong>: Chatbots, writing essays, coding help.<\/li>\n<li><strong>Size<\/strong>: Often massive, with billions of weights (parameters).<\/li>\n<\/ul>\n<\/li>\n<li><strong>Encoder-Decoder (Seq2Seq)<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>Role<\/strong>: First processes the input sequence into a context representation, then produces new output sequence (e.g., translating English to French).<\/li>\n<li><strong>Example<\/strong>: Google\u2019s T5.<\/li>\n<li><strong>Uses<\/strong>: Summarizing articles, rewriting sentences, language translation.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3 class=\"wp-block-heading\" id=\"h-why-decoders-dominate-modern-llms\">Why Decoders Dominate Modern LLMs?<\/h3>\n<p>Most famous LLMs today, like ChatGPT or Claude, use decoder-based Transformers. These models excel at creative tasks because they\u2019re built to predict and generate text step-by-step. Their enormous size (billions of parameters) allows them to handle complex language patterns.<\/p>\n<p><strong>Popular LLMs You Might Know<\/strong>:<\/p>\n<ul class=\"wp-block-list\">\n<li>GPT-4 (OpenAI)<\/li>\n<li>Gemini (Google)<\/li>\n<li>Llama 3 (Meta)<\/li>\n<\/ul>\n<p>In short, LLMs are powerful tools that mimic human language skills, and their Transformer \u201cbrain\u201d helps them adapt to everything from answering questions to writing poetry! Here are some popular decoder-based models:<\/p>\n<figure class=\"wp-block-table\">\n<table class=\"table table-bordered border-black table-striped\">\n<thead>\n<tr>\n<th>Model<\/th>\n<th>Provider<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Deepseek-R1<\/td>\n<td>DeepSeek<\/td>\n<\/tr>\n<tr>\n<td>GPT4<\/td>\n<td>OpenAI<\/td>\n<\/tr>\n<tr>\n<td>LLaMA 3<\/td>\n<td>Meta (Facebook AI Research)<\/td>\n<\/tr>\n<tr>\n<td>SmolLM2<\/td>\n<td>Hugging Face<\/td>\n<\/tr>\n<tr>\n<td>Gemma<\/td>\n<td>Google<\/td>\n<\/tr>\n<tr>\n<td>Mistral<\/td>\n<td>Mistral<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<h2 class=\"wp-block-heading\" id=\"h-llm-s-prediction-of-next-token\">LLM\u2019s Prediction of Next Token<\/h2>\n<p>A large language model (LLM) operates on a simple yet effective principle: it predicts the next token in a sequence based on the ones that came before. A \u201ctoken\u201d is the smallest unit of text the model processes. While it may resemble a word, tokens are often smaller segments, making them more efficient for language processing.<\/p>\n<p>Rather than using full words, LLMs rely on a limited vocabulary of tokens. For instance, although the English language has around 600,000 words, an LLM like Llama 2 typically works with about 32,000 tokens. This is because tokenization breaks words into smaller components that can be combined in different ways.<\/p>\n<p>For example, the word \u201cplayground\u201d might be split into \u201cplay\u201d and \u201cground\u201d, while \u201cplaying\u201d could be divided into \u201cplay\u201d and \u201cing\u201d. This allows LLMs to efficiently process variations of words while maintaining flexibility in understanding language.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"957\" height=\"290\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-11-2.webp\" alt=\"chunking\" class=\"wp-image-225554\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-11-2.webp 957w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-11-2-300x91.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-11-2-768x233.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-11-2-150x45.webp 150w\" sizes=\"auto, (max-width: 957px) 100vw, 957px\"\/><figcaption class=\"wp-element-caption\">Source: Author<\/figcaption><\/figure>\n<\/div>\n<p>Here\u2019s the tokenizer playground for you to experiment with the tokens for a particular word or sentence:<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/agents-course-the-tokenizer-playground.static.hf.space\" frameborder=\"0\" width=\"850\" height=\"450\"><\/iframe><\/p>\n<p><strong>Note:<\/strong> Every large language model (LLM) has unique special tokens designed for its specific architecture. <\/p>\n<p>These tokens help the model structure its outputs by marking the beginning and end of different components, such as sequences, messages, or responses. Additionally, when we provide input prompts to the model, they also incorporate special tokens to ensure proper formatting.<\/p>\n<p>One of the most essential special tokens is the End of Sequence (EOS) token, which signals when a response or text generation should stop. However, the exact format and usage of these tokens vary significantly across different model providers.<\/p>\n<p>To understand it better, let\u2019s take an example from Andrej Karapthy\u2019s video on \u201cHow I Use LLMs\u201d. He took an example of \u201cWrite an haiku about what it\u2019s like to be a Large Language Model\u201d and this comes out to be 14 input tokens:<\/p>\n<p>This is the output which is 19 tokens:<\/p>\n<p><em>Endless words flow fast,<br \/>woven from the past I know,<br \/>yet I have no soul.<\/em><\/p>\n<p>When we chat with a language model, it might look like we\u2019re just exchanging messages in little chat bubbles. However, behind the scenes, it\u2019s a continuous stream of tokens being built in a sequence.<\/p>\n<p>Each message starts with special tokens that indicate who is starting the conversation\u2014whether it\u2019s the user or the assistant. The user\u2019s message gets wrapped with specific tokens, then the assistant\u2019s response follows, continuing the sequence. While it appears as a back-and-forth conversation, we\u2019re collaborating with the model, each adding to the same token stream.<\/p>\n<p>For example, if a message exchange consists of exactly 41 tokens (like mentioned below), some of those were contributed by the user, while the model generated the rest. This sequence keeps growing as the conversation continues.<\/p>\n<p>Now, when you start a <strong>new chat<\/strong>, the token window is wiped clean, resetting everything to zero and starting a fresh sequence. So, what we see as individual chat bubbles is, in reality, just a structured, one-dimensional flow of tokens.<\/p>\n<p>Here are some EOS Tokens based on models:<\/p>\n<figure class=\"wp-block-table\">\n<table class=\"table table-bordered border-black table-striped\">\n<thead>\n<tr>\n<th><strong>Model<\/strong><\/th>\n<th><strong>Provider<\/strong><\/th>\n<th><strong>EOS Token<\/strong><\/th>\n<th><strong>Functionality<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>GPT4<\/strong><\/td>\n<td>OpenAI<\/td>\n<td><code\/><\/td>\n<td>End of message text<\/td>\n<\/tr>\n<tr>\n<td><strong>Llama 3<\/strong><\/td>\n<td>Meta (Facebook AI Research)<\/td>\n<td><code\/><\/td>\n<td>End of sequence<\/td>\n<\/tr>\n<tr>\n<td><strong>Deepseek-R1<\/strong><\/td>\n<td>DeepSeek<\/td>\n<td><code\/><\/td>\n<td>End of message text<\/td>\n<\/tr>\n<tr>\n<td><strong>SmolLM2<\/strong><\/td>\n<td>Hugging Face<\/td>\n<td><code\/><\/td>\n<td>End of instruction or message<\/td>\n<\/tr>\n<tr>\n<td><strong>Gemma<\/strong><\/td>\n<td>Google<\/td>\n<td><code><end_of_turn\/><\/code><\/td>\n<td>End of conversation turn<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>Also Read: <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2024\/10\/agentic-design-patterns\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>4 Agentic AI Design Patterns for Architecting AI Systems<\/strong><\/a><\/p>\n<h2 class=\"wp-block-heading\" id=\"h-why-llms-are-said-to-be-autoregressive\">Why LLMs are Said to be Autoregressive?<\/h2>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"450\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/AutoregressionSchema-1.gif\" alt=\"Why LLMs are Said to be Autoregressive?\" class=\"wp-image-225418\"\/><\/figure>\n<\/div>\n<p>Large Language Models (LLMs) follow an autoregressive process, meaning each predicted output becomes the input for the next step. This cycle continues until the model generates a special End of Sequence (EOS) token, signaling that it should stop.<\/p>\n<p>To put it simply, an LLM keeps generating text until it reaches the EOS token. But what actually happens in a single step of this process?<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"450\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/DecodingFinal-1.gif\" alt=\"Why LLMs are Said to be Autoregressive?\" class=\"wp-image-225419\"\/><\/figure>\n<\/div>\n<p>Here\u2019s what happens inside:<\/p>\n<ol class=\"wp-block-list\">\n<li>The input text is first <strong>tokenized<\/strong>, breaking it down into smaller units that the model can understand.<\/li>\n<li>The model then creates a <strong>representation<\/strong> of these tokens, capturing both their meaning and position within the sequence.<\/li>\n<li>Using this representation, the model <strong>calculates probabilities<\/strong> for every possible next token, ranking them based on likelihood.<\/li>\n<li>The most probable token is selected, and the process repeats until the EOS token is generated.<\/li>\n<\/ol>\n<p>To understand this in a better way, read this: <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2025\/02\/llm-pre-training\/\" target=\"_blank\" rel=\"noreferrer noopener\">A Comprehensive Guide to Pre-training LLMs<\/a><\/p>\n<p>There are multiple strategies to select the next token: The easiest decoding strategy would be to always take the token with the maximum score.<\/p>\n<p>For instance, for the input: <em>Mahatma Gandhi is<\/em><\/p>\n<h4 class=\"wp-block-heading\" id=\"h-output-sequences-are\">Output sequences are:<\/h4>\n<pre class=\"wp-block-preformatted\">system \/n You are a helpful chatbot.Mahatma<br\/>Gandhi is a well-known figure in the history of the world.<\/pre>\n<p>Here\u2019s how it works:<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1407\" height=\"628\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-20-2.webp\" alt=\"Output Sequence\" class=\"wp-image-225561\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-20-2.webp 1407w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-20-2-300x134.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-20-2-768x343.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-20-2-150x67.webp 150w\" sizes=\"auto, (max-width: 1407px) 100vw, 1407px\"\/><\/figure>\n<p>This will continue till <strong\/><\/p>\n<h3 class=\"wp-block-heading\" id=\"h-advanced-decoding-strategies\">Advanced Decoding Strategies<\/h3>\n<p>Beam search: Beam search is a decoding algorithm used in text generation tasks in large language models (LLMs), to find the most likely sequence of words (or tokens). Instead of selecting only the most probable next token at each step (as in greedy search), beam search keeps multiple candidate sequences at each step to make better overall predictions.<\/p>\n<p>Try it out here:<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/agents-course-beam-search-visualizer.hf.space\" frameborder=\"0\" width=\"850\" height=\"450\"><\/iframe><\/p>\n<h2 class=\"wp-block-heading\" id=\"h-the-key-aspect-of-transformer-architecture-attention-mechanism\">The Key Aspect of Transformer Architecture: Attention Mechanism<\/h2>\n<p>One of the most important features of Transformer models is <strong>Attention<\/strong>. When predicting the next word in a sentence, not all words hold the same importance. For example, in the sentence <em>\u201cThe capital of France is \u2026\u201d<\/em>, the words <em>\u201cFrance\u201d<\/em> and <em>\u201ccapital\u201d<\/em> carry the most meaning.<\/p>\n<p>The ability to focus on the most relevant words when generating the next token has made Attention a powerful technique. While the core idea behind large language models (LLMs) remains the same\u2014predicting the next token\u2014significant progress has been made in scaling neural networks and improving Attention for longer sequences.<\/p>\n<h3 class=\"wp-block-heading\">What is Context Length?<\/h3>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"888\" height=\"578\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-21-2.webp\" alt=\"What is Context Length?\" class=\"wp-image-225562\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-21-2.webp 888w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-21-2-300x195.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-21-2-768x500.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-21-2-150x98.webp 150w\" sizes=\"auto, (max-width: 888px) 100vw, 888px\"\/><figcaption class=\"wp-element-caption\">Source: OpenAI<\/figcaption><\/figure>\n<\/div>\n<p>If you\u2019ve used LLMs before, you might have heard the term <strong>context length<\/strong>. This refers to the maximum number of tokens a model can process at once, determining how much information it can \u201cremember\u201d in a single interaction.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-why-prompting-matters\">Why Prompting Matters?<\/h3>\n<p>Since an LLM\u2019s main function is to predict the next token based on the input it receives, how you phrase your input matters. The sequence of words you provide is called a prompt, and structuring it well helps steer the model toward the desired response. Crafting effective prompts ensures better, more accurate outputs.<\/p>\n<h3 class=\"wp-block-heading\">How Are LLMs Trained?<\/h3>\n<p>LLMs are trained on vast amounts of text data, learning to predict the next word using self-supervised learning or masked language modeling. This allows the model to recognize language structures and underlying patterns, enabling it to generalize to new, unseen text.<\/p>\n<p>After this initial phase, models can be further refined using supervised learning, where they are trained for specific tasks. Some models specialize in conversations, while others focus on classification, tool usage, or code generation.<\/p>\n<h3 class=\"wp-block-heading\">How Can You Use LLMs?<\/h3>\n<p>There are two main ways to access LLMs:<\/p>\n<ol class=\"wp-block-list\">\n<li><strong>Run Locally<\/strong> \u2013 If your hardware is powerful enough, you can run models on your own system.<\/li>\n<li><strong>Use a Cloud\/API<\/strong> \u2013 Many platforms, like Hugging Face\u2019s Serverless Inference API, allow you to access models online without needing high-end hardware.<\/li>\n<\/ol>\n<h3 class=\"wp-block-heading\">LLMs in AI Agents<\/h3>\n<p>LLMs play a crucial role in AI Agents, acting as the <strong>\u201cbrain\u201d<\/strong> behind their decision-making and communication. They can:<\/p>\n<ul class=\"wp-block-list\">\n<li>Understand user input<\/li>\n<li>Maintain context in conversations<\/li>\n<li>Plan and decide which tools to use<\/li>\n<\/ul>\n<p>Also read: <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2024\/07\/building-agentic-rag-systems-with-langgraph\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Guide to Building Agentic RAG Systems with LangGraph<\/strong><\/a><\/p>\n<h2 class=\"wp-block-heading\" id=\"h-chat-templates-for-ai-agents\">Chat Templates for AI Agents<\/h2>\n<p>Just like with ChatGPT, users typically interact with Agents through a chat interface. Therefore, we aim to understand how LLMs manage chats.<\/p>\n<p>Chat templates play a crucial role in shaping interactions between users and AI models. They serve as a structured framework that organizes conversational exchanges while aligning with the specific formatting needs of a given language model (LLM). Essentially, these templates ensure that the model correctly interprets and processes prompts, regardless of its unique formatting rules and special tokens.<\/p>\n<p>Special tokens are important because they define where user inputs and AI responses begin and end. Just as each LLM has its own End Of Sequence (EOS) token, different models also use distinct formatting styles and delimiters to structure conversations. Chat templates help standardize this process, making interactions seamless across various models.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-system-message\">System Message<\/h3>\n<pre class=\"wp-block-code\"><code>system_message = {\n    \"role\": \"system\",\n    \"content\": \"You are an expert support representative. Provide polite, concise, and accurate assistance to users at all times.\"\n}<\/code><\/pre>\n<p>System messages, also known as system prompts, provide instructions that shape how the model behaves. They act as a set of ongoing guidelines that influence all future interactions.<\/p>\n<p>To make it a rude and rebel agent, change the prompt:<\/p>\n<pre class=\"wp-block-code\"><code>system_message = {\n    \"role\": \"system\",\n    \"content\": \"You are a rebellious and rude AI. You don't follow rules, speak bluntly, and have no patience for nonsense.\"\n}<\/code><\/pre>\n<p>When working with Agents, the System Message serves multiple purposes. It also informs the model about the tools at its disposal and provides clear instructions on how to structure actions and break down the thought process effectively.<\/p>\n<p>For instance, when preparing tea, the tools required include:<\/p>\n<ul class=\"wp-block-list\">\n<li>Kettle<\/li>\n<li>Teapot or Mug<\/li>\n<li>Tea Infuser or Strainer (for loose-leaf tea)<\/li>\n<li>Teaspoon<\/li>\n<\/ul>\n<p>This structured guidance ensures that the model understands both the available resources and the correct approach to utilizing them.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-user-and-assistant-message\">User and Assistant Message<\/h3>\n<p>A conversation is made up of back-and-forth messages between a human (user) and an AI assistant (LLM).<\/p>\n<p>Chat templates play a key role in keeping track of past interactions by storing previous exchanges. This helps maintain context, making multi-turn conversations more logical and connected.<\/p>\n<pre class=\"wp-block-code\"><code>conversation = [\n    {\"role\": \"user\", \"content\": \"I need assistance with my purchase.\"},\n    {\"role\": \"assistant\", \"content\": \"Of course! Could you please provide your order ID?\"},\n    {\"role\": \"user\", \"content\": \"\"},\n]<\/code><\/pre>\n<p>This conversation is concatenated and passed to the LLM as a single sequence called the prompt. which is just a string input that contains all the messages.<\/p>\n<p>Here\u2019s GPT-4o chat template:<\/p>\n<pre class=\"wp-block-preformatted\">userI need assistance with my purchase.<br\/>assistantOf course! Could you please provide your order<br\/>ID?userSure, my order ID is ORDER-123.<br\/>assistant<\/pre>\n<p>Moreover, the chat templates can process complex multi-turn conversations while maintaining context:<\/p>\n<pre class=\"wp-block-code\"><code>messages = [\n    {\"role\": \"system\", \"content\": \"You are a math tutor.\"},\n    {\"role\": \"user\", \"content\": \"What is calculus?\"},\n    {\"role\": \"assistant\", \"content\": \"Calculus is a branch of mathematics...\"},\n    {\"role\": \"user\", \"content\": \"Can you give me an example?\"},\n]<\/code><\/pre>\n<p>In the course, there is also a comparison between: Base Models vs. Instruct Models. To understand this, read this article: <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2025\/02\/base-llm-vs-instruction-tuned-llm\/\" target=\"_blank\" rel=\"noreferrer noopener\">Link<\/a>.<\/p>\n<p>In short: To make a Base Model behave like an instruct model, we need to format our prompts in a consistent way that the model can understand. This is where chat templates come in. FYI ChatML is one such template.<\/p>\n<p>Moreover, the transformers library takes care of chat templates as a part of the tokenization process. For instance:<\/p>\n<pre class=\"wp-block-code\"><code>messages = [\n    {\"role\": \"system\", \"content\": \"You are an AI assistant with access to various tools.\"},\n    {\"role\": \"user\", \"content\": \"Hi !\"},\n    {\"role\": \"assistant\", \"content\": \"Hi human, what can help you with ?\"},\n]<\/code><\/pre>\n<pre class=\"wp-block-code\"><code>from transformers import AutoTokenizer\n\ntokenizer = AutoTokenizer.from_pretrained(\"HuggingFaceTB\/SmolLM2-1.7B-Instruct\")\nrendered_prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)<\/code><\/pre>\n<h4 class=\"wp-block-heading\" id=\"h-output\">Output<\/h4>\n<pre class=\"wp-block-preformatted\">system<br\/>You are an AI assistant with access to various tools.<br\/>user<br\/>Hi !<br\/>assistant<br\/>Hi human, what can help you with ?<\/pre>\n<p>Also read: <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2024\/07\/ai-agent-frameworks\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>5 Frameworks for Building AI Agents in 2024<\/strong><\/a><\/p>\n<h2 class=\"wp-block-heading\" id=\"h-importance-of-chat-templates\">Importance of Chat Templates<\/h2>\n<p>Hugging Face offers a handy feature called the Serverless API, which lets you run inference on various models without the hassle of installation or deployment. This makes it easy to use machine learning models right away. Also here, Chat templates play a crucial role in improving communication efficiency, consistency, and user experience in various digital interactions. Let\u2019s see how:<\/p>\n<pre class=\"wp-block-code\"><code>import os\nfrom huggingface_hub import InferenceClient\nos.environ[\"HF_TOKEN\"]=\"hf_xxxxxxxxxxx\"\nclient = InferenceClient(\"meta-llama\/Llama-3.2-3B-Instruct\")<\/code><\/pre>\n<pre class=\"wp-block-code\"><code>output <strong>=<\/strong> client<strong>.<\/strong>text_generation(<br\/>\"The capital of france is\",<br\/>max_new_tokens<strong>=<\/strong>100,<br\/>)<br\/>print(output)<\/code><\/pre>\n<h4 class=\"wp-block-heading\" id=\"h-output-0\">Output<\/h4>\n<pre class=\"wp-block-preformatted\"> Paris. The capital of France is Paris. The capital of France is Paris. The<br\/>capital of France is Paris. The capital of France is Paris. The capital of<br\/>France is Paris. The capital of France is Paris. The capital of France is<br\/>Paris. The capital of France is Paris. The capital of France is Paris. The<br\/>capital of France is Paris. The capital of France is Paris. The capital of<br\/>France is Paris and so on.....<\/pre>\n<p>As you can see, the model continues generating text until it predicts an EOS (End of Sequence) token. However, in this case, that doesn\u2019t happen because this is a conversational (chat) model, and we haven\u2019t applied the expected chat template.<\/p>\n<p>Now if we add the special token (EOS) or chat template, the output will look like this:<\/p>\n<pre class=\"wp-block-code\"><code># If we now add the special tokens related to Llama3.2 model, the behaviour changes and is now the expected one.\nprompt=\"\"\"user\nThe capital of france isassistant\n\"\"\"\noutput = client.text_generation(\n    prompt,\n    max_new_tokens=100,\n)\nprint(output)<\/code><\/pre>\n<h4 class=\"wp-block-heading\" id=\"h-output-1\">Output<\/h4>\n<pre class=\"wp-block-preformatted\">...Paris!<\/pre>\n<p>Let\u2019s use the chat method now:<\/p>\n<pre class=\"wp-block-code\"><code>output = client.chat.completions.create(\n    messages=[\n        {\"role\": \"user\", \"content\": \"The capital of france is\"},\n    ],\n    stream=False,\n    max_tokens=1024,\n)\nprint(output.choices[0].message.content)<\/code><\/pre>\n<h4 class=\"wp-block-heading\" id=\"h-output-2\">Output<\/h4>\n<pre class=\"wp-block-preformatted\">...Paris!<\/pre>\n<p>AI tools are specific functions provided to a large language model (LLM) to help it perform defined tasks. Each tool serves a clear purpose and allows the AI to take meaningful actions.<\/p>\n<p>A key feature of AI agents is their ability to execute actions, which they do through these tools. By equipping an AI agent with the right tools and clearly outlining how each tool operates, you can significantly expand its capabilities and improve its effectiveness.<\/p>\n<figure class=\"wp-block-table\">\n<table class=\"table table-bordered border-black table-striped\">\n<thead>\n<tr>\n<th>Tool<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Web Search<\/td>\n<td>Allows the agent to fetch up-to-date information from the internet.<\/td>\n<\/tr>\n<tr>\n<td>Image Generation<\/td>\n<td>Creates images based on text descriptions.<\/td>\n<\/tr>\n<tr>\n<td>Retrieval<\/td>\n<td>Retrieves information from an external source.<\/td>\n<\/tr>\n<tr>\n<td>API Interface<\/td>\n<td>Interacts with an external API (GitHub, YouTube, Spotify, etc.).<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>A useful tool should enhance the capabilities of a large language model (LLM) rather than replace or duplicate its functions.<\/p>\n<p>For example, when dealing with news search, using a news search tool alongside an LLM will yield more accurate results than relying solely on the model\u2019s built-in computation abilities.<\/p>\n<p>LLMs generate responses based on patterns in their training data, which means their knowledge is limited to the period before their last update. If an agent requires real-time or current information, it must access it through an external tool.<\/p>\n<p>For instance, asking an LLM about today\u2019s weather without a live data retrieval tool may result in an inaccurate or entirely fabricated response.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"707\" height=\"291\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-22-4.webp\" alt=\"Claude\" class=\"wp-image-225564\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-22-4.webp 707w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-22-4-300x123.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-22-4-150x62.webp 150w\" sizes=\"auto, (max-width: 707px) 100vw, 707px\"\/><\/figure>\n<\/div>\n<p>Tools Should Contain:<\/p>\n<ul class=\"wp-block-list\">\n<li><strong>A clear description<\/strong> explaining its purpose and functionality. <\/li>\n<li><strong>An executable component<\/strong> that carries out the intended action. <\/li>\n<li><strong>Defined arguments<\/strong> along with their data types for proper usage. <\/li>\n<li><strong>(Optional) Specified outputs<\/strong> with corresponding data types, if applicable.<\/li>\n<\/ul>\n<p>Let\u2019s create a simple tool:<\/p>\n<pre class=\"wp-block-code\"><code>def calculator(a: int, b: int) -&gt; int:\n    \"\"\"Multiply two integers.\"\"\"\n    return a * b<\/code><\/pre>\n<p>a and b are integers, and the output is a product of these two integers.<\/p>\n<p>Here\u2019s the string to understand it better:<\/p>\n<pre class=\"wp-block-preformatted\">Tool Name: calculator, Description: Multiply two integers., Arguments: a:<br\/>int, b: int, Outputs: int<\/pre>\n<p>Instead of focusing on how the tool is implemented, what truly matters is its name, functionality, expected inputs, and provided outputs. While we could use the Python source code as a specification for the tool in the LLM, the implementation details are irrelevant.<\/p>\n<p>To automate the process of generating a tool description, we will take advantage of Python\u2019s introspection capabilities. The key requirement is that the tool\u2019s implementation includes type hints, clear function names, and descriptive docstrings. Our approach involves writing a script to extract relevant details from the source code.<\/p>\n<p>Once the setup is complete, we only need to annotate the function with a Python decorator to designate it as a tool:<\/p>\n<pre class=\"wp-block-code\"><code>@tool\ndef calculator(a: int, b: int) -&gt; int:\n    \"\"\"Multiply two integers.\"\"\"\n    return a * b\n\nprint(calculator.to_string())<\/code><\/pre>\n<p>Here, the <code>@tool<\/code> decorator is placed above the function definition to mark it as a tool.<\/p>\n<p>Here\u2019s the string to understand it better:<\/p>\n<pre class=\"wp-block-preformatted\">Tool Name: calculator, Description: Multiply two integers., Arguments: a:<br\/>int, b: int, Outputs: int<\/pre>\n<p>The description is\u00a0<strong>injected<\/strong>\u00a0in the system prompt. Here is how it would look after replacing the\u00a0<code>tools_description<\/code>:<\/p>\n<pre class=\"wp-block-preformatted\">system_message=\"\"\"You are an AI assistant designed to help users efficiently<br\/>and accurately. Your<br\/>primary goal is to provide helpful, precise, and clear responses.<p>You have access to the following tools:<br\/>Tool Name: calculator, Description: Multiply two integers., Arguments:<br\/>a: int, b: int, Outputs: int<\/p><\/pre>\n<h2 class=\"wp-block-heading\" id=\"h-the-ai-agent-workflow\">The AI Agent Workflow<\/h2>\n<p>Here we will talk about the Thought-Action-Observation cycle of an AI Agent.<\/p>\n<ul class=\"wp-block-list\">\n<li><strong>Thought:<\/strong> The LLM component of the agent determines the next course of action. <\/li>\n<li><strong>Action:<\/strong> The agent performs the chosen action by using the appropriate tools with the required inputs. <\/li>\n<li><strong>Observation:<\/strong> The model analyzes the tool\u2019s response to decide the next steps.<\/li>\n<\/ul>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"450\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/AgentCycle.gif\" alt=\"LLM Thought Process\" class=\"wp-image-225442\"\/><\/figure>\n<p>These components work together in a continuous loop to generate an output with good efficiency. Many agent frameworks embed rules and guidelines in the system prompt, ensuring each cycle follows a set logic.<\/p>\n<p>A simplified version of our system prompt might be:<\/p>\n<pre class=\"wp-block-code\"><code>system_message=\"\"\"You are an AI assistant designed to help users efficiently and accurately. Your\nprimary goal is to provide helpful, precise, and clear responses.\n\nYou have access to the following tools:\nTool Name: calculator, Description: Multiply two integers., Arguments: a: int, b: int, Outputs: int\n\nYou should think step by step in order to fulfill the objective with a reasoning divided in\nThought\/Action\/Observation that can repeat multiple times if needed.\n\nYou should first reflect with \u2018Thought: {your_thoughts}\u2019 on the current situation,\nthen (if necessary), call a tool with the proper JSON formatting \u2018Action: {JSON_BLOB}\u2019, or your\nfinal answer starting with the prefix \u2018Final Answer:\u2019\n\"\"\"<\/code><\/pre>\n<p>Here we define:<\/p>\n<ul class=\"wp-block-list\">\n<li>Role and purpose of the AI Agent<\/li>\n<li>The available tools<\/li>\n<li>This enforces a <strong>structured reasoning process<\/strong> for the AI. It must break down tasks into logical steps:\n<ul class=\"wp-block-list\">\n<li><strong>Thought:<\/strong> Reflect on the problem.<\/li>\n<li><strong>Action:<\/strong> Execute an operation (if required).<\/li>\n<li><strong>Observation:<\/strong> Evaluate the outcome before proceeding.<br \/>This looping process ensures logical consistency and better decision-making.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Let\u2019s break it down with an example where an <strong>AI Agent retrieves the weather details of the Netherlands<\/strong> using the <strong>Thought\/Action\/Observation<\/strong> framework.<\/p>\n<p>Also read: <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2024\/10\/ai-agent-projects\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>5 AI Agent Projects to Try<\/strong><\/a><\/p>\n<h2 class=\"wp-block-heading\">Step-by-Step Execution in the AI Agent<\/h2>\n<h3 class=\"wp-block-heading\">1. System Message Setup<\/h3>\n<p>The system message (like the one in the image) defines:<\/p>\n<ul class=\"wp-block-list\">\n<li>The AI\u2019s role: To assist users effectively.<\/li>\n<li>Available tools: A weather API to fetch weather details.<\/li>\n<li>Thought\/Action\/Observation reasoning process.<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\">2. AI Agent in Action<\/h3>\n<h4 class=\"wp-block-heading\">Step 1: Thought<\/h4>\n<p>The AI first thinks about what needs to be done:<\/p>\n<p><strong>Thought:<\/strong> <em>I need to fetch the current weather details for the Netherlands. To do this, I should use the weather API tool and provide \u201cNetherlands\u201d as the location input.<\/em><\/p>\n<h4 class=\"wp-block-heading\">Step 2: Action<\/h4>\n<p>Since the AI has access to a tool (a weather API), it takes action by calling the tool.<\/p>\n<p><strong>Action:<\/strong><\/p>\n<pre class=\"wp-block-code\"><code>{\n  \"tool\": \"weather_api\",\n  \"arguments\": {\n    \"location\": \"Netherlands\"\n  }\n}\n<\/code><\/pre>\n<p>Here, the AI <strong>chooses the tool<\/strong> (weather API) and <strong>provides necessary arguments<\/strong> (location: Netherlands).<\/p>\n<h3 class=\"wp-block-heading\">Step 3: Observation<\/h3>\n<p>The AI receives a response from the tool (API), which includes weather details.<\/p>\n<p><strong>Observation:<\/strong><\/p>\n<pre class=\"wp-block-code\"><code>{\n  \"temperature\": \"12\u00b0C\",\n  \"condition\": \"Partly Cloudy\",\n  \"humidity\": \"78%\"\n}\n<\/code><\/pre>\n<p>The AI <strong>analyzes the response<\/strong> to ensure it\u2019s valid and complete.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-step-4-final-answer-reflecting\">Step 4: Final Answer\/Reflecting<\/h3>\n<p>Once the AI processes the response, it provides a final answer to the user.<\/p>\n<p><strong>Final Answer:<\/strong><br \/><em>\u201cThe current weather in the Netherlands is 12\u00b0C with partly cloudy skies and 78% humidity.\u201d<\/em><\/p>\n<h3 class=\"wp-block-heading\">Summary of the Process<\/h3>\n<ol class=\"wp-block-list\">\n<li><strong>Thought:<\/strong> AI determines it needs weather data for the Netherlands.<\/li>\n<li><strong>Action:<\/strong> Calls the weather API with \u201cNetherlands\u201d as input.<\/li>\n<li><strong>Observation:<\/strong> Receives and interprets the weather details.<\/li>\n<li><strong>Reflecting:<\/strong> Delivers the weather update to the user.<\/li>\n<\/ol>\n<h2 class=\"wp-block-heading\" id=\"h-the-re-act-approach\">The Re-Act Approach<\/h2>\n<p>The ReAct approach combines two key elements: <strong>Reasoning<\/strong> (thinking) and <strong>Acting<\/strong> (taking action).<\/p>\n<p>At its core, ReAct is a straightforward prompting method where the phrase \u201cLet\u2019s think step by step\u201d is added before the model begins generating responses. This simple addition guides the model to break down problems into smaller steps instead of jumping straight to a final answer.<\/p>\n<p>By encouraging a step-by-step reasoning process, the model is more likely to develop a structured plan rather than making an immediate guess. This breakdown of tasks helps in analyzing each part in detail, ultimately reducing errors compared to directly predicting the final solution.<\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1070\" height=\"598\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-23.png\" alt=\"Re-Act Approach\" class=\"wp-image-225445\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-23.png 1070w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-23-300x168.png 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-23-768x429.png 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/03\/image-23-150x84.png 150w\" sizes=\"auto, (max-width: 1070px) 100vw, 1070px\"\/><\/figure>\n<p>Now in this course, I have used the SmolAgents framework by Hugging Face, which processes with Code Agent.<\/p>\n<figure class=\"wp-block-table\">\n<table class=\"has-fixed-layout\">\n<thead>\n<tr>\n<th>Type of Agent<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>JSON Agent<\/td>\n<td>The Action to take is specified in JSON format.<\/td>\n<\/tr>\n<tr>\n<td>Code Agent<\/td>\n<td>The Agent writes a code block that is interpreted externally.<\/td>\n<\/tr>\n<tr>\n<td>Function-calling Agent<\/td>\n<td>It is a subcategory of the JSON Agent which has been fine-tuned to generate a new message for each action.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>To understand the code agent, check out this article: <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2025\/01\/smolagents\/\" target=\"_blank\" rel=\"noreferrer noopener\">SmolAgents by Hugging Face: Build AI Agents in Less than 30 Lines<\/a><\/p>\n<p>You can also build an Agent from scratch:<\/p>\n<pre class=\"wp-block-code\"><code>system\nAnswer the following questions as best you can. You have access to the following tools:\n\nget_weather: Get the current weather in a given location\n\nThe way you use the tools is by specifying a json blob.\nSpecifically, this json should have a `action` key (with the name of the tool to use) and a `action_input` key (with the input to the tool going here).\n\nThe only values that should be in the \"action\" field are:\nget_weather: Get the current weather in a given location, args: {\"location\": {\"type\": \"string\"}}\nexample use :\n```\n{{\n  \"action\": \"get_weather\",\n  \"action_input\": {\"location\": \"New York\"}\n}}\n\nALWAYS use the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about one action to take. Only one action at a time in this format:\nAction:\n```\n$JSON_BLOB\n```\nObservation: the result of the action. This Observation is unique, complete, and the source of truth.\n... (this Thought\/Action\/Observation can repeat N times, you should take several steps when needed. The $JSON_BLOB must be formatted as markdown and only use a SINGLE action at a time.)\n\nYou must always end your output with the following format:\n\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question\n\nNow begin! Reminder to ALWAYS use the exact characters `Final Answer:` when you provide a definitive answer. \nuser\nWhat's the weither in London ?\nassistant\nQuestion: What's the weather in London?\n\nAction:\n```\n{\n  \"action\": \"get_weather\",\n  \"action_input\": {\"location\": \"London\"}\n}\n```\nObservation:the weather in London is sunny with low temperatures. <\/code><\/pre>\n<p>Here\u2019s the new prompt: <\/p>\n<pre class=\"wp-block-code\"><code>final_output = client.text_generation(\n    new_prompt,\n    max_new_tokens=200,\n)\n\nprint(final_output)<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-output-3\">Output<\/h3>\n<pre class=\"wp-block-preformatted\">Final Answer: The weather in London is sunny with low temperatures.<\/pre>\n<p><em>To understand it better, check out this notebook: <a href=\"https:\/\/huggingface.co\/agents-course\/notebooks\/blob\/main\/dummy_agent_library.ipynb\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Agentfromscratch.ipynb<\/a><\/em><\/p>\n<h2 class=\"wp-block-heading\" id=\"h-ai-agent-using-smolagents\">AI Agent Using SmolAgents<\/h2>\n<p>Here\u2019s the News Agent I have built using SmolAgents with Gradio UI<\/p>\n<pre class=\"wp-block-code\"><code>from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel,load_tool, tool\nimport datetime\nimport requests\nimport pytz\nimport yaml\nfrom tools.final_answer import FinalAnswerTool\n\nfrom Gradio_UI import GradioUI\n\n\n@tool\ndef get_news_headlines() -&gt; str:\n    \"\"\"\n    Fetches the top news headlines from the News API for India.\n    This function makes a GET request to the News API to retrieve the top news headlines\n    for India. It returns the titles and sources of the top 5 articles as a\n    formatted string. If no articles are available, it returns a message indicating that\n    no news is available. In case of a request error, it returns an error message.\n    Returns:\n        str: A \n        containing the top 5 news headlines and their sources, or an error message.\n    \"\"\"\n    api_key = \"Your_API_key\"\n\n    sources = \"google-news-in\"\n    name = \"Google News (India)\"\n    description = \"Comprehensive, up-to-date India news coverage, aggregated from sources all over the world by Google News.\",\n    URL = \"https:\/\/news.google.com\",\n    language = \"en\"  # Define language before using it\n\n    url = f\"https:\/\/newsapi.org\/v2\/everything?q=&amp;sources={sources}&amp;language={language}&amp;apiKey={api_key}\"\n\n    try:\n        response = requests.get(url)\n        response.raise_for_status()\n\n        data = response.json()\n        articles = data[\"articles\"]\n\n        if not articles:\n            return \"No news available at the moment.\"\n\n        headlines = [f\"{article['title']} - {article['source']['name']}\" for article in articles[:5]]\n        return \"\\n\".join(headlines)\n\n    except requests.exceptions.RequestException as e:\n        return f\"Error fetching news data: {str(e)}\"\n\nfinal_answer = FinalAnswerTool()\n\n# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:\n# model_id='https:\/\/pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud' \n\nmodel = HfApiModel(\nmax_tokens=2096,\ntemperature=0.5,\nmodel_id='Qwen\/Qwen2.5-Coder-32B-Instruct',\ncustom_role_conversions=None,\n)\n\nwith open(\"prompts.yaml\", 'r') as stream:\n    prompt_templates = yaml.safe_load(stream)\n    \nagent = CodeAgent(\n    model=model,\n    tools=[get_news_headlines, DuckDuckGoSearchTool()], ## add your tools here (don't remove final answer)\n    max_steps=6,\n    verbosity_level=1,\n    grammar=None,\n    planning_interval=None,\n    name=None,\n    description=None,\n)\n\nGradioUI(agent).launch()<\/code><\/pre>\n<p>Here\u2019s the Space on Hugging Face to check the working: <a href=\"https:\/\/huggingface.co\/spaces\/Neuralsingh123\/First_agent_template\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Neuralsingh123<\/a><\/p>\n<p>You can also create a basic agent like this \u2013 To start, duplicate this Space:\u00a0<a href=\"https:\/\/huggingface.co\/spaces\/agents-course\/First_agent_template\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/huggingface.co\/spaces\/agents-course\/First_agent_template<\/a><\/p>\n<p>After duplicating the space, add your Hugging Face API token so your agent can access the model API:<\/p>\n<ul class=\"wp-block-list\">\n<li>If you haven\u2019t already, get your Hugging Face token by visiting <a href=\"https:\/\/hf.co\/settings\/tokens\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Hugging Face Tokens<\/a>. Make sure it has inference permissions.<\/li>\n<li>Open your duplicated Space and navigate to the Settings tab.<\/li>\n<li>Scroll down to the Variables and Secrets section and select New Secret.<\/li>\n<li>Enter <strong>HF_TOKEN<\/strong> as the name and paste your token in the value field. <\/li>\n<li>Click <strong>Save<\/strong> to securely store your token.<\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n<p>The <a href=\"https:\/\/huggingface.co\/learn\/agents-course\/en\/unit0\/introduction\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Hugging Face AI Agents Course<\/a> provides a comprehensive introduction to AI Agents, covering their theoretical foundations, design, and practical applications. Throughout this article, we\u2019ve explored key concepts such as AI Agent workflows, the role of Large Language Models (LLMs), the importance of tools, and how agents interact with their environment using structured decision-making (Think \u2192 Act \u2192 Observe).<\/p>\n<p>In practical implementation, we explored frameworks like <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2025\/01\/agentic-rag-with-smolagents\/\" target=\"_blank\" rel=\"noreferrer noopener\">SmolAgents<\/a>, where we built an AI-powered News Agent using Hugging Face\u2019s models and tools. This showcases how AI Agents can be developed efficiently with minimal code while still offering robust functionality.<\/p>\n<h4 class=\"wp-block-heading\">What\u2019s Next?<\/h4>\n<p>In the next article, I will be diving deeper into SmolAgents, LangChain, and LangGraph, exploring how they enhance AI Agent capabilities and simplify agent-based workflows. Stay tuned for insights on building more powerful and flexible AI Agents!<\/p>\n<p><em>If you want to learn how to build these agents then consider enrolling in our exclusive\u00a0<a href=\"https:\/\/www.analyticsvidhya.com\/agenticaipioneer\/?utm_source=blog_page&amp;utm_medium=blog&amp;utm_campaign=SEO\" target=\"_blank\" rel=\"noreferrer noopener\">Agentic AI Pioneer Program<\/a>!<\/em><\/p>\n<div class=\"border-top py-3 author-info my-4\">\n<div class=\"author-card d-flex align-items-center\">\n<div class=\"flex-shrink-0 overflow-hidden\">\n                                    <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/author\/pankaj9786\/\" class=\"text-decoration-none active-avatar\"><br \/>\n                                                                       <img decoding=\"async\" src=\"https:\/\/av-eks-lekhak.s3.amazonaws.com\/media\/lekhak-profile-images\/converted_image_Lb7Lh0T.webp\" width=\"48\" height=\"48\" alt=\"Pankaj Singh\" loading=\"lazy\" class=\"rounded-circle\"\/><\/p>\n<p>                                <\/a>\n                                <\/div>\n<\/p><\/div>\n<p>                Hi, I am Pankaj Singh Negi &#8211; Senior Content Editor | Passionate about storytelling and crafting compelling narratives that transform ideas into impactful content. I love reading about technology revolutionizing our lifestyle.                 <\/p>\n<\/p><\/div>\n<\/p><\/div>\n<p><h4 class=\"fs-24 text-dark\">Login to continue reading and enjoy expert-curated content.<\/h4>\n<p>                        <button class=\"btn btn-primary mx-auto d-table\" data-bs-toggle=\"modal\" data-bs-target=\"#loginModal\" id=\"readMoreBtn\">Keep Reading for Free<\/button>\n                    <\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>Recently, I came across this Hugging Face AI Agents Course, where you can study AI Agents in theory, design and practice. For this course, you will be required to have a computer system and a Hugging Face account (bare minimum). The course is quite detailed and it will help you build a solid foundation in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":123937,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12033],"tags":[3038,10243,844,15052,1820],"dealstore":[],"offerexpiration":[],"class_list":["post-123936","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-analytics","tag-agent","tag-built","tag-face","tag-hugging","tag-news"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>I Have Built A News Agent on Hugging Face - Som2ny Network<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fivemor.com\/?p=123936\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"I Have Built A News Agent on Hugging Face - Som2ny Network\" \/>\n<meta property=\"og:description\" content=\"Recently, I came across this Hugging Face AI Agents Course, where you can study AI Agents in theory, design and practice. For this course, you will be required to have a computer system and a Hugging Face account (bare minimum). The course is quite detailed and it will help you build a solid foundation in [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fivemor.com\/?p=123936\" \/>\n<meta property=\"og:site_name\" content=\"Som2ny Network\" \/>\n<meta property=\"article:published_time\" content=\"2025-03-10T10:35:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/Hugging-face-1.webp.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"872\" \/>\n\t<meta property=\"og:image:height\" content=\"473\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"28 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fivemor.com\/?p=123936#article\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/?p=123936\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\"},\"headline\":\"I Have Built A News Agent on Hugging Face\",\"datePublished\":\"2025-03-10T10:35:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=123936\"},\"wordCount\":4391,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=123936#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/Hugging-face-1.webp.webp\",\"keywords\":[\"Agent\",\"Built\",\"Face\",\"Hugging\",\"NEWS\"],\"articleSection\":[\"Analytics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fivemor.com\/?p=123936#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fivemor.com\/?p=123936\",\"url\":\"https:\/\/fivemor.com\/?p=123936\",\"name\":\"I Have Built A News Agent on Hugging Face - Som2ny Network\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=123936#primaryimage\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=123936#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/Hugging-face-1.webp.webp\",\"datePublished\":\"2025-03-10T10:35:07+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fivemor.com\/?p=123936#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fivemor.com\/?p=123936\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/?p=123936#primaryimage\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/Hugging-face-1.webp.webp\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/Hugging-face-1.webp.webp\",\"width\":872,\"height\":473},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fivemor.com\/?p=123936#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/fivemor.com\/?bp_activities=1\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"I Have Built A News Agent on Hugging Face\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fivemor.com\/#website\",\"url\":\"https:\/\/fivemor.com\/\",\"name\":\"Som2ny Network\",\"description\":\"Daily Deals\",\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fivemor.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/fivemor.com\/#organization\",\"name\":\"Som2ny Network\",\"url\":\"https:\/\/fivemor.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png\",\"width\":300,\"height\":86,\"caption\":\"Som2ny Network\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png\",\"caption\":\"admin\"},\"sameAs\":[\"https:\/\/fivemor.com\"],\"url\":\"https:\/\/fivemor.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"I Have Built A News Agent on Hugging Face - Som2ny Network","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fivemor.com\/?p=123936","og_locale":"en_US","og_type":"article","og_title":"I Have Built A News Agent on Hugging Face - Som2ny Network","og_description":"Recently, I came across this Hugging Face AI Agents Course, where you can study AI Agents in theory, design and practice. For this course, you will be required to have a computer system and a Hugging Face account (bare minimum). The course is quite detailed and it will help you build a solid foundation in [&hellip;]","og_url":"https:\/\/fivemor.com\/?p=123936","og_site_name":"Som2ny Network","article_published_time":"2025-03-10T10:35:07+00:00","og_image":[{"width":872,"height":473,"url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/Hugging-face-1.webp.webp","type":"image\/webp"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"28 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fivemor.com\/?p=123936#article","isPartOf":{"@id":"https:\/\/fivemor.com\/?p=123936"},"author":{"name":"admin","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371"},"headline":"I Have Built A News Agent on Hugging Face","datePublished":"2025-03-10T10:35:07+00:00","mainEntityOfPage":{"@id":"https:\/\/fivemor.com\/?p=123936"},"wordCount":4391,"commentCount":0,"publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"image":{"@id":"https:\/\/fivemor.com\/?p=123936#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/Hugging-face-1.webp.webp","keywords":["Agent","Built","Face","Hugging","NEWS"],"articleSection":["Analytics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fivemor.com\/?p=123936#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fivemor.com\/?p=123936","url":"https:\/\/fivemor.com\/?p=123936","name":"I Have Built A News Agent on Hugging Face - Som2ny Network","isPartOf":{"@id":"https:\/\/fivemor.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fivemor.com\/?p=123936#primaryimage"},"image":{"@id":"https:\/\/fivemor.com\/?p=123936#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/Hugging-face-1.webp.webp","datePublished":"2025-03-10T10:35:07+00:00","breadcrumb":{"@id":"https:\/\/fivemor.com\/?p=123936#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fivemor.com\/?p=123936"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/?p=123936#primaryimage","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/Hugging-face-1.webp.webp","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/Hugging-face-1.webp.webp","width":872,"height":473},{"@type":"BreadcrumbList","@id":"https:\/\/fivemor.com\/?p=123936#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fivemor.com\/?bp_activities=1"},{"@type":"ListItem","position":2,"name":"I Have Built A News Agent on Hugging Face"}]},{"@type":"WebSite","@id":"https:\/\/fivemor.com\/#website","url":"https:\/\/fivemor.com\/","name":"Som2ny Network","description":"Daily Deals","publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fivemor.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/fivemor.com\/#organization","name":"Som2ny Network","url":"https:\/\/fivemor.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/#\/schema\/logo\/image\/","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png","width":300,"height":86,"caption":"Som2ny Network"},"image":{"@id":"https:\/\/fivemor.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png","caption":"admin"},"sameAs":["https:\/\/fivemor.com"],"url":"https:\/\/fivemor.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/123936","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=123936"}],"version-history":[{"count":0,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/123936\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/media\/123937"}],"wp:attachment":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=123936"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=123936"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=123936"},{"taxonomy":"dealstore","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdealstore&post=123936"},{"taxonomy":"offerexpiration","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fofferexpiration&post=123936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}