LangChain is probably the most adopted framework for building LLM applications in 2023. Its proposition: instead of making direct OpenAI API calls and assembling your own plumbing, use a coherent set of abstractions to compose complex pipelines. We cover when it adds real value, when it adds unnecessary complexity, and the components worth knowing.
What It Includes
LangChain is a superset of features. Main areas:
- LLM wrappers: a uniform interface over OpenAI, Anthropic, local models (Llama 2, Mistral), Hugging Face, etc.
- Prompts and prompt templates: management of reusable templates with variables, few-shot examples, and composition.
- Chains: sequences of steps. The simplest binds a prompt template to an LLM. Complex ones orchestrate retrieval, validation, and multiple calls.
- Retrievers: abstraction over vector DBs (Chroma, Pinecone, Qdrant, pgvector) with consistent interface.
- Agents: “decide + act” loops based on function calling or the ReAct pattern.
- Memory: conversation history management with various strategies (buffer, summary, window).
- Document loaders: readers for PDF, web, Notion, Slack, database, Google Drive, and dozens more.
- Output parsers: validation and conversion of LLM output to structured types.
This breadth is both its strength and most frequent criticism.
A Minimal RAG Example
What was 100 lines of direct code reduces to this:
from langchain.embeddings import OpenAIEmbeddings
from langchain.vectorstores import Chroma
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.document_loaders import TextLoader
from langchain.chains import RetrievalQA
from langchain.chat_models import ChatOpenAI
docs = TextLoader("manual.txt").load()
splits = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=50).split_documents(docs)
db = Chroma.from_documents(splits, OpenAIEmbeddings())
qa = RetrievalQA.from_chain_type(llm=ChatOpenAI(), retriever=db.as_retriever())
print(qa.run("What does the manual say about warranty?"))
Load document, split into chunks, embed, index, configure retriever, connect to LLM, and expose a question-answering function. All in 8 operative lines. Prototyping speed is real.
Patterns Where It Truly Adds Value
Three cases where LangChain is the right choice:
- Prototypes and exploration. When validating an idea, getting to a demo fast matters more than having optimal code.
- Orchestrating multiple LLMs and tools. If your system combines OpenAI, Anthropic, web search, internal DB, and conversational memory, LangChain already has each piece with a consistent interface.
- Junior teams with LLMs. Abstractions reduce the space of common errors (prompt format, token management, output parsing).
Frequent (Justified) Criticism
LangChain has received serious criticism in 2023 worth knowing:
- Too much abstraction. For simple cases, it hides what’s actually happening under layers. Debugging gets hard when something fails — you need to understand the abstraction + what’s beneath.
- Unstable API. Incompatible changes between minor versions. Code from 3 months ago may not compile today.
- Over-engineering. Some abstractions seem designed to impress more than to solve real problems (chains of chains of chains).
- Performance penalty. Python layer over HTTP calls adds latency. For production at scale, coding closer to the metal may pay off.
- Volatile documentation. The library evolves so fast that public tutorials and blogs are constantly outdated.
In response, a “LangChain too much for me” current has emerged — teams preferring direct code. For serious production, that criticism is legitimate.
Alternatives and Different Philosophies
If LangChain feels heavy, there are options:
- LlamaIndex: specific focus on RAG and document indexing, less pretense of “universal framework”. Simpler if your case is retrieval.
- Instructor: for structured extraction with Pydantic. Much simpler if that’s all you need.
- Direct calls + small utilities. For many production products it’s the more maintainable option: openai-python + your logic + your favourite vector DB.
- Semantic Kernel by Microsoft. More aligned with .NET but Python available.
The right choice depends on how much of the framework you actually need and how much magic you tolerate underneath.
My Recommendation
For 2023 I propose this criterion:
- Prototypes, hackathons, exploration: LangChain. Saves hours of plumbing.
- Production of a single well-defined use case: very likely direct code. Maintainability beats initial speed.
- Product with multiple LLM flows, multiple integrations, large team: LangChain or equivalent. Uniformity matters.
- If LangChain blocks you on performance or opacity: don’t hesitate to migrate to direct code or LlamaIndex in critical modules. Migration isn’t traumatic if your business logic is well separated.
Conclusion
LangChain is a valuable framework that has accelerated the LLM ecosystem’s maturation in 2023. Its criticisms are fair but so is its usefulness. The key is applying it where its abstractions add more than they hide. For serious products, knowing it is useful even if you eventually decide not to use it — understanding its patterns will tell you what needs to be in your code.
Follow us on jacar.es for more on AI frameworks, RAG, and LLM product building.