Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the main purpose of LangChain?
LangChain helps developers build applications that use language models by connecting them with other tools and data sources.
Click to reveal answer
beginner
Name the four core modules of LangChain architecture.
The four core modules are: 1) Prompt Templates, 2) Language Models, 3) Chains, and 4) Agents.
Click to reveal answer
beginner
What role do Prompt Templates play in LangChain?
Prompt Templates help create clear and reusable instructions for the language model, like a recipe for what to say or do.
Click to reveal answer
intermediate
How do Chains work in LangChain?
Chains connect multiple steps or calls to language models and tools in a sequence, like following a checklist to complete a task.
Click to reveal answer
intermediate
What is the function of Agents in LangChain?
Agents decide which tools or actions to use based on user input and can call language models and external tools dynamically, like a smart assistant choosing the best tool for a job.
Click to reveal answer
Which LangChain module helps create reusable instructions for language models?
APrompt Templates
BChains
CAgents
DMemory
✗ Incorrect
Prompt Templates are used to create clear and reusable instructions for language models.
What does a Chain in LangChain do?
ADecides which tool to use dynamically
BStores user conversation history
CConnects multiple steps or calls in sequence
DCreates prompt templates
✗ Incorrect
Chains connect multiple steps or calls to language models and tools in a sequence.
Agents in LangChain are best described as:
AStatic prompt templates
BDynamic decision makers for tool usage
CSimple language models
DData storage modules
✗ Incorrect
Agents decide dynamically which tools or actions to use based on input.
Which module is NOT one of the core LangChain architecture parts?
APrompt Templates
BChains
CAgents
DDatabases
✗ Incorrect
Databases are not a core module; LangChain focuses on prompt templates, chains, agents, and language models.
LangChain primarily helps developers to:
ABuild applications using language models and tools
BCreate databases
CDesign user interfaces
DWrite low-level system code
✗ Incorrect
LangChain is designed to help build applications that use language models connected with tools and data.
Explain the four core modules of LangChain architecture and their roles.
Think of how each part helps build a smart language-based app.
You got /4 concepts.
Describe how LangChain helps developers build applications with language models.
Imagine building a smart assistant that can do many things.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of a chain in LangChain architecture?
easy
A. To link different steps like prompts and LLMs to build language apps
B. To store data permanently in a database
C. To create user interfaces for language models
D. To train new language models from scratch
Solution
Step 1: Understand the role of chains
Chains connect parts like prompt templates and language models to form a workflow.
Step 2: Identify the main purpose
Chains help organize and link these steps to build smart language apps easily.
Final Answer:
To link different steps like prompts and LLMs to build language apps -> Option A
Quick Check:
Chains link steps = D [OK]
Hint: Chains connect prompts and models to build apps [OK]
Common Mistakes:
Thinking chains store data permanently
Confusing chains with UI components
Assuming chains train models
2. Which of the following is the correct way to create a prompt template in LangChain?
easy
A. PromptTemplate.create("Hello, {name}!")
B. PromptTemplate("Hello, {name}!")
C. PromptTemplate(template="Hello, {name}!")
D. PromptTemplate.new(template="Hello, {name}!")
Solution
Step 1: Recall PromptTemplate syntax
PromptTemplate requires a named argument 'template' with the string pattern.
Step 2: Match syntax to options
Only PromptTemplate(template="Hello, {name}!") uses PromptTemplate(template="...") correctly.
Final Answer:
PromptTemplate(template="Hello, {name}!") -> Option C
Quick Check:
Named 'template' argument = A [OK]
Hint: Use named 'template' argument to create PromptTemplate [OK]
Common Mistakes:
Passing template string without argument name
Using non-existent create() or new() methods
Confusing positional and keyword arguments
3. Given this code snippet, what will be the output?
from langchain import PromptTemplate, LLMChain
prompt = PromptTemplate(template="What is the capital of {country}?")
chain = LLMChain(prompt=prompt)
result = chain.run(country="France")
print(result)
medium
A. "Paris"
B. An error because LLM is missing
C. "What is the capital of France?"
D. "France"
Solution
Step 1: Analyze the code components
The chain is created with a prompt but no LLM (language model) is provided.
Step 2: Understand LangChain requirements
LLMChain needs an LLM to generate answers; missing it causes an error.
Final Answer:
An error because LLM is missing -> Option B
Quick Check:
LLM missing causes error = B [OK]
Hint: LLMChain needs an LLM instance to run [OK]
Common Mistakes:
Assuming chain.run returns prompt text
Expecting output without LLM
Confusing prompt template with output
4. Identify the error in this LangChain code snippet:
from langchain import PromptTemplate, LLMChain
prompt = PromptTemplate(template="Say hello to {name}")
chain = LLMChain(prompt=prompt, llm=None)
output = chain.run(name="Alice")
print(output)
medium
A. LLMChain requires a valid LLM, not None
B. PromptTemplate syntax is incorrect
C. run() method does not accept arguments
D. Missing import for LLM class
Solution
Step 1: Check PromptTemplate usage
PromptTemplate is correctly created with a template string.
Step 2: Check LLMChain initialization
LLMChain requires a valid LLM object; passing None causes failure.
Final Answer:
LLMChain requires a valid LLM, not None -> Option A
Quick Check:
LLM must be valid, not None = A [OK]
Hint: LLMChain needs a real LLM instance, not None [OK]
Common Mistakes:
Thinking run() can't take arguments
Assuming PromptTemplate syntax is wrong
Missing imports but not causing this error
5. You want to build a LangChain app that asks a user's name, then uses an LLM to greet them. Which architecture correctly links these parts?
hard
A. Create a PromptTemplate and run it directly without an LLMChain
B. Create an LLMChain without a prompt and run it with user input
C. Create an LLM instance and call it directly without prompt or chain
D. Create a PromptTemplate for the question, then an LLMChain with that prompt and an LLM, then run the chain with user input
Solution
Step 1: Understand LangChain app structure
PromptTemplate creates the question, LLMChain links prompt and LLM to generate answers.
Step 2: Identify correct linking
Create a PromptTemplate for the question, then an LLMChain with that prompt and an LLM, then run the chain with user input correctly creates prompt, then LLMChain with prompt and LLM, then runs with input.
Final Answer:
Create a PromptTemplate for the question, then an LLMChain with that prompt and an LLM, then run the chain with user input -> Option D