Bird
0
0

Given the code below, what will be the output of print(results) if both prompt variations return 'Hello Alice' and 'Hi Alice' respectively?

medium📝 component behavior Q4 of 15
LangChain - Evaluation and Testing
Given the code below, what will be the output of print(results) if both prompt variations return 'Hello Alice' and 'Hi Alice' respectively?
prompts = [PromptTemplate(template='Hello {name}'), PromptTemplate(template='Hi {name}')]
multi_chain = MultiPromptChain(prompts=prompts, llm=llm)
results = multi_chain.run({'name': 'Alice'})
A'Hello Alice'
B['Hello Alice', 'Hi Alice']
CError: MultiPromptChain does not support run()
D{'prompt_1': 'Hello Alice', 'prompt_2': 'Hi Alice'}
Step-by-Step Solution
Solution:
  1. Step 1: Understand MultiPromptChain output format

    MultiPromptChain returns a dictionary with keys for each prompt variation and their outputs.
  2. Step 2: Match expected output

    Since two prompts run, output is a dict with keys like 'prompt_1' and 'prompt_2' and their respective results.
  3. Final Answer:

    {'prompt_1': 'Hello Alice', 'prompt_2': 'Hi Alice'} -> Option D
  4. Quick Check:

    MultiPromptChain output = dict of prompt results [OK]
Quick Trick: MultiPromptChain returns dict with keys for each prompt [OK]
Common Mistakes:
MISTAKES
  • Expecting a list instead of dict
  • Expecting a single string output
  • Assuming run() method is unsupported

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes