LangChain API
Search Options for Deep Lake Vector Stores in LangChain
This tutorial requires installation of:
Vector Search in Python
Let's load the same vector store used in the Quickstart and run embeddings search based on a user prompt using the LangChain API.
Vector Similarity Search
Let's run a similarity search on Paul Graham's essay based on a query we want to answer. The query is embedded and a similarity search is performed against the stored embeddings, with execution taking place on the client.
If we print the first document using query_docs[0].page_content
, it appears to be relevant to the query:
Vector Search in an LLM Context
We can directly use LangChain to run a Q&A using an LLM and answer the question about Paul Graham's essay. Internally, this API performs an embedding search to find the most relevant data to feeds them into the LLM context.
'The first programs he tried writing were on the IBM 1401 that his school district used for "data processing" in 9th grade.'
Vector Search Using the Compute Engine on the Client Side in LangChain
The workflow above can also be performed on the client using Deep Lake's Compute Engine, which offers faster execution for larger Vector Stores and complex queries.
The similarity search, queries are executed on Compute Engine by and by specifying exec_option = "compute_engine"
in the parameters for similarity_search
.
For chains, we should specify the exec_option
as "compute_engine"
in the search_kwargs
.
Vector Search Using the Managed Tensor Database in LangChain
Vector search using the Tensor Database + LangChain API will be available soon.
Last updated