馃憪 Add embeddings to the data
Now that you know how to generate embeddings using the CLIP model, let's add embeddings to the books dataset you previously imported into MongoDB.
This is a common scenario you will run into where you might want to update your existing data in MongoDB with embeddings.
Fill in any <CODE_BLOCK_N>
placeholders and run the cells under the Step 4: Adding embeddings to existing data in Atlas section in the notebook to add embeddings of the books' cover images to the documents in the books
collection.
The answers for code blocks in this section are as follows:
CODE_BLOCK_4
Answer
collection.find({})
CODE_BLOCK_5
Answer
get_embedding(content, "image")
CODE_BLOCK_6
Answer
{"$set": {embedding_field: embedding}}
CODE_BLOCK_7
Answer
collection.update_one(filter, update)
You can verify that embeddings have been added to the documents in the books
collection using the Atlas UI:
