Vectara self-querying
Vectara is the trusted AI Assistant and Agent platform which focuses on enterprise readiness for mission-critical applications.
Vectara serverless RAG-as-a-service provides all the components of RAG behind an easy-to-use API, including:
- A way to extract text from files (PDF, PPT, DOCX, etc)
- ML-based chunking that provides state of the art performance.
- The Boomerang embeddings model.
- Its own internal vector database where text chunks and embedding vectors are stored.
- A query service that automatically encodes the query into embedding, and retrieves the most relevant text segments, including support for Hybrid Search as well as multiple reranking options such as the multi-lingual relevance reranker, MMR, UDF reranker.
- An LLM to for creating a generative summary, based on the retrieved documents (context), including citations.
See the Vectara API documentation for more information on how to use the API.
This notebook shows how to use SelfQueryRetriever
with Vectara.
Getting Started
To get started, use the following steps:
- If you don't already have one, Sign up for your free Vectara trial. Once you have completed your sign up you will have a Vectara customer ID. You can find your customer ID by clicking on your name, on the top-right of the Vectara console window.
- Within your account you can create one or more corpora. Each corpus represents an area that stores text data upon ingest from input documents. To create a corpus, use the "Create Corpus" button. You then provide a name to your corpus as well as a description. Optionally you can define filtering attributes and apply some advanced options. If you click on your created corpus, you can see its name and corpus ID right on the top.
- Next you'll need to create API keys to access the corpus. Click on the "Access Control" tab in the corpus view and then the "Create API Key" button. Give your key a name, and choose whether you want query-only or query+index for your key. Click "Create" and you now have an active API key. Keep this key confidential.
To use LangChain with Vectara, you'll need to have these three values: customer ID
, corpus ID
and api_key
.
You can provide those to LangChain in two ways:
-
Include in your environment these three variables:
VECTARA_CUSTOMER_ID
,VECTARA_CORPUS_ID
andVECTARA_API_KEY
.For example, you can set these variables using os.environ and getpass as follows:
import os
import getpass
os.environ["VECTARA_CUSTOMER_ID"] = getpass.getpass("Vectara Customer ID:")
os.environ["VECTARA_CORPUS_ID"] = getpass.getpass("Vectara Corpus ID:")
os.environ["VECTARA_API_KEY"] = getpass.getpass("Vectara API Key:")
- Add them to the
Vectara
vectorstore constructor:
vectara = Vectara(
vectara_customer_id=vectara_customer_id,
vectara_corpus_id=vectara_corpus_id,
vectara_api_key=vectara_api_key
)
In this notebook we assume they are provided in the environment.
Notes: The self-query retriever requires you to have lark
installed (pip install lark
).