Bird
0
0

Given this code snippet, what will be printed?

medium📝 Predict Output Q5 of 15
LangChain - Embeddings and Vector Stores
Given this code snippet, what will be printed?
from langchain.embeddings import HuggingFaceEmbeddings
model = HuggingFaceEmbeddings()
texts = ["apple", "banana"]
embeddings = model.embed_documents(texts)
print(len(embeddings))
A1
B2
C0
DError
Step-by-Step Solution
Solution:
  1. Step 1: Understand embed_documents behavior

    embed_documents returns a list of embeddings, one per input text.
  2. Step 2: Count embeddings returned

    Since input has 2 texts, output list length is 2.
  3. Final Answer:

    2 -> Option B
  4. Quick Check:

    Embedding list length = B [OK]
Quick Trick: One embedding per input text string [OK]
Common Mistakes:
  • Expecting a single embedding for multiple texts
  • Assuming output is empty or error
  • Confusing embed_query with embed_documents

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes