Skip to content

Latest commit

 

History

History
114 lines (70 loc) · 6.88 KB

README.md

File metadata and controls

114 lines (70 loc) · 6.88 KB

Roo-VectorDB Tutorials

We will show our tutorials in Jupyter notebooks. Please follow the preparing steps below before running notebooks.

Create a python virtual environment

The tutorial code is written in python, we need to prepare a standalone virtual environemnt for tutorial only. Say this virtual environment name is roovenv, then you can created it by run:

cd tutorials
python3 -m venv roovenv

(If you have virtualenv installed, an alternative approach for creating roovenv could be virtualenv -p python3 roovenv.)

Install requirement packages

Activate the environment by run:

source roovenv/bin/activate

and install all requirement packages that are needed in the following tutorials by run:

pip install -r requirements.txt

(Some package may require python-dev package. In Ubuntu you can just run sudo apt-get install python-dev)

Pointing Jupyter kernal to the new created virtual environment

Then register roovenv as a candidate kernel:

python3 -m ipykernel install --user --name=roovenv --display-name "RooVenv"

Now start Jupyter server

jupyter notebook

In any notebook page, under the menu "Kernel" -> "Change Kernel", you should be able to see RooVenv as one of candidate kernels to select. Select RooVenv kernel to run any tutorial notebooks.


Full Text Search

In this tutorial, we show how to perform a full text search with Roo-VectorDB.

Download data and embedding model

In this tutorial, we use the Amazon-QA dataset. Each entry in the dataset consists of a question followed by one or more corresponding answers (user reviews). We process the data by enumerating each answer and pairing it with its associated question to form distinct question-answer pairs. We then create a table with three metadata columns: question, answer, and a concatenated question+answer field. Embeddings are computed from this combined text, allowing vector search to capture semantic similarity across both the question and its answer.

The embedding vectors are generated on-the-fly using aSentence Transformer model. To enable this, the model file will be downloaded beforehand.

  1. Amazon-QA text data jsonl file: amazon-qa.jsonl (678MB)

Please verify the file size after downloading to ensure the download completed successfully and the file is not corrupted.

Start and follow steps of tutorial

First, start the PostgreSQL server with the Roo-VectorDB extension enabled. Then launch the Jupyter server and open the tutorial_text_search.ipynb notebook. Follow the instructions step by step. In the first few steps (steps 1–2), you’ll need to provide some basic configuration information before proceeding.


Image Search

In this tutorial, we show how to perform image search with Roo-VectorDB.

Download image data and image embedding files

We use Imagenet Train Subset 100k dataset, a subset of full ImageNet data in this tutorial. Two files need to be downloaded first.

  1. The original image dataset zip file: archive.zip (Login Kaggle and click Download) (10.6GB)
  2. The precomputed image embedding file: imgnet100k_dim128.txt (248.3MB)

Please verify the file size after downloading to ensure the download completed successfully and the file is not corrupted.

For (2), there are two alternative choices:

You are free to choose any of the available embedding files to experiment with. However, make sure to set the embedding_file_info tuple in the notebook with values that match your selection. For example, if you choose "imgnet100k_dim2048.txt", be sure to set the embedding dimension to 2048 accordingly.

Start and follow steps of tutorial

First, start the PostgreSQL server with the Roo-VectorDB extension enabled. Then launch the Jupyter server and open the tutorial_image_search.ipynb notebook. Follow the instructions step by step. In the first few steps (steps 1–2), you’ll need to provide some basic configuration information before proceeding.


Long Document Search

In this tutorial, we demonstrate how to perform long-document search using Roo-VectorDB. As an example, we treat books as long documents, and show how to run searches at different levels of granularity—such as chapters, sections, paragraphs, or the entire book.

Download segmented book data

We use the Pile dataset (specifically the Books1 subset) as the source of data. This subset contains approximately 18,000 books, each ranging from 100,000 to 1,000,000 words. For this tutorial, we randomly sample 1,000 books from the dataset. Because a single book is too large to store as one record—making both storage and search inefficient—we preprocess the books using LangChain TextSplitter. Each book is split into 1024‑token chunks with a 30% overlap between adjacent chunks. Each chunk is stored as an individual row in the database table. The preprocessed dataset can be downloaded here:

  1. Preprocessed Pile Books1 data file: pile_book1.jsonl (506.5MB)

Please verify the file size after downloading to ensure the download completed successfully and the file is not corrupted.

Start and follow steps of tutorial

First, start the PostgreSQL server with the Roo-VectorDB extension enabled. Then launch the Jupyter server and open the tutorial_long_document_search.ipynb notebook. Follow the instructions step by step. In the first few steps (steps 1–2), you’ll need to provide some basic configuration information before proceeding.