Hint: Focus on improving chatbot understanding of follow-ups [OK]
Common Mistakes:
Confusing reformulation with speed optimization
Thinking it stores personal data
Assuming it translates languages
2. Which of the following is the correct way to create a ConversationChain in LangChain that uses question reformulation with history?
easy
A. chain = ConversationChain(llm=llm, memory=ConversationBufferMemory())
B. chain = ConversationChain(memory=llm, llm=ConversationBufferMemory())
C. chain = ConversationChain(llm=llm, history=ConversationBufferMemory())
D. chain = ConversationChain(buffer=llm, memory=ConversationBufferMemory())
Solution
Step 1: Recall the correct parameter names
ConversationChain expects an LLM instance as 'llm' and a memory object as 'memory'.
Step 2: Match the correct syntax
chain = ConversationChain(llm=llm, memory=ConversationBufferMemory()) correctly assigns 'llm=llm' and 'memory=ConversationBufferMemory()'. Others mix parameter names or use incorrect ones.
Final Answer:
chain = ConversationChain(llm=llm, memory=ConversationBufferMemory()) -> Option A
Quick Check:
Correct parameters = llm and memory [OK]
Hint: Remember 'llm' and 'memory' are required parameters [OK]
Common Mistakes:
Swapping 'llm' and 'memory' parameters
Using 'history' instead of 'memory'
Passing wrong argument names
3. Given the following code snippet, what will be the output after the second question?
from langchain.chains import ConversationChain
from langchain.memory import ConversationBufferMemory
llm = SomeLLM()
memory = ConversationBufferMemory()
chain = ConversationChain(llm=llm, memory=memory)
print(chain.run("What is AI?"))
print(chain.run("And how does it learn?"))
medium
A. The memory will reset after each question
B. The second answer will ignore the first question
C. The second answer will consider the first question's context
B. ConversationBufferMemory is not instantiated with parentheses
C. The run method does not exist on ConversationChain
D. The print statement is missing parentheses
Solution
Step 1: Check how ConversationBufferMemory is used
It must be instantiated with parentheses to create an object, but here it's passed as a class.
Step 2: Verify other parts
llm is defined, run method exists, and print syntax is correct in Python 3.
Final Answer:
ConversationBufferMemory is not instantiated with parentheses -> Option B
Quick Check:
Instantiate classes with () [OK]
Hint: Always add () when creating memory instance [OK]
Common Mistakes:
Forgetting parentheses when instantiating classes
Assuming run method is missing
Confusing print syntax in Python 3
5. You want to improve a chatbot to handle multi-turn conversations with question reformulation using LangChain. Which approach best achieves this?
hard
A. Use ConversationChain with ConversationBufferMemory to keep history and reformulate questions
B. Use a simple LLM call without memory for faster responses
C. Store conversation history manually in a list and pass only the last question to the LLM
D. Use ConversationChain but reset memory after each question to avoid confusion
Solution
Step 1: Understand multi-turn conversation needs
Keeping conversation history helps the chatbot understand context and reformulate questions properly.
Step 2: Evaluate options
Use ConversationChain with ConversationBufferMemory to keep history and reformulate questions uses ConversationChain with memory, which automates history management and reformulation. Others either ignore history or reset it, losing context.
Final Answer:
Use ConversationChain with ConversationBufferMemory to keep history and reformulate questions -> Option A
Quick Check:
Memory + ConversationChain = best multi-turn handling [OK]
Hint: Use ConversationChain with memory for natural multi-turn chats [OK]
Common Mistakes:
Ignoring conversation history
Resetting memory too often
Manually managing history inefficiently
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.