Working through this module?
Module 01 · Page 2 of 20 · 5 sections
Introduction to LangChain
What LangChain is, why developers use it, its high-level architecture, the core concepts and how it compares with calling an LLM API directly.
What is LangChain?
- LangChain is an open-source framework designed to build applications with Large Language Models (LLMs).
- It provides tools, abstractions and modules to connect LLMs with external data, tools and real-world actions.
- It simplifies the development of complex LLM applications like chatbots, agents, RAG systems and document analysis.
- LangChain is language-agnostic but most popular with Python.
Why LangChain?
- Provides high-level abstractions for LLM apps.
- Easy integration with multiple LLM providers (OpenAI, Anthropic, Google, etc.).
- Built-in support for document loaders, text splitters, vector stores and tools.
- Helps in building production-ready applications.
- Modular and extensible architecture.
- Large community and active development.
- Useful for building RAG, agents, chatbots and multi-step workflows.
High Level Architecture
User Query
LangChain FrameworkPrompts, chains, agents, memory, loaders, vector stores, tools
LLMOpenAI, Claude, Gemini
Response to User
The framework also reaches out to external data such as PDFs, databases and APIs.
Core Concepts in LangChain
- Models
- LLMs and chat models.
- Prompts
- Templates to create structured inputs.
- Chains
- Sequence of operations using LLMs.
- Agents
- Use tools to perform actions.
- Memory
- Maintain conversation history.
- Document Loaders
- Load data from various sources.
- Text Splitters
- Split large documents.
- Vector Stores
- Store and search embeddings.
- Retrievers
- Fetch relevant documents.
- Tools
- Integrate with external APIs, DBs, etc.
- Callbacks
- Track and monitor token usage.
- Output Parsers
- Structure the LLM output.
1
2
3
4
5
6
7
8
9
10
11
12
LangChain vs Direct LLM API Calls
| Aspect | Direct LLM API Calls | LangChain |
|---|---|---|
| Ease of Use | Manual implementation | High-level abstractions |
| Prompt Management | Hard-coded | Prompt templates and chains |
| Document Handling | Custom implementation | Built-in document loaders and splitters |
| Vector Store Integration | Manual integration | Direct support (FAISS, Chroma, etc.) |
| Agents and Tools | Complex to implement | Built-in agents and tool integration |
| Memory | Manual handling | Built-in memory modules |
| Production Ready | More effort | Ready-to-use components |