Bird
0
0

You want to store multiple vectors with metadata in Pinecone using Langchain. Which approach correctly includes metadata during upsert?

hard📝 component behavior Q8 of 15
LangChain - Embeddings and Vector Stores
You want to store multiple vectors with metadata in Pinecone using Langchain. Which approach correctly includes metadata during upsert?
Aindex.upsert(vectors=[('id1', [0.1, 0.2])], metadata={'color': 'red'})
Bindex.upsert(vectors=[('id1', [0.1, 0.2], {'color': 'red'})])
Cindex.upsert(vectors=[{'id': 'id1', 'vector': [0.1, 0.2], 'metadata': {'color': 'red'}}])
Dindex.upsert(vectors=[('id1', [0.1, 0.2], 'color', 'red')])
Step-by-Step Solution
Solution:
  1. Step 1: Review Pinecone upsert format

    Vectors are tuples of (id, vector, optional metadata dictionary).
  2. Step 2: Match options to format

    Only index.upsert(vectors=[('id1', [0.1, 0.2], {'color': 'red'})]) correctly uses tuple with metadata dictionary as third element.
  3. Final Answer:

    index.upsert(vectors=[('id1', [0.1, 0.2], {'color': 'red'})]) -> Option B
  4. Quick Check:

    Metadata goes as third tuple item [OK]
Quick Trick: Metadata is third item in vector tuple [OK]
Common Mistakes:
  • Passing metadata as separate argument
  • Using dict instead of tuple for vectors
  • Incorrect tuple structure with extra strings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes