Skip to main content

Conceptual Guide

Overview​

In this guide, you'll find explanations of the key concepts, providing a deeper understanding of core principles.

We recommend that you go through at least one of the Tutorials before diving into the conceptual guide. This will help you understand the context and practical applications of the concepts discussed here.

The conceptual guide will not cover step-by-step instructions or specific implementation details β€” those are found in the How-To Guides and Tutorials sections. For detailed reference material, please visit the API Reference.

High Level​

  • Why LangChain?: Why LangChain is the best choice for building AI applications.
  • Architecture: Overview of how packages are organized in the LangChain ecosystem.

Concepts​

  • Chat models: LLMs exposed via a chat interface which process sequences of messages as input and output a message.
  • Messages: Messages are the unit of communication in modern LLMs, used to represent input and output of a chat model, as well as any additional context or metadata that may be associated with the conversation.
  • Chat history: Chat history is a record of the conversation between the user and the chat model, used to maintain context and state throughout the conversation.
  • Tools: The tool abstraction in LangChain associates a Python function** with a schema defining the function's name, description, and input.
  • Tool calling: Tool calling is a special type of chat model API that allows you to pass tool schemas to a model and get back invocations of those tools.
  • Structured output: A technique to make the chat model respond in a structured format, such as JSON that's matching a specified schema.
  • Memory: Persisting information from conversations, so it can be used in future conversations.
  • Multimodality: The ability to work with data that comes in different forms, such as text, audio, images, and video.
  • Tokens: Modern large language models (LLMs) are typically based on a transformer architecture that processes a sequence of units known as tokens.
  • Runnable interface: A standard Runnable interface implemented across many in LangChain components.
  • LangChain Expression Language (LCEL): A declarative approach to building pipelines with LangChain components. LCEL servers as a simple orchestration language for LangChain.
  • Document loaders: Components that help loading documents from various sources.
  • Retrieval: Information retrieval systems can retrieve structured or unstructured data from a datasource in response to a query.
  • Text splitters: Use to split long content into smaller more manageable chunks.
  • Embedding models: Embedding models are models that can represent data in a vector space.
  • Vector stores: A datastore that can store embeddings and associated data and supports efficient vector search.
  • Retriever: A retriever is a component that retrieves relevant documents from a knowledge base in response to a query.
  • Retrieval Augmented Generation (RAG): A technique that enhances language models by combining them with external knowledge bases.
  • Agents: Use a language model to choose a sequence of actions to take. Agents can interact with external resources via tools.
  • Prompt templates: Used to define reusable structures for generating prompts dynamically, allowing for variables or placeholders to be filled in when needed. This is particularly useful with LCEL or when prompts need to be stored and retrieved from a database for repeated use.
  • Async programming with LangChain: Guidelines about programming with LangChain in an asynchronous context.
  • Callbacks: Callbacks are used to stream outputs from LLMs in LangChain, observe the progress of an LLM application, and more.
  • Output parsers: Components that take the output of a model and transform it into a more suitable format for downstream tasks. Output parsers were primarily useful prior to the general availability of chat models that natively support tool calling and structured outputs.
  • Few shot prompting: Few-shot prompting is a technique used improve the performance of language models by providing them with a few examples of the task they are expected to perform.
  • Example selectors: Example selectors are used to select examples from a dataset based on a given input. They can be used to select examples randomly, by semantic similarity, or based on some other constraints. Example selectors are used in few-shot prompting to select examples for a prompt.
  • Tracing: Tracing is the process of recording the steps that an application takes to go from input to output. Tracing is essential for debugging and diagnosing issues in complex applications.
  • Evaluation: Evaluation is the process of assessing the performance and effectiveness of your LLM-powered applications. It involves testing the model's responses against a set of predefined criteria or benchmarks to ensure it meets the desired quality standards and fulfills the intended purpose. This process is vital for building reliable applications. For more information on evaluation in LangChain, see the LangSmith documentation.

Glossary​

  • AIMessageChunk: A partial response from an AI message. Used when streaming responses from a chat model.
  • AIMessage: Represents a complete response from an AI model.
  • astream_events: Stream granular information from LCEL chains.
  • BaseTool: The base class for all tools in LangChain.
  • batch: Use to execute a runnable with batch inputs a Runnable.
  • bind_tools: Allows models to interact with tools.
  • Caching: Storing results to avoid redundant calls to a chat model.
  • Chat Models: Chat models that handle multiple data modalities.
  • Configurable Runnables: Creating configurable Runnables.
  • Context window: The maximum size of input a chat model can process.
  • Conversation patterns: Common patterns in chat interactions.
  • Document: LangChain's representation of a document.
  • Embedding models: Models that generate vector embeddings for various data types.
  • HumanMessage: Represents a message from a human user.
  • InjectedState: A state injected into a tool function.
  • InjectedStore: A store that can be injected into a tool for data persistence.
  • InjectedToolArg: Mechanism to inject arguments into tool functions.
  • input and output types: Types used for input and output in Runnables.
  • invoke: A standard method to invoke a Runnable.
  • JSON mode: Returning responses in JSON format.
  • langchain-community: Community-driven components for LangChain.
  • langchain-core: Core langchain package. Includes base interfaces and in-memory implementations.
  • langchain: A package for higher level components (e.g., some pre-built chains).
  • langgraph: Powerful orchestration layer for LangChain. Use to build complex pipelines and workflows.
  • langserve: Use to deploy LangChain Runnables as REST endpoints. Uses FastAPI. Works primarily for LangChain Runnables, does not currently integrate with LangGraph.
  • Managing chat history: Techniques to maintain and manage the chat history.
  • Multimodality: Capability to process different types of data like text, audio, and images.
  • OpenAI format: OpenAI's message format for chat models.
  • Partner packages: Third-party packages that integrate with LangChain.
  • Propagation of RunnableConfig: Propagating configuration through Runnables. Read if working with python 3.9, 3.10 and async.
  • rate-limiting: Client side rate limiting for chat models.
  • RemoveMessage: An abstraction used to remove a message from chat history, used primarily in LangGraph.
  • role: Represents the role (e.g., user, assistant) of a chat message.
  • RunnableConfig: Use to pass run time information to Runnables (e.g., run_name, run_id, tags, metadata, max_concurrency, recursion_limit, configurable).
  • Standard parameters for chat models: Parameters such as API key, temperature, and max_tokens,
  • stream: Use to stream output from a Runnable or a graph.
  • Tokenization: The process of converting data into tokens and vice versa.
  • Tokens: The basic unit that a language model reads, processes, and generates.
  • Tool artifacts: Add artifacts to the output of a tool that will not be sent to the model, but will be available for downstream processing.
  • Tool binding: Binding tools to models.
  • @tool: Decorator for creating tools in LangChain.
  • Toolkits: A collection of tools that can be used together.
  • ToolMessage: Represents a message that contains the results of a tool execution.
  • Vectorstores: Datastores specialized for storing and efficiently searching vector embeddings.
  • with_structured_output: A helper method for chat models that natively support tool calling to get structured output matching a given schema specified via Pydantic, JSON schema or a function.
  • with_types: Method to overwrite the input and output types of a runnable. Useful when working with complex LCEL chains and deploying with LangServe.

Was this page helpful?