Bird
0
0

Given the code snippet:

medium📝 Predict Output Q13 of 15
LangChain - RAG Chain Construction
Given the code snippet:
docs = ["Doc1 content", "Doc2 content"]
llm = SomeLLM()
rag_chain = LCEL.RAGChain.from_documents(docs, llm)
answer = rag_chain.run("What is in Doc1?")
print(answer)

What is the expected output?
AAn error because docs should be a string, not a list
BA list of documents including Doc1 and Doc2
CAn answer generated by the LLM based on Doc1 content
DThe string 'What is in Doc1?' printed as is
Step-by-Step Solution
Solution:
  1. Step 1: Understand RAG chain run method

    Running rag_chain.run(question) uses the LLM to answer based on retrieved documents.
  2. Step 2: Analyze input and output

    Docs are provided as a list, which is valid. The output is an AI-generated answer about Doc1 content.
  3. Final Answer:

    An answer generated by the LLM based on Doc1 content -> Option C
  4. Quick Check:

    rag_chain.run(question) = AI answer [OK]
Quick Trick: RAG chain answers questions using docs + LLM [OK]
Common Mistakes:
  • Expecting raw docs list as output
  • Thinking docs must be a single string
  • Assuming run just echoes input question

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes