Ubuntu TechHive
building-llm-agents-with-langchain-and-langgraph.md
LangChain और LangGraph के साथ LLM एजेंट्स बनाना
article.विवरण

LangChain और LangGraph के साथ LLM एजेंट्स बनाना

reading.प्रगति 9 मिनट पढ़ें

Langchain और LangGraph के साथ Llm एजेंट्स बनाने का विवरण

Langchain और LangGraph के साथ LLM एजेंट बनाना

एजेंडा

English
  1. Introduction to LLM Agents:
  2. Building Simple LLM Agents:
  3. Advanced LLM Agent Development:
  4. Project Showcase: Building a Travel Agent App:
  5. Simplifying Development with Microsoft's Autogen Studio:
  6. Capstone Project Demonstration:
हिंदी
  1. LLM एजेंटों का परिचय:
  2. सरल LLM एजेंट बनाना:
  3. उन्नत LLM एजेंट विकास:
  4. प्रोजेक्ट शोकेस: ट्रैवल एजेंट ऐप बनाना:
  5. Microsoft के Autogen Studio के साथ विकास को सरल बनाना:
  6. कैपस्टोन प्रोजेक्ट प्रदर्शन:

LLM एजेंटों और उनके अनुप्रयोगों का अवलोकन

LLM एजेंटों का परिचय

English

Definition: Large Language Model (LLM) Agents are AI systems designed to understand, generate, and respond to human language in a way that simulates human-like interaction. LLM Agents can automate tasks, provide insights, assist with decision-making, and enhance user experiences across various industries. To understand what LLM agents are, we need to step back to understand what LLM is and how agents came about. Large Language Models (LLMs) are advanced artificial intelligence models designed to understand and generate human-like text. These models are typically based on deep learning architectures, specifically transformers, which enable them to process and produce natural language with high accuracy and coherence. LLMs are trained on vast amounts of text data, allowing them to learn the intricacies of language, including grammar, context, semantics, and even some level of common-sense reasoning.

हिंदी

परिभाषा: लार्ज लैंग्वेज मॉडल (LLM) एजेंट ऐसी AI प्रणालियाँ हैं जिन्हें मानवीय भाषा को समझने, उत्पन्न करने और उसका उत्तर देने के लिए डिज़ाइन किया गया है, जो मानवीय बातचीत की नकल करती हैं। LLM एजेंट कार्यों को स्वचालित कर सकते हैं, अंतर्दृष्टि प्रदान कर सकते हैं, निर्णय लेने में सहायता कर सकते हैं और विभिन्न उद्योगों में उपयोगकर्ता अनुभव को बेहतर बना सकते हैं। यह समझने के लिए कि LLM एजेंट क्या हैं, हमें यह समझने के लिए पीछे मुड़कर देखना होगा कि LLM क्या है और एजेंट कैसे अस्तित्व में आए। लार्ज लैंग्वेज मॉडल (LLMs) उन्नत आर्टिफिशियल इंटेलिजेंस मॉडल हैं जिन्हें मानवीय टेक्स्ट को समझने और उत्पन्न करने के लिए डिज़ाइन किया गया है। ये मॉडल आमतौर पर डीप लर्निंग आर्किटेक्चर, विशेष रूप से ट्रांसफॉर्मर पर आधारित होते हैं, जो उन्हें उच्च सटीकता और सुसंगतता के साथ प्राकृतिक भाषा को संसाधित करने और उत्पन्न करने में सक्षम बनाते हैं। LLMs को बड़ी मात्रा में टेक्स्ट डेटा पर प्रशिक्षित किया जाता है, जिससे वे भाषा की जटिलताओं, जैसे व्याकरण, संदर्भ, शब्दार्थ और यहाँ तक कि सामान्य ज्ञान के तर्क के कुछ स्तर को भी सीख पाते हैं।

ट्रांसफॉर्मर और LLMs:

English

Transformers, introduced in 2017 with the "Attention is All You Need" paper, became the foundation for modern NLP. LLMs like GPT-3 and BERT demonstrated unprecedented language capabilities, understanding context, generating coherent text, and performing complex language tasks.

हिंदी

ट्रांसफॉर्मर, जिन्हें 2017 में "Attention is All You Need" पेपर के साथ पेश किया गया था, आधुनिक NLP की नींव बन गए। GPT-3 और BERT जैसे LLMs ने अभूतपूर्व भाषाई क्षमताओं का प्रदर्शन किया, जिसमें संदर्भ को समझना, सुसंगत टेक्स्ट उत्पन्न करना और जटिल भाषाई कार्यों को पूरा करना शामिल है।

इंटेलिजेंट एजेंटों का उदय

English

Intelligent Agents emerged in 2020s – Present. Building on advancements in LLMs, intelligent agents emerged, combining the autonomy of traditional agents with advanced language capabilities. These agents can understand and generate natural language, interact with users, integrate external tools and APIs, and perform complex tasks.

हिंदी

