Introduction to LangChain
Kunal Mehta
Global Data Platform Head | Product Owner | Associate Director | Data Analytics | Google Analytics | Adobe Analytics | Google Cloud Platform | Machine Learning | Data Science | Data Engineering | Speaker
LangChain is a framework in place to develop LLM applications. The best part about this framework is that it supports LLM application lifecycle at every stage:
-????????? Development: LangChain provides Open-Source building blocks to build your LLM applications from scratch using their own templates if we want.
-????????? Productionalization: LangSmith can be used to inspect, monitor, and evaluate our chains, so that we can continuously optimize and deploy
-????????? Deployment: We can even turn any chain into an API with the help of LangServe.
There are 4 key components of LangChain:
-????????? Chains
-????????? Agents
-????????? Memory
-????????? Tools
Lets take a deeper dive into all these 4 components in next few sections.
Chains
For composing modular components into reusable pipelines, developers can put together multiple LLM components in a sequence to create complex applications for things like Chatbots, data extractors, and data analysis.
Chains deliver several benefits like:
-????????? Modularity
-????????? Composability
-????????? Reusability
-????????? Tool Integration
-????????? Readability
-????????? Maintainability
-????????? Productivity
Agents
Agents help in creating systems that interact dynamically with users and environments over time. An agent is an autonomous software entity, that is capable of taking actions to accomplish goals and tasks.
Both chains and agents extend LLMs. Agents orchestrate chains while chains compose more lower-level modules.
Chains define reusable logic by sequencing components, agents observes the environment, decides which chain to execute based on observations, takes chain’s specified action and repeats. Agents essentially decides which action to take using LLMs as reasoning engines.
Major benefits of agents are:
领英推荐
-????????? Goal oriented execution
-????????? Dynamic responses
-????????? Composition
-????????? Robustness
-????????? Statefulness
?Memory
It refers to the persisting state between executions of a chain as agents. It helps building conversational and interactive applications. Rather than treating each user input as an isolated prompt, chains can pass conversational memory to models. Agents can also persist facts, relationships and deductions in memory.
Several memory options that exist are:
-????????? ConversationBufferMemory: Stores all messages in model history.
-????????? ConversationBufferWindowMemory: Retains all recent messages.
-????????? ConversationKGMemory: Summarize exchanges as a knowledge graph.
-????????? EntityMemory: Backed by a database, persists agent state and facts.
?Tools
They provide modular interfaces for agents to integrate external services like databases and APIs. There are many tools that are available like:
-????????? Machinetranslator
-????????? Calculator
-????????? Search Engine
-????????? Maps
-????????? Stocks
-????????? Weather
-????????? Wikipedia
There are many more pre-defined tools, and even more custom tools that can be created with the use of Chains or Agents, to complete your defined custom tasks.
This is the first chapter on LangChain, which dealt with introduction to LangChain, its major components, and hopefully gave you an idea of major functionalities present in this framework. In the next installment, we will go through the steps to create first LangChain program to create a very simple program to invoke LLM (Open AI) using the LangChain components.
In case you have any doubts, any questions, or any suggestions, please do feel free to express the same in the comments below.
Women in Tech Asia- Top 10 Data Leaders of 2023| Marketing Analytics & Data Strategy | Next Generation Leadership Team | Certified Data Scientist & Architect | ML & AI Enthusiast| Avid Learner| Thought Leader & Speaker
10 个月So looking forward to it! ??
Senior Data Analyst & AEP Developer @Samsung Group | Ex-Publicis Sapient | Azure Solutions Architect Certified | 4x Adobe Analytics Certified | PowerBI Certified| Data Strategy | MarTech
10 个月Insightful!
Specialist, Data Analyst, Audience Insights and Client Activation, McKinsey & Company
10 个月Very helpful!
Expertise in #MarketingManagement , #BrandManagement , #ProfitManagement in #Heavy #Engineering #Equipment as #DGM for Pan India and #Exports. WhatsApp +919071165777 [email protected]
10 个月You are a Leader sir!!
?? Driving Customer Experience Transformation | Data Analytics Lead | CX Podcaster & Speaker
10 个月This is a much needed initiative, thanks for taking the time to share your experience and learnings with us… will definitely follow diligently