Vector Search Using the Deep Lake Tensor Database

Running Vector Search in the Deep Lake Tensor Database

How to Run Vector Search in the Deep Lake Tensor Database

triangle-exclamation

Deep Lake offers a Managed Tensor Database for querying datasets, including vector search. The database is serverless, which simplifies self-hosting and substantially lowers costs. This tutorial demonstrates how to execute embedding search on a Deep Lake dataset using the REST API for the Tensor Database.

Creating the Dataset

A Deep Lake dataset containing embeddings can be created using a variety of APIs, including Deep Lake's LangChain integration.

triangle-exclamation
dataset_path = "hub://<org_id>/<dataset_name>"
runtime = {"db_engine": True}

# from langchain.vectorstores import DeepLake
# db = DeepLake.from_documents(texts, embeddings, dataset_path=dataset_path, runtime = runtime)

In this tutorial, the dataset has already been created can be found herearrow-up-right.

Let's query our dataset stored in the Managed Tensor Database using the REST API. The steps are:

  1. Define the authentication tokens and search terms

  2. Embed the search search term using OpenAI

  3. Reformat the embedding to an embedding_search string that can be passed to the REST API request.

  4. Create the query string using Deep Lake TQL. The dataset_path and embedding_search are a part of the query string.

  5. Submit the request and print the response data data

Congrats! You performed a vector search using the Deep Lake Managed Database! πŸŽ‰

Last updated

Was this helpful?