Saturday, March 2, 2024
No menu items!
HomeArtificial IntelligenceWhat is LangGraph?

What is LangGraph?

large language models (LLMs) that maintain state, and it is built upon LangChain with the intention of being used in conjunction with it.

LangGraph expands the capabilities of the LangChain Expression Language by enabling the coordination of multiple chains or actors across multiple computational steps in a cyclical manner. This design is influenced by Pregel and Apache Beam. The current interface is modeled after NetworkX.The primary function of LangGraph is to introduce cycles into your LLM application. It is essential to note that this is NOT a directed acyclic graph (DAG) framework. If you wish to create a DAG, you should utilize the LangChain Expression Language directly. Cyclical structures are vital for agent-like behaviors, as they allow you to repeatedly call an LLM in a loop and request its next action.

How it works

Concept of stateful, multi-actor applications and how LangGraph enables their creation using LLMs

LangGraph is a library that enables the creation of stateful, multi-actor applications with LLMs (LangModel Models) using LangChain. It extends the LangChain Expression Language, allowing the coordination of multiple chains or actors across multiple steps of computation in a cyclic manner. This is particularly useful for building agent-like behaviors, where an LLM is called in a loop to determine the next action.

The concept of stateful, multi-actor applications is central to LangGraph. It allows the creation of applications where multiple actors (representing different components or entities) maintain their state and interact with each other in a coordinated manner. This is achieved by defining a StatefulGraph, which is parameterized by a state object that is passed around to each node. Each node then returns operations to update that state. These operations can either set specific attributes on the state or add to the existing attributes. The main type of graph in LangGraph is the StatefulGraph, which facilitates the management of state within the application.

Essentially, LangGraph enables the creation of stateful, multi-actor applications by providing a framework for coordinating multiple actors and managing their state using LLMs and LangChain.

LangGraph vs directed acyclic graph (DAG).

The main difference between LangGraph and a directed acyclic graph (DAG) is that LangGraph allows for cycles, while a DAG does not. A DAG is a directed graph with no directed cycles, meaning it is impossible to start at a vertex and follow the edges in such a way that eventually loops back to the same vertex. On the other hand, LangGraph specifically provides the ability to create cyclic behavior, allowing for repeated actions and interactions between actors in the graph

LangGraph Use Cases

Some examples of applications that can benefit from LangGraph include:

  1. Agent-like Behaviors: LangGraph is useful for applications that require agent-like behaviors, where an LLM is called in a loop, asking it what action to take next. This can be applied in chatbots, conversational agents, or any system where an agent needs to make sequential decisions based on the state of the conversation or environment. CrewAI is building something similiar to this using LangChain.
  2. Coordinating Multiple Chains or Actors: LangGraph extends the LangChain Expression Language with the ability to coordinate multiple chains or actors across multiple steps of computation in a cyclic manner. This feature is beneficial for applications that involve coordinating and managing multiple interconnected processes or actors.
  3. Web-Enabled Agents: WebVoyager, built with LangGraph is a new kind of web-browsing agent using multi-model AI.
  4. Stateful Applications: Applications that need to maintain and update a state as they progress, such as task-oriented dialogue systems, can benefit from the stateful nature of LangGraph.
  5. Custom Tool Integration: LangGraph allows the integration of custom tools, making it suitable for applications that require the use of diverse external tools and services in their decision-making processes.

LangGraph is beneficial for applications that require agent-like behaviors, coordination of multiple actors, cyclic behavior, stateful processing, and integration of custom tools. It is particularly well-suited for building complex, interactive, and stateful language-based applications.

Compare and Contrast LangGraph

Would be interesting to see how it compares to Llamaindex, PyTorch. LLM Frameworks in general seem to get a lot of flak for over-complicating things. DSPy has also been gaining popularity. DSPy, is a framework for algorithmically optimizing LM prompts and weights, especially when LMs are used multiple times within a pipeline. DSPy separates the flow of the program from the parameters of each step, allowing for more systematic and powerful optimization of LM prompts and weights. DSPy also introduces new optimizers that are LM-driven algorithms that can tune the prompts and/or weights of LM calls to maximize a given metric.

Final Thoughts

LangGraph shows promise as a valuable addition to the growing ecosystem of LangChain. With its ability to enable the creation of stateful, multi-actor applications using LLMs and LangChain, LangGraph opens up new possibilities for building complex and interactive language-based systems.

The future of agents looks promising, as they are expected to have massive use cases. While agents in the past may have been ineffective and token-consuming, advancements in technologies like LangGraph can help address these challenges. By allowing for more advanced agent runtimes from academia, such as LLM Compiler and plan-and-solve, LangChain aims to enhance the effectiveness and efficiency of agents.

Stateful tools are also on the horizon for LangChain, which would enable tools to modify the state of applications. This capability would further enhance the flexibility and adaptability of stateful, multi-actor applications, enabling them to better respond to dynamic environments.

Moreover, LangChain is actively exploring the integration of more controlled human-in-the-loop workflows. This would provide opportunities for human involvement and guidance in decision-making processes, augmenting the capabilities of automated systems.

In the future, LangGraph and LangChain are expected to continue evolving and growing, offering more advanced features and expanding their capabilities. This opens up exciting research directions and potential applications that could benefit from advancements in LangGraph and similar technologies.

Overall, LangGraph’s potential to improve agent performance, enable stateful applications, and support multi-agent workflows positions it as a promising tool in the realm of language-based systems. As the LangChain ecosystem continues to thrive and innovate, we can anticipate even more exciting developments in the near future.

Jorge Villegas
Jorge Villegas
Software Developer
RELATED ARTICLES
- Advertisment -

Most Popular

Recent Comments

Subscribe to our AI newsletter. Get the latest on news, models, open source and trends.
Don't worry, we won't spam. 😎

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

Lusera will use the information you provide on this form to be in touch with you and to provide updates and marketing.