Langchain Ecosystem Image
30 June, 2023

The Langchain Framework And How It Enables Real-World Generative AI Applications

Businesses are coming under increasing pressure from their investors to articulate their strategy deploy generative AI. Identifying suitable use cases that demonstrate a meaningful business impact whilst managing the risks associated with emerging technologies has proved difficult within the constraints of the technologies' limitations. However, the scope of potential generative AI use cases is now expanding rapidly as techniques such as chain-of-thought prompting and the ReAct approach to deploying LLM's have enabled better outcomes from more complex business process challenges and opportunities. To enable businesses to deploy generative AI products using LLM's at any kind of commercial scale an appropriate ecosystem of technologies to deliver ReAct capabilities is required.

Langchain is an open source framework that enables LLM's to be deployed with ReAct capabilities. Langchain enables the development of generative ai technologies that use LLM's and which are context-aware, have the ability to reason and to take actions. Importantly, Langchain enables sequences of context, reasoning and actions where the context of one step can be the result of a prior context, reasoning and action step. This process involves taking an action, observing the result and then repeating the cycle until completion. This ability to perform complex, multi-step sequences significantly expands the potential use cases for businesses seeking to deploy generative AI based products and services.

One of the key capabilities of Langchain is to enable access to external sources of context, such as databases or search engines that enable context to be retrieved in real-time prior to a reasoning step. Access to context from external sources ensures the context is accurate, timely and independent of the snapshot of context on which the LLM was trained.

LangChain solves the problem of LLM's inability to understand context, learn, adapt and interact with the real world.

Langchain - Key Features Langchain is developing quickly and its capabilities are expanding very rapidly. I will therefore concentrate on a subset of key features with the intention of communicating the essence of how this might be useful to businesses looking for a strategy to deploy LLM's without obscuring that goal with too much detail.

There are three core capabilities that are most important to understand:

  • Components
  • Chains
  • Agents

Understanding these three capabilities is sufficient to be able to ideate potential generative AI use cases to a business and each will be covered in their own sections below.

Langchain Ecosystem Image

Components Langchain components are the building blocks from which applications can be assembled and can be thought of as a set of utilities that have been written, tested and widely used to accelerate development. Example components include:

  • Wrappers for LLM's
  • Prompt templates that enable variable values to be inserted as context updates
  • Database interfaces for widely use databases
  • Vector store interfaces for Pinecone and others
  • Search engine interfaces
  • Output parsers

The Langchain components reduce the time to delivering generative AI products by avoiding the need to write and test code for standard utility functionality. This allows businesses to focus on the relevant business logic. The components enable prototype generative AI products to be rapidly assembled so that the feasibility of candidate products can be determined efficiently.

Chains Langchain chains are the instructions that describe the sequence of steps in an end-to-end process. The steps in the sequence could be a call to a database or a search engine to obtain context, a call to an LLM to perform a reasoning step or a call to a tool to perform an action and return the outcome.

It is these chains that enable the multi-step complex business logic to be performed in which generative AI plays the key reasoning role to determine the path of the sequence to achieve the objective.

Chains enable us to combine multiple components together to solve a specific task and build a complete LLM application.

Agents The purpose of Langchain agents is to use the reasoning capabilities of an LLM to choose the sequence of actions to take to achieve the business objective. A set of tools are defined that may be required as an action for a given context. The agent decides which tool to use and once the tool has returned the outcome determines whether to move to the next step in the sequence by providing the updated context or to use another tool to obtain an alternative context update.

The agents are therefore the component that facilitates the intelligence in the product.

Conclusion Generative AI has exploded in popularity since OpenAI released ChatGPT in November 2022 as the chat interface made the technology more accessible to non-technical users. Since then a number of alternative GPT based technologies have released including Microsoft Copilot (originally Bing AI), Anthropic's Claude, Google Bard and before those both Character AI and Perlexity AI were released. The technology is becoming more broad based, capable and accessible to both consumers and businesses.

Leadership teams of businesses are under pressure to articulate their generative AI strategies. Deploying a rapidly evolving, emerging technology has its risks and a lack of practical knowledge of generative AI within leadership teams increases that risk. Business leaders can demonstrate progress by initially deploying generative AI products internally that enable the business to move up the learning curve without external risk. The Langchain framework potentially offers an accelerated time to delivery of generative AI products whilst enabling more compelling use cases.

Next Steps I build businesses, both as independent startups and as new initiatives within large global companies. Having been an early adopter of generative AI as a member of the beta program of OpenAi's GPT-3 model, I released my first LLM based product, Perxeive, to the Apple App Store in November 2021. Since then, I have continued to develop my experience and skills of applying generative AI to real world challenges and opportunities. If you are looking to build a business and require leadership then please contact me via the About section of this website.