<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Akash Modi on Medium]]></title>
        <description><![CDATA[Stories by Akash Modi on Medium]]></description>
        <link>https://medium.com/@akash-modi?source=rss-c608b86d080f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*W8EFmUCFcWspXV_7gK4ULQ.png</url>
            <title>Stories by Akash Modi on Medium</title>
            <link>https://medium.com/@akash-modi?source=rss-c608b86d080f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 01:18:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akash-modi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Docling — An OpenSource python library for PDF Parsing | OCR Support | RAG | IBM Research]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://pub.towardsai.net/docling-an-opensource-python-library-for-pdf-parsing-ocr-support-rag-ibm-research-fe6177235329?source=rss-c608b86d080f------2"><img src="https://cdn-images-1.medium.com/max/2048/1*X9PdCM5R094vIEnx6MDt3g.png" width="2048"></a></p><p class="medium-feed-snippet">Locally Parses reading formats such as PDF, DOCX, PPTX, Images, HTML, AsciiDoc and converts them to Markdown or JSON format using GPUs &amp;&#x2026;</p><p class="medium-feed-link"><a href="https://pub.towardsai.net/docling-an-opensource-python-library-for-pdf-parsing-ocr-support-rag-ibm-research-fe6177235329?source=rss-c608b86d080f------2">Continue reading on Towards AI »</a></p></div>]]></description>
            <link>https://pub.towardsai.net/docling-an-opensource-python-library-for-pdf-parsing-ocr-support-rag-ibm-research-fe6177235329?source=rss-c608b86d080f------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe6177235329</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[ibm]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[pdf]]></category>
            <dc:creator><![CDATA[Akash Modi]]></dc:creator>
            <pubDate>Thu, 21 Nov 2024 15:13:52 GMT</pubDate>
            <atom:updated>2024-11-22T10:20:36.797Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Data Query & Visualisation using LLM Agents from Scratch]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://pub.towardsai.net/data-query-visualisation-using-llm-agents-from-scratch-098c85905179?source=rss-c608b86d080f------2"><img src="https://cdn-images-1.medium.com/max/1923/1*TCtHTBudMoV3ltvrsLlHNQ.png" width="1923"></a></p><p class="medium-feed-snippet">Building a simple data analysis &amp; plotting engine using LLaMa and LangChain Agentic Framework with Structured Data</p><p class="medium-feed-link"><a href="https://pub.towardsai.net/data-query-visualisation-using-llm-agents-from-scratch-098c85905179?source=rss-c608b86d080f------2">Continue reading on Towards AI »</a></p></div>]]></description>
            <link>https://pub.towardsai.net/data-query-visualisation-using-llm-agents-from-scratch-098c85905179?source=rss-c608b86d080f------2</link>
            <guid isPermaLink="false">https://medium.com/p/098c85905179</guid>
            <category><![CDATA[agents]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[langchain]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Akash Modi]]></dc:creator>
            <pubDate>Fri, 25 Oct 2024 20:01:43 GMT</pubDate>
            <atom:updated>2024-10-26T10:11:55.207Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Logical Reasoning with ReAct Agent from Scratch in Python: Part 2]]></title>
            <link>https://medium.com/@akash-modi/logical-reasoning-with-react-agent-from-scratch-in-python-part-2-b74ef462244b?source=rss-c608b86d080f------2</link>
            <guid isPermaLink="false">https://medium.com/p/b74ef462244b</guid>
            <category><![CDATA[agents]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[machine-learning-ai]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Akash Modi]]></dc:creator>
            <pubDate>Sat, 05 Oct 2024 17:09:14 GMT</pubDate>
            <atom:updated>2024-10-05T18:08:08.504Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Going Beyond Prompts: Advanced AI Systems for logical Reasoning</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*eBqJo2DgZaBgPjil3eGLmQ.png" /></figure><p>In this notebook, we will build a simple LLM (Large Language Model) Agent that tackles logical reasoning questions using only Python. Through this process, you will gain insight into the <strong>Agentic framework</strong>, with a specific focus on one of the most widely used agents — <strong>ReAct (Reasoning and Acting)</strong> agents. By the end of this notebook, you will have successfully created a ReAct Agent from scratch using Python, while also developing a foundational understanding of how agents function. This knowledge will serve as a stepping stone toward mastering more advanced agentic concepts such as <strong>Autonomous Agents</strong>, <strong>Large Multimodal Agents</strong>, and more.</p><h4>Prerequisites:</h4><p>** If you have basic understanding of the concepts such as <strong><em>the Chain of Thoughts, Agents, React Agents, output parsers etc </em></strong>then you can directly proceed this article for the code implementation and skip Part — 1 **</p><p>But for complete understanding of the basic concepts such as <strong><em>the Chain of Thoughts, Agents, React Agents</em></strong> and other tools used in this article, please read the Part 1 of this article.</p><blockquote><a href="https://medium.com/@akash-modi/logical-reasoning-with-react-agent-from-scratch-in-python-part-1-60bda6b182af"><strong><em>Logical-reasoning-with-react-agent-from-scratch-in-python-part-1</em></strong></a></blockquote><h3>Lets continue with the code Implementation ……</h3><p>Installing the needed packages:</p><pre>%pip install langchain_groq<br>%pip install python-dotenv<br>%pip install langchain</pre><h4>Importing packages &amp; loading .env variable</h4><blockquote>Please set “GROQ_API_KEY” environment variable which we created before in a .env file in same folder as the notebook</blockquote><pre>from langchain_core.prompts import PromptTemplate<br>from langchain_groq import ChatGroq<br>import math<br><br>from dotenv import load_dotenv<br>load_dotenv()</pre><h4>Prompt Creation</h4><p>Below is a modified version of the prompt derived from one of LangChain’s actual ReAct Prompt Templates (available at “<a href="https://smith.langchain.com/hub/hwchase17/react">https://smith.langchain.com/hub/hwchase17/react</a>&quot;).</p><blockquote>The example prompt provided here is intentionally simple and meant for demonstration purposes.</blockquote><pre>template = &#39;&#39;&#39;Answer the following questions as best you can. <br>You have access to the following tools:{tools}<br>Use the following format strictly:<br>Question: the input question you must answer. Do not repeat this.<br>Thought: you should always think about what to do<br>Action: the action to take, should be one of [{tool_names}]<br>Action Input: the input to the action comma seperated<br>Then return &quot;PAUSE&quot;. Do not perform any action on your own.<br>Observation: the result of the action<br>... (this Thought/Action/Action Input/PAUSE/Observation can repeat N times)<br>Thought: I now know the final answer<br>Final Answer: the final answer to the original input question<br>Begin!<br>Question: {input}<br>Thought: {agent_scratchpad}&#39;&#39;&#39;<br>prompt = PromptTemplate.from_template(template)</pre><p>In this prompt, the LLM is first instructed to think through the problem in a manner similar to how we approach real-world reasoning questions. It is then tasked with identifying the next best action along with the necessary action parameters. After that, the model pauses to allow the action to be completed before proceeding. This structure enables the agent to methodically tackle complex problems and ensure that each step is executed effectively.</p><blockquote>Here **<strong>ACTION</strong>** is the step that identifies the external tool to use, based on the tool descriptions given to it in the prompt as <strong>{tools}</strong>.</blockquote><p>Once the action is completed, the prompt treats the results as <strong><em>OBSERVATION</em></strong> and prompts the reasoning model to share its thoughts again. This cycle continues until the model determines that it has reached the final answer. By iterating through this process, the agent refines its reasoning and adapts its approach based on new information, leading to a more accurate and thoughtful conclusion.</p><blockquote>Note: Here Agent is using <strong><em>{agent_scratchpad} </em></strong>as the memory of the model to store all the previous iterations of the Thought, Action, Observation</blockquote><h4>Custom Output Parser by LangChain</h4><pre>#this code is demonstrates the use of custom LLM output parsher<br>from langchain_core.messages import AIMessage<br>def parse(ai_message: AIMessage) -&gt; str:<br>    &quot;&quot;&quot;Parse the AI message.&quot;&quot;&quot;<br>    result = ai_message.content<br>    if result.lower().startswith(&quot;thought&quot;):<br>        result = result[8:].strip()<br>    #print(result)<br>    return result</pre><h4>Tools</h4><p>Sample calculator tool that uses different mathematical functions such as addition, subtraction, multiplication, division , power, log etc</p><pre># Advanced calculator in Python<br># Function to perform addition<br>def add(x, y):<br>    return x + y<br># Function to perform subtraction<br>def subtract(x, y):<br>    return x - y<br># Function to perform multiplication<br>def multiply(x, y):<br>    return x * y<br># Function to perform division<br>def divide(x, y):<br>    if y == 0:<br>        return &quot;Error! Division by zero.&quot;<br>    else:<br>        return x / y<br># Function to perform power calculation (x^y)<br>def power(x, y):<br>    return math.pow(x, y)<br># Function to calculate square root<br>def square_root(x):<br>    if x &lt; 0:<br>        return &quot;Error! Negative number cannot have a real square root.&quot;<br>    return math.sqrt(x)<br># Function to calculate logarithm (base 10)<br>def logarithm(x):<br>    if x &lt;= 0:<br>        return &quot;Error! Logarithm undefined for zero or negative numbers.&quot;<br>    return math.log10(x)<br># Function to calculate sine of an angle (in degrees)<br>def sine(x):<br>    return math.sin(math.radians(x))<br># Function to calculate cosine of an angle (in degrees)<br>def cosine(x):<br>    return math.cos(math.radians(x))<br># Function to calculate tangent of an angle (in degrees)<br>def tangent(x):<br>    return math.tan(math.radians(x))<br>def calculate(operator, **args):<br>    if &quot;y&quot; in args:<br>        return eval(f&quot;{operator}({args[&#39;x&#39;]}, {args[&#39;y&#39;]})&quot;)<br>    else:<br>        return eval(f&quot;{operator}({args[&#39;x&#39;]})&quot;)</pre><h4>Defining tools that can be consumed by Agents</h4><pre>#{tool_desc} provides the LLM with information about the available tools, <br># enabling it to make informed choices when taking action based on its <br># thoughts.<br><br>tool_desc = f&quot;calculate: this tool is useful for calculating the mathematical <br>              expressions such as add, subtract, divide, multiply, power, <br>              square_root, sine, cosine, tagent. this tool expects the <br>              operation needed and the numbers are parameters&quot; <br><br>def call_tools(tool, args):<br>    func = args[&#39;func&#39;]<br>    del args[&#39;func&#39;]<br>    observation = eval(f&#39;{tool}(&quot;{func}&quot;, **args)&#39;)<br>    return observation</pre><p>This code block illustrates how to make the previously defined calculator functions accessible as a parameterised tool for the LLM. By executing this code, you can invoke various mathematical operations using the call_tools function, where you pass the function name along with the relevant parameters.</p><ul><li>Example — call_tools(“calculate”, {func=’add’, x=10, y=20})</li></ul><h4>LLM Model Using GROQ</h4><pre>import os<br><br>client = ChatGroq(<br>    groq_api_key=os.environ.get(&quot;GROQ_API_KEY&quot;),<br>    model_name=&#39;llama-3.1-70b-versatile&#39;<br>)</pre><h3>Processing of the LLM text response</h3><p>This code block processes the LLM’s response by checking for the presence of the phrase “final answer” to determine if the final solution has been identified.</p><ul><li>If the final answer is found, it returns the parsed response.</li><li>If not, it parses the response to identify the appropriate tool to be called, along with the necessary parameters for execution.</li></ul><p>This approach ensures that the agent either retrieves the final solution or performs an intermediate action using a tool to advance toward solving the problem.</p><pre>def post_process_response(result):<br>    lines = result.split(&quot;\n&quot;)<br>    tool,  parameters = None, None<br>    answer_found = False<br>    for line in lines:<br>        if len(line)&gt; 0:<br>            if line.lower().startswith(&quot;thought&quot;):<br>                continue<br>            elif line.lower().startswith(&quot;final answer:&quot;):<br>                answer_found = True<br>                return answer_found, line.split(&quot;:&quot;)[-1].strip()<br>            elif line.lower().startswith(&quot;action:&quot;):<br>                tool = line.split(&quot;:&quot;)[-1].strip()<br>            elif line.lower().startswith(&quot;action input:&quot;):<br>                parameters = line.split(&quot;:&quot;)[-1].strip()<br>    <br>    if tool is None:<br>        raise Exception(&quot;tool not detected by model&quot;)<br>    <br>    if parameters is None:<br>        raise Exception(&quot;paramters not detected by model&quot;)<br>    else:<br>        params_list = parameters.split(&quot;,&quot;)<br>        func = params_list[0].strip()<br>        args = {}<br>        args[&quot;func&quot;] = func<br>        args[&quot;x&quot;] = params_list[1].strip()<br>        if len(params_list)&gt;2:<br>            args[&quot;y&quot;]=params_list[2].strip()  <br>    <br>    return answer_found, (tool, args)</pre><h4>ReAct Agent Definition</h4><p>In the code block below, we initiate and define the ReAct Agent. A chain is created to call the LLM model using the specified prompt template. The chain is executed in a loop until either the final answer is reached or the maximum iteration limit is met.</p><p>During each iteration, the model goes through the steps of <strong>Thought, Action, Pause, and Observation</strong> to determine the next course of action.</p><pre>def myAgent(query):<br>    agent_scratchpad = &quot;&quot;<br>    chain = prompt | client | parse<br>    count, max_loop = 0, 10 <br>    print(&quot;Thought: &quot;, end=&quot; &quot;)<br><br>    while count&lt;max_loop:<br>        req = chain.invoke({&quot;input&quot;:query, &quot;tools&quot;:tool_desc, &quot;tool_names&quot;: &quot;calculate&quot;, &quot;agent_scratchpad&quot; : agent_scratchpad})<br>        #print(req, end =&quot; &quot;)<br>        answer_found, response = post_process_response(req)<br>        if answer_found:<br>            agent_scratchpad = f&quot;{agent_scratchpad}{req}&quot;<br>            return response, agent_scratchpad<br>        else:<br>            observation = call_tools(response[0], response[1])<br>            #print(f&quot;\nObervation: {observation}\nThought:&quot;, end=&quot; &quot;)<br>            agent_scratchpad = f&quot;{agent_scratchpad}{req}\nObervation: {observation}\nThought:&quot;<br>        count+=1  </pre><blockquote>Note: This is a basic implementation of the ReAct Agent designed for demonstration and learning purposes. It illustrates the agent’s core functionality while keeping the process straightforward for beginners.</blockquote><h3>Finally bringing it all together ..</h3><p>Very basic math example to test whether the components are functioning correctly or Not.</p><pre>query = &quot;I wanna add 2 and 3 then divide by 7. finaly getting the square of it&quot;<br><br>res, agent_scratchpad = myAgent(query=query)<br>print(agent_scratchpad)</pre><h4>Output:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*S9HuO6KxA9L1zm-30hG15w.png" /></figure><p>It looks line our Agent is working fine and gave correct output.</p><p>Lets Try with a difficult Logical Reasoning Question:</p><pre>query = &quot;Alfred buys an old scooter for Rs. 4700 and spends Rs. 800 on its repairs. If he sells the scooter for Rs. 5800, his gain percent is:&quot;<br>res, agent_scratchpad = myAgent(query=query)<br>print(agent_scratchpad)</pre><h4>Output:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*Yq8DyvyOBWnl18rPB2fcOg.png" /></figure><h4>Yaay!!!!! Our agent is working great with some difficult Questions.</h4><h3>Conclusion</h3><p>AI agents are increasingly becoming the focal point in the field of artificial intelligence, and they are regarded as the next key area of interest for OpenAI.</p><p>This article provides you with basic understanding of ReAct Agentic Framework and also helps with a very simple implementation using python and not Framework such as LangChain &amp; CrewAI. Once you have proper understanding of the agents now you can proceed with advanced topics like Multi-Model Agents, Agentic RAG etc which we are going to cover soon.</p><blockquote>For complete running notebook you can visit my GitHub Repo — <a href="https://github.com/furious-dev/Langchain-tutorial/blob/main/agents_from_scratch.ipynb">https://github.com/furious-dev/Langchain-tutorial/blob/main/agents_from_scratch.ipynb</a></blockquote><p>Thanks for sticking around for this long and completing the implementation. I hope you had some great learning experience.</p><blockquote><strong>If you like this Article, please follow me for more of such articles.</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b74ef462244b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Logical Reasoning with ReAct Agent from Scratch in Python: Part 1]]></title>
            <link>https://medium.com/@akash-modi/logical-reasoning-with-react-agent-from-scratch-in-python-part-1-60bda6b182af?source=rss-c608b86d080f------2</link>
            <guid isPermaLink="false">https://medium.com/p/60bda6b182af</guid>
            <category><![CDATA[react-agent]]></category>
            <category><![CDATA[llm-agent]]></category>
            <category><![CDATA[langchain]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <dc:creator><![CDATA[Akash Modi]]></dc:creator>
            <pubDate>Sat, 05 Oct 2024 16:26:53 GMT</pubDate>
            <atom:updated>2024-10-05T18:25:35.096Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Going Beyond Prompts: Advanced AI Systems for logical Reasoning</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*eBqJo2DgZaBgPjil3eGLmQ.png" /></figure><p>In this notebook, we will build a simple LLM (Large Language Model) Agent that tackles logical reasoning questions using only Python. Through this process, you will gain insight into the <strong>Agentic framework</strong>, with a specific focus on one of the most widely used agents — <strong>ReAct (Reasoning and Acting)</strong> agents. By the end of this notebook, you will have successfully created a ReAct Agent from scratch using Python, while also developing a foundational understanding of how agents function. This knowledge will serve as a stepping stone toward mastering more advanced agentic concepts such as <strong>Autonomous Agents</strong>, <strong>Large Multimodal Agents</strong>, and more.</p><p>Note: If you have basic understanding of the concepts such as <strong><em>the Chain of Thoughts, Agents, React Agents, output parsers etc </em></strong>then you can skip Part — 1 and go to Part-2 which has the Code Implementation of ReAct Agent.</p><blockquote><a href="https://medium.com/@akash-modi/logical-reasoning-with-react-agent-from-scratch-in-python-part-2-b74ef462244b"><strong>Logical-reasoning-with-react-agent-from-scratch-in-python-part-2</strong></a></blockquote><h3><strong>Introduction</strong></h3><p>Let’s begin by exploring the fundamental concepts of the chain of thoughts, reasoning, and acting, which form the foundation for understanding agents.</p><h4>Chain of Thoughts</h4><p>Chain of Thought (CoT) is a technique that enables LLMs to tackle complex reasoning tasks by deconstructing the problem into a sequence of intermediate steps. This approach serves as a roadmap for the LLM, guiding it through the process rather than merely providing the end goal</p><blockquote>The <strong>Chain of Thoughts</strong> concept is integral to the functioning of intelligent agents, as it outlines the sequential process through which an agent analyzes information and arrives at conclusions.</blockquote><p>If you want to dive deeper in the concept of chain of thought, you can refer the paper where all of it started : “<a href="https://arxiv.org/abs/2201.11903">Chain-of-Thought Prompting Elicits Reasoning in Large Language Models</a>”</p><p>You can also read more about it in the Article : “<a href="https://medium.com/@pankaj_pandey/chain-of-thought-prompting-guiding-llms-step-by-step-e6eac32d02d8">Chain of Thought Prompting: Guiding LLMs Step-by-Step</a>” for quick recap.</p><h4>Agents</h4><blockquote>An <strong>LLM Agent</strong> is a smart system that uses advanced models to think, understand and then process queries. It can handle tasks that involve thinking and making decisions based on what it understands, allowing it to interact with users in a natural and meaningful way.</blockquote><p>Real-world tasks rarely have simple, one-step solutions. Instead, they typically involve a series of interconnected and independent steps that must be completed to achieve the desired outcome.</p><blockquote>Example: What were the major points of discussion in UNSECO summit this year?</blockquote><p>Now this question cannot be answered directly. First LLM has to find the current year, then get the discussion points and then summarise it into points before providing the final answers. We as humans will also follow the same steps right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*07lsjh7W8WZDC45bXH3wpw.png" /></figure><p>The figures above illustrate the core capabilities of an agent.</p><ul><li><strong>Tools — </strong>Agents have the ability to connect with a wide range of external tools, such as internet searches, database queries, program functions, APIs, and more. This capability significantly enhances the agent’s power, enabling it to perform diverse tasks beyond its core functionality.</li><li><strong>Thinking &amp; Planning</strong> — Unlike most LLMs, agents have the ability to analyze a query, think critically about it, and then plan the necessary steps to solve it. This strategic approach enables agents to handle more complex and multi-step tasks effectively.</li><li><strong>Memory</strong> — Agents possess both short-term and long-term memory, allowing them to store intermediate results and retrieve them when necessary. This capability makes agents more flexible, enabling them to handle ongoing tasks, adapt to changing conditions, and recall information across different stages of problem-solving.</li><li><strong>Pre-trained knowledge</strong> — Lastly, agents harness the power of large language models (LLMs), benefiting from advanced language understanding and access to vast amounts of pre-trained data. This enables them to comprehend complex queries and provide intelligent, context-aware responses.</li></ul><p>To dive further deep into Agents you can go through article— <a href="https://medium.com/@aydinKerem/what-is-an-llm-agent-and-how-does-it-work-1d4d9e4381ca">What is an LLM Agent and how does it work?</a></p><h4>ReAct Agents</h4><p>The ReAct framework was first introduced in the paper <strong>“</strong><a href="https://arxiv.org/pdf/2210.03629"><strong>ReAct: Synergizing Reasoning and Acting in Language Models</strong></a><strong>”</strong> in October 2022. This paper outlines how the ReAct agent integrates reasoning and actions within large language models to enable more intelligent and dynamic problem-solving.Please go through this paper for in depth understanding of the ReAct Framework.</p><p>In a nutshell, ReAct(Reasoning and Action) is a special type of agent that combines the reasoning power of large language models (LLMs) with the ability to take actionable steps. This approach enables more advanced interactions and problem-solving, allowing the agent to not only understand and analyse complex queries but also perform actions based on its reasoning to achieve specific goals.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*umLzNc4x_9aIaCONsjwb1g.png" /></figure><p>The figure above illustrates how a ReAct Agent, powered by a large language model (LLM), operates using a <strong>Thought, Action, and Observation</strong> loop. In this process, the agent reasons about its previous observations to determine the next actions. When a query is received, the <strong>Thought</strong> step identifies the most appropriate action to take and retrieves the necessary inputs for that action from the agent’s memory. This iterative loop allows the agent to continuously refine its approach as it works toward solving the query.</p><blockquote>Note: All previous loops are stored in the prompt which makes up the Agent Memory</blockquote><h3>Code Implementation of ReAct Agent</h3><p>Before we start building a ReAct Agent to solve some Logical Reasoning Queries, let us first set up “<strong>GROQ</strong>”.</p><p>GROQ is a Fast AI Interface SaaS Service, that allows us to interact with many popular LLM Models such as llama, Mixtral, Gemma etc. free of cost upto a certain limit. As it doesn’t cost if we are using within limits, It is very useful for learning and development purposes. For more details please visit “<a href="https://groq.com/">https://groq.com/</a>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PwH83cNQvAqHXkFqDH6jeg.png" /></figure><p>To use this service , please sign up for free and create API key. Refer above image for creating a new API key.</p><h4>For the implementation of the code, the next steps &amp; Conclusion, please refer to Part 2 of the article by clicking the link below.</h4><blockquote><a href="https://medium.com/@akash-modi/logical-reasoning-with-react-agent-from-scratch-in-python-part-2-b74ef462244b"><strong>Logical-reasoning-with-react-agent-from-scratch-in-python-part-2</strong></a></blockquote><p>See you soon in next part ……..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60bda6b182af" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LLM Powered Search Application with Ollama & LangChain]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@akash-modi/llm-powered-search-application-with-ollama-langchain-ebd1cb613636?source=rss-c608b86d080f------2"><img src="https://cdn-images-1.medium.com/max/661/1*2EjIKn5nCUc5fYUINrS-VQ.png" width="661"></a></p><p class="medium-feed-snippet">Keyword based Searching of Medium Articles &amp; Summarisation using LangChain and Ollama running locally</p><p class="medium-feed-link"><a href="https://medium.com/@akash-modi/llm-powered-search-application-with-ollama-langchain-ebd1cb613636?source=rss-c608b86d080f------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@akash-modi/llm-powered-search-application-with-ollama-langchain-ebd1cb613636?source=rss-c608b86d080f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebd1cb613636</guid>
            <category><![CDATA[langchain]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[llama-3]]></category>
            <category><![CDATA[ollama]]></category>
            <dc:creator><![CDATA[Akash Modi]]></dc:creator>
            <pubDate>Sun, 29 Sep 2024 11:56:26 GMT</pubDate>
            <atom:updated>2024-09-30T05:58:18.913Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[LangChain Basics]]></title>
            <link>https://medium.com/@akash-modi/langchain-basics-af0c803a3d88?source=rss-c608b86d080f------2</link>
            <guid isPermaLink="false">https://medium.com/p/af0c803a3d88</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[langchain]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[llm-tool]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <dc:creator><![CDATA[Akash Modi]]></dc:creator>
            <pubDate>Thu, 26 Sep 2024 16:03:43 GMT</pubDate>
            <atom:updated>2024-09-26T16:03:43.924Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding LangChain Components: A Beginner’s Guide to Building LLM Applications</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wiyccF0pKdjJF4gqt-s4Ww.png" /></figure><p>This article serves as a beginner-friendly guide to the basics of LangChain, a powerful framework for building applications in the field of Generative AI. It introduces LangChain’s core components and walks you through simple examples to help you gain a clearer understanding of how it works.</p><p>This article is designed for beginners looking to understand the fundamentals of LangChain, offering insights into its core components and practical examples to demonstrate how it can be used to create efficient, language-driven applications. By the end of this guide, you’ll have a solid foundation to start building your own AI-powered solutions with LangChain.</p><h4>Lets Get Started …..</h4><h3>What is LangChain?</h3><p>LangChain is a framework built to facilitate the creation of applications powered by large language models (LLMs). It abstracts away many of the complexities involved in managing language models, from prompt engineering to chaining different language models together. LangChain supports different LLM providers like OpenAI, Hugging Face, and Cohere, making it a versatile choice for developers.</p><p>Key use cases of LangChain include:</p><ul><li>Question Answering (QA) systems</li><li>Text generation and Summarization</li><li>Conversational agents (chatbots)</li><li>Automated Document Processing</li><li>Sentiment Analysis and Opinion Mining</li></ul><p><em>and many more ….</em></p><figure><img alt="Components of LLM Prompt templates, chains &amp; LLMs" src="https://cdn-images-1.medium.com/max/590/1*wYgkdebvNgiwC4v60cyuEw.png" /><figcaption>Basic Components of LangChain</figcaption></figure><h3>Core Concepts in LangChain</h3><p>LangChain simplifies working with LLMs by organizing tasks into several components. Understanding these components is essential to building any application using the framework. Below are the key building blocks:</p><h4>1. Prompts/Prompt Templates</h4><p>Prompts are at the heart of interacting with language models. LangChain provides a modular prompt system, allowing developers to dynamically build and modify prompts. You can create templates that combine variables, making it easier to scale or reuse your prompts across different models.</p><p><em>Note: Prompts with variables are known as prompt templates</em></p><p>Example: Below is the summarisation prompt template, that takes an paragraph as input and returns a short summary with neutral tone.</p><pre>summary_prompt = &#39;&#39;&#39;<br><br>Instruction: <br>Summarize the following text into a concise and coherent version. <br>Focus on the key points and eliminate unnecessary details. <br>Ensure the summary is significantly shorter than the original <br>content while retaining the main message.<br><br>Tone &amp; Style:<br>neutral<br><br>Length of Summary:<br>100 words<br><br>Input:<br>{input}<br>&#39;&#39;&#39;</pre><h4>2. <strong>LLMs (Large Language Models)</strong></h4><p>LangChain is designed to integrate with multiple LLMs. You can use APIs from models like OpenAI’s GPT-4, Hugging Face transformers, or any custom LLMs. LangChain makes it easier to switch between models without rewriting large parts of your application.</p><p>Lang chain can also connect to locally deployed LLM models through Ollama or vllm.These platform offers optimised infrastructure for fast, scalable, and cost-efficient language model deployments. For use-cases with private dataset / less infrastructure / education purposes, these kind of local deployed LLMs are the best solutions.</p><h4>3. Chains</h4><p>A chain is the central building block in LangChain. It allows you to combine multiple actions or language model calls in a sequence to achieve more complex tasks. For example, you can have a chain that first generates a summary and then performs sentiment analysis on that summary.</p><p>Example:</p><pre>chain = prompTemplate | model</pre><p>Chains are very easy to be use in LangChain as simple as just using a pipe “|” operator. It can connect multiple langchain components.</p><h4>4. Tools</h4><p>LangChain provides various pre-built tools that can extend the capabilities of your application. For example, LangChain includes built-in support for external APIs, search engines, and databases. This enables you to chain language model queries with other processes like fetching data from an API or performing a web search.</p><p>Key tools available in LangChain, each with a brief explanation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*I9LEfymQwb8cd9ZnBotFHg.png" /></figure><ol><li><strong>WebSearchTool</strong>: Allows models to search the web for real-time information.</li><li><strong>PythonRequestsTool</strong>: Enables models to send HTTP requests to external APIs for fetching live data.</li><li><strong>Calculator Tool</strong>: Performs arithmetic and advanced mathematical operations for precise calculations.</li><li><strong>Python REPL Tool</strong>: Executes Python code for dynamic calculations or script-based tasks.</li><li><strong>Database Tool</strong>: Connects and queries databases to retrieve or manipulate structured data.</li><li><strong>Wikipedia Tool</strong>: Fetches relevant information directly from Wikipedia for knowledge retrieval.</li><li><strong>Code Interpreter Tool</strong>: Allows models to write and execute code, useful for solving coding or logic problems.</li><li><strong>CSV Tool</strong>: Reads and processes CSV files, useful for extracting data or generating insights from tabular data.</li><li><strong>Zapier Tool</strong>: Automates workflows by connecting models to over 5,000 apps via the Zapier platform.</li><li><strong>Google Search Tool</strong>: Queries Google Search to retrieve the latest or specific information from the web.</li><li><strong>Selenium Browser Tool</strong>: Automates browser interactions, such as scraping web data or testing UI components.</li><li><strong>SerpAPI Tool</strong>: Provides Google search results using the SerpAPI, returning top search results for queries.</li></ol><p>These tools enable LangChain to interact with external data, APIs, and perform tasks beyond the typical capabilities of language models.</p><h3>Conclusion</h3><p>LangChain simplifies the development of applications leveraging large language models by providing modular tools, chaining functionality, and built-in integrations with external resources. Whether you’re building a simple chatbot or a more complex automated research assistant, LangChain’s flexible architecture and extensive support for LLMs make it a powerful tool in the developer’s toolkit.</p><p>As language models continue to evolve, frameworks like LangChain will become even more essential for building scalable, efficient, and intelligent applications. By understanding its basic components and capabilities, you can unlock the potential of LLMs and bring your language model-driven applications to life.</p><p>We will dive deep into each of these topics independently and also develop real world applications using LangChain in the upcoming articles.</p><h3>References:</h3><p><a href="https://www.langchain.com/">https://www.langchain.com</a></p><p><a href="https://python.langchain.com/v0.2/docs/introduction/">https://python.langchain.com/v0.2/docs/introduction</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af0c803a3d88" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>