इंटेलिजेंट एजेंट 2020 के दशक से वर्तमान तक उभरे हैं। LLMs में प्रगति के आधार पर, इंटेलिजेंट एजेंटों का उदय हुआ, जिन्होंने पारंपरिक एजेंटों की स्वायत्तता को उन्नत भाषाई क्षमताओं के साथ जोड़ा। ये एजेंट प्राकृतिक भाषा को समझ और उत्पन्न कर सकते हैं, उपयोगकर्ताओं के साथ बातचीत कर सकते हैं, बाहरी टूल और API को एकीकृत कर सकते हैं, और जटिल कार्य कर सकते हैं।

एजेंटिक सिस्टम

English

LangChain and Other Frameworks:

Frameworks like LangChain provide tools for developing and managing intelligent agents, enabling integration with LLMs and external tools. These agents can perform a wide range of tasks, from customer support to personal assistance and automated workflows.

Examples of Modern Intelligent Agents:

  1. Chatbots and Virtual Assistants:

    • Powered by LLMs, these agents provide human-like interaction, handling customer inquiries, scheduling, and personal tasks.
    • Examples: OpenAI's ChatGPT, Google Assistant, Amazon Alexa.
  1. Automated Customer Support:

    • Agents integrated with CRM systems to handle support tickets, provide information, and resolve issues.
    • Examples: Intercom's automated support bots, Zendesk Answer Bot.
  1. Personalized Recommendations:

    • Agents that analyze user preferences and behaviors to provide tailored recommendations for products, services, or content.
    • Examples: Netflix's recommendation engine, Amazon's product recommendations.
  1. Task automation:

    • Agents that automate repetitive tasks, such as data entry, report generation, and email management.
    • Examples: UiPath's RPA bots, Microsoft's Power Automate.
हिंदी

LangChain और अन्य फ्रेमवर्क:

LangChain जैसे फ्रेमवर्क इंटेलिजेंट एजेंटों को विकसित करने और प्रबंधित करने के लिए टूल प्रदान करते हैं, जो LLMs और बाहरी टूल के साथ एकीकरण को सक्षम बनाते हैं। ये एजेंट ग्राहक सहायता से लेकर व्यक्तिगत सहायता और स्वचालित वर्कफ़्लो तक, कार्यों की एक विस्तृत श्रृंखला कर सकते हैं।

आधुनिक इंटेलिजेंट एजेंटों के उदाहरण:

  1. चैटबॉट्स और वर्चुअल असिस्टेंट:

    • LLMs द्वारा संचालित, ये एजेंट मानवीय बातचीत प्रदान करते हैं, ग्राहकों की पूछताछ, शेड्यूलिंग और व्यक्तिगत कार्यों को संभालते हैं।
    • उदाहरण: OpenAI का ChatGPT, Google Assistant, Amazon Alexa।
  1. स्वचालित ग्राहक सहायता:

    • सपोर्ट टिकटों को संभालने, जानकारी प्रदान करने और समस्याओं को हल करने के लिए CRM सिस्टम के साथ एकीकृत एजेंट।
    • उदाहरण: Intercom के स्वचालित सपोर्ट बॉट्स, Zendesk Answer Bot।
  1. व्यक्तिगत अनुशंसाएँ:

    • ऐसे एजेंट जो उत्पादों, सेवाओं या सामग्री के लिए अनुरूप अनुशंसाएँ प्रदान करने के लिए उपयोगकर्ता की प्राथमिकताओं और व्यवहारों का विश्लेषण करते हैं।
    • उदाहरण: Netflix का अनुशंसा इंजन, Amazon की उत्पाद अनुशंसाएँ।
  1. कार्य स्वचालन:

    • ऐसे एजेंट जो डेटा प्रविष्टि, रिपोर्ट निर्माण और ईमेल प्रबंधन जैसे दोहराव वाले कार्यों को स्वचालित करते हैं।
    • उदाहरण: UiPath के RPA बॉट्स, Microsoft का Power Automate।

LLM एजेंटों के अनुप्रयोग

English
  • Customer Service: Automating responses to customer inquiries, providing 24/7 support.
  • Content Creation: Assisting with writing, editing, and generating creative content.
  • Education: Personalizing learning experiences, tutoring, and providing educational resources.
  • Healthcare: Offering preliminary medical advice, scheduling appointments, and managing patient records.
  • Finance: Assisting with financial planning, managing budgets, and providing investment advice.
  • Travel and Hospitality: Planning trips, booking accommodations, and providing travel recommendations.
हिंदी
  • ग्राहक सेवा: ग्राहकों की पूछताछ के उत्तरों को स्वचालित करना, 24/7 सहायता प्रदान करना।
  • सामग्री निर्माण: लेखन, संपादन और रचनात्मक सामग्री उत्पन्न करने में सहायता करना।
  • शिक्षा: सीखने के अनुभवों को वैयक्तिकृत करना, ट्यूशन देना और शैक्षिक संसाधन प्रदान करना।
  • स्वास्थ्य सेवा: प्रारंभिक चिकित्सा सलाह देना, अपॉइंटमेंट शेड्यूल करना और रोगी रिकॉर्ड प्रबंधित करना।
  • वित्त: वित्तीय योजना, बजट प्रबंधन और निवेश सलाह प्रदान करने में सहायता करना।
  • यात्रा और आतिथ्य: यात्रा की योजना बनाना, आवास बुक करना और यात्रा संबंधी अनुशंसाएँ प्रदान करना।

