AI / LangGraph LangChain Interview questions
What are Chains in LangChain?
A Chain in LangChain is any sequence of processing steps that takes an input, passes it through one or more components (prompts, models, retrievers, tools), and produces an output. Chains are the fundamental unit of composition — everything from a single prompt+model call to a multi-step RAG pipeline is a chain.
The modern way to build chains is with LCEL (using the | operator). Legacy chain classes still exist but are deprecated:
| Legacy Class | LCEL Equivalent |
|---|---|
| LLMChain | prompt | llm | StrOutputParser() |
| SimpleSequentialChain | chain1 | chain2 | chain3 |
| RetrievalQA | (retriever | format_docs) | prompt | llm | StrOutputParser() |
| ConversationalRetrievalChain | RunnablePassthrough + retriever + prompt | llm |
Every LCEL chain is itself a Runnable, so chains compose recursively — a chain can be embedded inside another chain as a step. The main practical patterns are: simple prompt chain (question → answer), RAG chain (question → retrieve → augment → answer), and agent loop (question → plan → tool → observe → answer).
More Related questions...