BaşlayınÜcretsiz başlayın

Querying with multiple texts

In many cases, you'll want to query the vector database using multiple query texts. Recall that these query texts are embedded using the same embedding function as when the documents were added.

In this exercise, you'll use the documents from two IDs in the netflix_titles collection to query the rest of the collection, returning the most similar results as recommendations.

The netflix_titles collection is still available to use, and OpenAIEmbeddingFunction() has been imported.

Bu egzersiz, kursun bir parçasıdır

Introduction to Embeddings with the OpenAI API

Kursa Göz Atın

Egzersiz talimatları

  • Retrieve the documents from the collection for the IDs in reference_ids.
  • Query the collection using reference_texts to return three results for each query.

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

collection = client.get_collection(
  name="netflix_titles",
  embedding_function=OpenAIEmbeddingFunction(model_name="text-embedding-3-small", api_key="")
)

reference_ids = ['s999', 's1000']

# Retrieve the documents for the reference_ids
reference_texts = ____

# Query using reference_texts
result = ____

print(result['documents'])
Kodu Düzenle ve Çalıştır