In this post we'll demonstrate how to build RAG (Retrieval Augmentation) pipelines using Python. We'll DEMO two different ways one using raw text documents and another using PDF files. Let's jump right in.

First, we need to install dependencies:

Once we have the dependencies installed, we need to import these into our code.

Note that we have imported both TextLoader and PyPDFLoader into our environment we'll demonstrate how to use both.

Next, we'll need to import some LLM provider's API key.

Shifting gears, we now have to load and chunk our documents. Let's demonstrate how to load and chunk a simple text document and then a pdf file.

For PDF files we use the pypdf library and RecursiveCharacterTextSplitter as shown below:

Now, all that's left to do is embed our document chunks, store them in a FAISS vector index

And finally call our agent chain shown below: