Install ApertureDB Python SDK
This installs the Python SDK used to write client code for ApertureDB.Run an ApertureDB instance
To continue, you should have an ApertureDB instance up and running and configure your environment to use it. There are various ways to do that, for example:Download some web documents
We’re going to do a mini-crawl here of one web page.Select embeddings model
We want to use OllamaEmbeddings so we have to import the necessary modules. Ollama can be set up as a docker container as described in the documentation, for example:Split documents into segments
We want to turn our single document into multiple segments.Create vectorstore from documents and embeddings
This code creates a vectorstore in the ApertureDB instance. Within the instance, this vectorstore is represented as a “descriptor set”. By default, the descriptor set is namedlangchain
. The following code will generate embeddings for each document and store them in ApertureDB as descriptors. This will take a few seconds as the embeddings are bring generated.
Select a large language model
Again, we use the Ollama server we set up for local processing.Build a RAG chain
Now we have all the components we need to create a RAG (Retrieval-Augmented Generation) chain. This chain does the following:- Generate embedding descriptor for user query
- Find text segments that are similar to the user query using the vector store
- Pass user query and context documents to the LLM using a prompt template
- Return the LLM’s answer