Bird
0
0

Which of the following is the correct way to create a few-shot prompt template in Langchain?

easy📝 Syntax Q12 of 15
LangChain - Prompt Templates
Which of the following is the correct way to create a few-shot prompt template in Langchain?
AFewShotPromptTemplate(data=examples, prompt=example_prompt, suffix=prefix_text)
BFewShotPromptTemplate(samples=examples, prompt_template=example_prompt, header=prefix_text)
CFewShotPromptTemplate(examples=examples, example_prompt=example_prompt, prefix=prefix_text)
DFewShotPromptTemplate(inputs=examples, prompt=example_prompt, footer=prefix_text)
Step-by-Step Solution
Solution:
  1. Step 1: Recall Langchain few-shot prompt syntax

    The correct constructor uses parameters: examples, example_prompt, and prefix.
  2. Step 2: Match parameters to options

    Only FewShotPromptTemplate(examples=examples, example_prompt=example_prompt, prefix=prefix_text) uses the exact parameter names required by Langchain's FewShotPromptTemplate.
  3. Final Answer:

    FewShotPromptTemplate(examples=examples, example_prompt=example_prompt, prefix=prefix_text) -> Option C
  4. Quick Check:

    Correct parameter names = B [OK]
Quick Trick: Check parameter names exactly as in Langchain docs [OK]
Common Mistakes:
  • Using wrong parameter names like data or samples
  • Mixing prefix with suffix or footer
  • Confusing example_prompt with prompt_template

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes