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 does 'retrieved context' mean when working with a Large Language Model (LLM)?
Retrieved context is extra information or data fetched from an external source to help the LLM give better and more accurate answers.
Click to reveal answer
beginner
Why do we combine retrieved context with an LLM's input?
We combine retrieved context with the LLM's input to provide it with relevant facts or details it might not remember, improving the quality of its responses.
Click to reveal answer
intermediate
Name one common method to combine retrieved context with an LLM.
One common method is to prepend the retrieved context as extra text before the user's question, so the LLM reads it all together.
Click to reveal answer
intermediate
What is a potential challenge when combining retrieved context with an LLM?
A challenge is that the combined input might become too long, exceeding the LLM's maximum token limit, which can cause errors or cut off information.
Click to reveal answer
beginner
How can combining retrieved context with an LLM improve real-life applications?
It helps in tasks like customer support or research by giving the LLM up-to-date or specific information, making answers more useful and trustworthy.
Click to reveal answer
What is the main purpose of adding retrieved context to an LLM's input?
ATo make the LLM run faster
BTo provide extra relevant information for better answers
CTo reduce the size of the input text
DTo confuse the LLM
✗ Incorrect
Adding retrieved context gives the LLM more relevant facts, helping it generate better responses.
Which of the following is a common way to combine retrieved context with an LLM?
AReplacing the question with context
BIgnoring the context completely
CSending context after the answer
DPrepending the context before the question
✗ Incorrect
Prepending the context before the question lets the LLM read all information together.
What can happen if the combined input with context is too long for the LLM?
AThe LLM may cut off some information or error out
BThe LLM will answer faster
CThe LLM will ignore the question
DThe LLM will learn new facts
✗ Incorrect
LLMs have token limits; exceeding them can cause truncation or errors.
Why is retrieved context important for up-to-date answers?
ABecause LLMs may not know recent information
BBecause LLMs always know everything
CBecause context slows down the model
DBecause context replaces the LLM
✗ Incorrect
LLMs are trained on past data and may miss recent facts; context fills that gap.
Which real-life task benefits from combining retrieved context with an LLM?
APlaying video games
BDrawing pictures
CCustomer support with specific product info
DListening to music
✗ Incorrect
Customer support needs accurate, specific info, which context helps provide.
Explain how combining retrieved context with an LLM improves the quality of its responses.
Think about what the LLM knows and what it might miss.
You got /3 concepts.
Describe one challenge when adding retrieved context to an LLM input and how it might be handled.
Consider the LLM's maximum input size.
You got /3 concepts.
Practice
(1/5)
1. Why do we combine retrieved context with a large language model (LLM)?
easy
A. To give the model extra information it did not learn before
B. To make the model run faster
C. To reduce the size of the model
D. To replace the model's training data
Solution
Step 1: Understand the purpose of retrieved context
Retrieved context provides additional information that the model might not have seen during training.
Step 2: Connect context to model output quality
Providing this extra information helps the model give better and more accurate answers.
Final Answer:
To give the model extra information it did not learn before -> Option A
Quick Check:
Extra info improves answers = D [OK]
Hint: Extra info helps model answer better [OK]
Common Mistakes:
Thinking context speeds up the model
Believing context shrinks the model size
Assuming context replaces training data
2. Which of the following is the correct way to combine retrieved context with an LLM prompt?
easy
A. prompt = question * context
B. prompt = question + context
C. prompt = context + ' ' + question
D. prompt = context - question
Solution
Step 1: Understand prompt construction
The prompt should start with the context followed by the question to give the model relevant info first.
Step 2: Check syntax correctness
Using string concatenation with '+' is correct; multiplication or subtraction of strings is invalid.
Final Answer:
prompt = context + ' ' + question -> Option C
Quick Check:
Context before question with '+' = A [OK]
Hint: Concatenate context and question with + [OK]
Common Mistakes:
Putting question before context
Using * or - operators on strings
Not adding space between context and question
3. Given the code below, what will be the output?
context = 'The capital of France is Paris.'
question = 'What is the capital of France?'
prompt = context + ' ' + question
response = llm.generate(prompt)
print(response)
Assuming llm.generate() returns the model's answer, what is the likely output?
medium
A. Paris
B. London
C. I don't know
D. Error: undefined variable
Solution
Step 1: Analyze the prompt content
The prompt includes the context 'The capital of France is Paris.' followed by the question.
Step 2: Predict model output based on context
The model uses the context to answer correctly with 'Paris'.
Final Answer:
Paris -> Option A
Quick Check:
Context guides answer = Paris [OK]
Hint: Context gives correct answer to question [OK]
Common Mistakes:
Ignoring context and guessing wrong
Assuming code error without cause
Thinking model says 'I don't know'
4. You wrote this code to combine context with a question:
context = 'Water boils at 100 degrees Celsius.'
question = 'At what temperature does water boil?'
prompt = question + ' ' + context
response = llm.generate(prompt)
print(response)
Why might the model give a less accurate answer?
medium
A. Because the context is missing important info
B. Because the question comes before the context, confusing the model
C. Because the model cannot handle string concatenation
D. Because the prompt is too short
Solution
Step 1: Check prompt order
The prompt puts the question before the context, which may confuse the model about what info to use.
Step 2: Understand best practice
Context should come first to provide relevant info before the question.
Final Answer:
Because the question comes before the context, confusing the model -> Option B
Quick Check:
Context before question improves accuracy = B [OK]
Hint: Put context before question in prompt [OK]
Common Mistakes:
Thinking model can't concatenate strings
Assuming context lacks info
Believing prompt length is the issue
5. You want to build a system that answers questions about a company's products using an LLM. You have a large product manual. What is the best way to combine the manual with the LLM to get accurate answers?
hard
A. Train a new LLM from scratch on the manual
B. Feed the entire manual as a prompt to the LLM every time
C. Only ask the question without any manual context
D. Retrieve relevant sections from the manual and add them as context before the question in the prompt
Solution
Step 1: Consider prompt size limits
Feeding the entire manual is too large and inefficient for the LLM prompt.
Step 2: Use retrieval to select relevant info
Retrieving relevant sections and adding them as context helps the model answer accurately without overload.
Step 3: Evaluate other options
Asking without context misses info; training new LLM is costly and unnecessary.
Final Answer:
Retrieve relevant sections from the manual and add them as context before the question in the prompt -> Option D
Quick Check:
Relevant context retrieval + LLM = A [OK]
Hint: Retrieve relevant info, then prompt LLM [OK]