This folder has examples of RAG applications with data prep kit (DPK).
## Clone this repo
git clone https://github.com/IBM/data-prep-kit
cd data-prep-kit
## All commands from here on out, assume you are in project root directory
Make sure Jupyter is running after this step. We will use this Jupyter instance to run the notebooks in next steps.
Here is the overall work flow. For details see RAG-explained
This code uses DPK to
- Extract text from PDFs (RAG stage-1)
- Performs de-dupes (RAG stage-1)
- split the documents into chunks (RAG stage-2)
- vectorize the chunks (RAG stage-3)
Here is the code:
- Python version: rag_1A_dpk_process_python.ipynb
- Ray version: rag_1A_dpk_process_ray.ipynb
Our vector database is Milvus
Run the code: rag_1B_load_data_into_milvus.ipynb
Be sure to shutdown the notebook before proceeding to the next step
Let's do a few searches on our data.
Code: rag_1C_vector_search.ipynb
Be sure to shutdown the notebook before proceeding to the next step
We will use Llama as our LLM running on Replicate service.
To use replicate service, we will need a replicate API token.
You can get one from Replicate
Create an .env
file (notice the dot in the file name in this directory with content like this
REPLICATE_API_TOKEN=your REPLICATE token goes here
Code: rag_1D_query_llama_replicate.ipynb
For comparision, we can use Llama-index framework to process PDFs and query
Code: rag_2A_llamaindex_process.ipynb
Be sure to shutdown the notebook before proceeding to the next step
code: rag_2B_llamaindex_query.ipynb
When using embedded database, the program maintains a lock on the database file. If the lock is active, other notebooks may not be able to access the same database.
Here is how to close kernels:
- In vscode: Restart the kernel. This will end the current kernel session and release the db.lock
- In Jupyter : Go to
File --> Close and shutdown notebook
. This will end the current kernel session and release the db.lock