Qlaudia

← All courses

LangChain

  • Artificial Intelligence
  • Technology & Computing

Compose unified interfaces for language models, embeddings, and prompts while building multi-step applications through chains, memory, retrieval, and agents. Master LangChain's six core pillars to orchestrate complex LLM workflows that retrieve data, remember context, invoke tools, and reason across steps.

Sign in to enroll$1034 lessons

What you'll learn

  • Large Language Model (LLM)A deep neural network trained on massive text corpora to model the probability distribution over sequences of tokens and generate new text or complete language tasks.
  • Retrieval-Augmented Generation (RAG)An architectural pattern that grounds language model responses by retrieving relevant external documents at inference time and injecting them into the prompt.
  • Runnable InterfaceA standard protocol that every LangChain component implements to enable consistent invocation, streaming, and batching across prompts, models, retrievers, parsers, and custom functions.
  • Chat ModelA language model variant that processes conversations as structured lists of role-tagged message objects rather than flat strings.
  • Prompt TemplateA reusable, parameterised text structure that combines fixed instructions with dynamic values to produce complete prompts ready for a language model.
  • LangChain Expression Language (LCEL)A declarative syntax using the pipe operator to compose LangChain components into executable pipelines where each component's output flows as input to the next.
  • ChainA sequence of processing steps such as prompt templates, language model calls, and output parsers composed into a single executable unit that takes an input and produces an output.
  • RetrieverA standardised interface that accepts a text query and returns a ranked list of relevant Document objects from a source like a vector store or search engine.
  • Conversational Retrieval ChainA retrieval chain that maintains conversation history and reformulates new questions into standalone queries before retrieval.
  • LangSmith TracingAn observability feature that records a structured hierarchical log of every step occurring during a LangChain run for inspection, querying, and evaluation.
  • MemoryA mechanism that stores information from past conversational interactions and injects it into future language model calls to maintain context across multiple turns.
  • AgentA component that uses a language model as a reasoning engine to decide step by step which actions to take by observing state, thinking, and acting in a loop until reaching a goal.
  • Vector StoreA specialised database that stores embeddings and provides efficient mechanisms to find the most semantically similar text based on geometric proximity in vector space.
  • Chat Prompt TemplateA template that constructs an ordered list of typed message objects with parameterized placeholders for use with chat models.
  • Few-Shot PromptingA technique where one or more worked examples of input-output pairs are embedded in a prompt to guide a language model's response style and format without weight updates.
  • Human Message / AI MessageTyped message objects in LangChain that explicitly distinguish between user-authored text (HumanMessage) and model-authored text (AIMessage) in conversations.
  • Text SplitterA LangChain utility that breaks large text into smaller, semantically coherent chunks to fit within token limits and improve retrieval precision.
  • DocumentA container with page_content text and a metadata dictionary that serves as the fundamental data unit throughout LangChain pipelines.
  • CallbacksHooks that fire automatically at well-defined points during chain, agent, LLM, or tool execution to observe and react to events without modifying core logic.
  • Output ParserA component that transforms raw text output from a language model into a well-defined Python object like a dictionary or Pydantic model.
  • Agent ExecutorThe runtime component that drives an agent through a ReAct-style loop of repeated LLM calls and tool executions until a final answer is produced.
  • ToolA named, callable function that an agent can invoke to perform discrete actions like searching the web, querying a database, or calling an API beyond text generation.
  • StreamingA delivery mode in which language models produce output token-by-token and immediately forward each token to the application for display rather than waiting for generation to complete.
  • Structured OutputA pattern that constrains a language model to return responses conforming to a precise, machine-readable schema definition rather than free-form text.
  • LangChain HubA hosted public registry for publishing, versioning, discovering, and pulling reusable prompt templates and chain components.
  • RunnableParallelA component that takes a single input, distributes it to multiple runnables simultaneously, and merges their outputs into a dictionary keyed by user-defined names.
  • LangChain Model I/OAn abstraction layer that standardizes formatting inputs as prompts, calling a language model, and parsing outputs into a composable provider-agnostic pipeline.
  • System MessageA meta-instruction placed at the beginning of a chat prompt that provides persistent, high-level guidance to the LLM before any user interaction begins.
  • Embedding ModelA neural network that maps text to a fixed-length vector encoding semantic meaning so that passages with similar meanings are positioned close together in vector space.
  • Tool Calling (Function Calling)A capability in certain LLMs to output structured, machine-readable payloads that signal the model wants to invoke an external tool with specific arguments.
  • Conversation Buffer MemoryA memory system that stores the complete, unabridged history of all message exchanges in a conversation.
  • RunnablePassthroughA runnable that accepts an input and returns it unchanged, useful for fanning out data through multiple paths while preserving the original value.
  • Batch ProcessingThe ability to send multiple independent inputs through a chain or model in a single call to achieve higher throughput through parallel or concurrent execution.
  • Document LoaderA LangChain component that reads data from external sources and returns a uniform list of Document objects, normalizing diverse data formats into a single representation.

About this course

LangChain Overview

What Is LangChain?

LangChain is an open-source framework — available in both Python and JavaScript/TypeScript — designed to help developers build applications powered by large language models (LLMs). At its core, LangChain addresses a simple but critical observation: calling an LLM in isolation is rarely enough for a real-world application. Useful products need to retrieve relevant data, remember past interactions, invoke external tools, and coordinate multi-step reasoning. LangChain provides a structured set of abstractions and composable components to wire all of these concerns together in a maintainable way.