कैपस्टोन प्रोजेक्ट

graph TD
    START --> A[Travel Planner]
    A --> B[Select Hotels]
    A --> C[Select Plane Tickets]
    A --> D[Select Events]
    B --> E[Feedback Loop]
    C --> E[Feedback Loop]
    D --> E[Feedback Loop]
    E --> F[Check User Requirements]
    F --> A
    F --> END
English

As a capstone project, we will build LLM Agent based Travel Agent App that potentially books airline tickets, reserve accommodation, and provides event recommendations in the destination location.

हिंदी

कैपस्टोन प्रोजेक्ट के रूप में, हम LLM एजेंट पर आधारित एक ट्रैवल एजेंट ऐप बनाएंगे जो संभावित रूप से एयरलाइन टिकट बुक कर सकता है, आवास आरक्षित कर सकता है, और गंतव्य स्थान पर इवेंट अनुशंसाएँ प्रदान कर सकता है।

LangChain और LangGraph की मूल बातें समझना

English

Definition: One of the commercial frameworks for building LLM-powered applications, focusing on creating chains of operations that process and respond to inputs. Key features of LangChain includes:

  • Modular design for flexibility and scalability.
  • Integration with various tools and data sources.
  • Support for building complex workflows.

LangGraph is an extension of LangChain that uses graph structures to manage and visualize the relationships between different operations and data points. Key features of LangGraph includes:

  • Visual representation of LLM workflows.
  • Enhanced debugging and optimization through graph analysis.
  • Ability to handle complex dependencies and data flows.

Reference the Demo presentation for the following topics:

हिंदी

परिभाषा: LLM-संचालित एप्लिकेशन बनाने के लिए व्यावसायिक फ्रेमवर्क में से एक, जो संचालन की ऐसी श्रृंखला बनाने पर केंद्रित है जो इनपुट को संसाधित करती है और उसका उत्तर देती है। LangChain की मुख्य विशेषताओं में शामिल हैं:

  • लचीलेपन और स्केलेबिलिटी के लिए मॉड्यूलर डिज़ाइन।
  • विभिन्न टूल और डेटा स्रोतों के साथ एकीकरण।
  • जटिल वर्कफ़्लो बनाने के लिए समर्थन।

LangGraph LangChain का एक विस्तार है जो विभिन्न ऑपरेशनों और डेटा बिंदुओं के बीच संबंधों को प्रबंधित और विज़ुअलाइज़ करने के लिए ग्राफ़ संरचनाओं का उपयोग करता है। LangGraph की मुख्य विशेषताओं में शामिल हैं:

  • LLM वर्कफ़्लो का दृश्य प्रतिनिधित्व।
  • ग्राफ़ विश्लेषण के माध्यम से बेहतर डिबगिंग और अनुकूलन।
  • जटिल निर्भरताओं और डेटा प्रवाह को संभालने की क्षमता।

निम्नलिखित विषयों के लिए डेमो प्रस्तुति देखें:

LangChain / LangGraph

English
  • Setting Up Your Development Environment
  • Tools and Libraries:

    • Python: Ensure Python is installed on your system. Recommended version: 3.8 or higher.
    • IDE or Code Editor: Use an Integrated Development Environment (IDE) like PyCharm, VSCode, or Jupyter Notebook for coding.
  • LangChain and LangGraph: Install these libraries using pip.

    • pip install langchain, langgraph and other libraries
    • Create a Virtual Environment:

      python -m venv llm_env
    • Activate your Python path

      source llm_env/bin/activate

      On Windows

      llm_env\Scripts\activate
  • Design flowcharts
हिंदी
  • अपना विकास वातावरण सेट करना
  • टूल और लाइब्रेरी:

    • Python: सुनिश्चित करें कि आपके सिस्टम पर Python इंस्टॉल है। अनुशंसित संस्करण: 3.8 या उच्चतर।
    • IDE या कोड एडिटर: कोडिंग के लिए PyCharm, VSCode, या Jupyter Notebook जैसे इंटीग्रेटेड डेवलपमेंट एनवायरनमेंट (IDE) का उपयोग करें।
  • LangChain और LangGraph: pip का उपयोग करके इन लाइब्रेरी को इंस्टॉल करें।

    • pip install langchain, langgraph और अन्य लाइब्रेरी
    • एक वर्चुअल एनवायरनमेंट बनाएँ:

      python -m venv llm_env
    • अपने Python पथ को सक्रिय करें

      source llm_env/bin/activate

      Windows पर

      llm_env\Scripts\activate
  • फ्लोचार्ट डिज़ाइन करें

Microsoft का AutoGen Studio

English
  • Setting Up Your Development Environment
  • Build and test the LLM Agent based Travel Agent App
हिंदी
  • अपना विकास वातावरण सेट करना
  • LLM एजेंट आधारित ट्रैवल एजेंट ऐप बनाएं और टेस्ट करें