Think of LangChain as the "plumbing" layer between your application logic and the raw intelligence of an LLM. Just as a web framework like Flask or Express gives you routing, middleware, and request handling so you don't have to build those from scratch, LangChain gives you prompts, chains, memory, retrievers, and agents so you don't have to reinvent LLM orchestration every time.


Why LangChain Exists

LLMs are stateless text-in / text-out functions. By themselves, they cannot:

  • Remember what was said earlier in a conversation beyond what fits in their context window.
  • Look up fresh or private information they were not trained on.
  • Take actions in the world — searching the web, querying a database, running code.
  • Decompose a complex goal into a plan and execute it step by step.

Every team building serious LLM applications ends up solving these problems independently, and solving them well requires careful engineering. LangChain consolidates those solutions into a reusable, tested, and extensible library so that teams can focus on what makes their application unique.


The Core Pillars

LangChain organises its functionality around six tightly related areas. Understanding how they fit together is the key to understanding the framework.

LangChain Framework Models & Prompts LLMs, Chat, Embeddings Chains Composable Pipelines Memory Conversation History Retrieval (RAG) Vector Stores, Loaders Tools & Agents Actions & Decision Loops LCEL Expression Language

The six core pillars of LangChain and how they orbit the central framework. Each pillar is an independently usable module that can be combined with the others.

1. Models & Prompts

The foundation of everything. LangChain provides unified interfaces for LLMs (text-in / text-out), Chat Models (message lists in / message out), and Embedding Models (text-in / vector out). Because it wraps providers like OpenAI, Anthropic, Google, Cohere, and local models behind a common interface, you can swap providers without rewriting your application logic.

Prompts are managed through prompt templates — parameterised string blueprints that keep instructions separate from runtime data, making prompts reusable, testable, and version-controllable.

2. Chains

A chain is a sequence of steps where the output of one step feeds into the next. The simplest chain is prompt → model → output parser. More complex chains branch, loop, or call sub-chains. LangChain's LangChain Expression Language (LCEL) — using a pipe (|) operator — makes composing these steps concise and readable:

chain = prompt | model | output_parser
result = chain.invoke({"topic": "black holes"})

Chains are the primary unit of composition in LangChain, and almost every other feature is expressed as a chain or a component within one.

3. Memory

Because LLMs are stateless, memory components give chains the ability to persist and recall information across multiple calls. Simple buffer memory stores the raw conversation history; more advanced strategies summarise old turns or select only the most relevant ones to stay within the context window. Memory can be stored in-process (in RAM) or in external backends like Redis or a database.

4. Retrieval-Augmented Generation (RAG)

RAG is the pattern of grounding an LLM's response in external documents retrieved at query time. LangChain provides:

  • Document loaders to ingest text from PDFs, websites, databases, and hundreds of other sources.
  • Text splitters to break documents into manageable chunks.
  • Embedding models to convert chunks into vector representations.
  • Vector stores (Pinecone, Chroma, FAISS, etc.) to index and search those vectors.
  • Retrievers to query the store and return the most relevant chunks.

This pillar is what enables LLM applications to answer questions about private or up-to-date information the model was never trained on.

5. Tools & Agents

Tools are functions an LLM can choose to call — a web search, a calculator, a database query, a code interpreter. Agents wrap an LLM in a reasoning loop: the model decides which tool to call, calls it, observes the result, and repeats until it reaches an answer. This transforms the LLM from a passive text generator into an active problem-solver that can interact with the world.

6. LangChain Expression Language (LCEL)

LCEL is LangChain's declarative interface for composing chains. Every LCEL object implements a common Runnable interface with methods like .invoke(), .stream(), and .batch(). This uniformity means any component — a prompt, a model, a retriever, a custom function — can be composed with any other using the | operator, and the resulting chain automatically supports streaming, async execution, and parallel branches.


How the Pillars Work Together

A realistic LangChain application combines all six pillars. Consider a customer-support chatbot that answers questions about a company's product documentation:

  1. The user's message arrives and is formatted by a prompt template.
  2. Memory appends the conversation history to the prompt.
  3. A retriever searches a vector store to find the most relevant documentation passages.
  4. The assembled prompt (history + retrieved context + user question) is sent to a chat model.
  5. If the model decides it needs live data (e.g., current stock levels), it calls a tool.
  6. The final response is parsed by an output parser and returned to the user.

The entire pipeline is wired together as an LCEL chain, giving it built-in support for streaming tokens to the user as they are generated.


LangChain in the Ecosystem

LangChain itself focuses on composable building blocks. Two companion projects extend it:

  • LangSmith — a platform for tracing, debugging, evaluating, and monitoring LangChain applications in production.
  • LangGraph — a library for building stateful, multi-actor workflows as graphs, enabling more complex agent architectures with cycles and explicit state management.

Together, these three projects cover the full lifecycle of an LLM application: development (LangChain), orchestration of complex agents (LangGraph), and observability (LangSmith).


What to Learn Next

Because LangChain is a framework of composable parts, the best way to learn it is to understand each pillar in depth before combining them. A natural progression is:

  1. Models & Prompt Templates — the bedrock of every chain.
  2. LCEL & Chains — how to compose components declaratively.
  3. Output Parsers — how to turn raw model output into structured data.
  4. Memory — how to make chains stateful across conversation turns.
  5. Document Loaders, Splitters, and Retrievers — the RAG pipeline.
  6. Vector Stores — where embeddings live and how they are searched.
  7. Tools & Agents — giving the LLM the ability to act.

Each subsequent concept in this course corresponds to one of these pillars or a specific technique within them. By the end, you will have a complete mental model of how LangChain's abstractions fit together and how to apply them to build reliable, production-grade LLM applications.

LangChain — Qlaudia