Skip to content

Retrieval Augmented Generation (RAG) with Langchain

Retrieval Augumented Generation (RAG) is an architectural pattern that can be used to augment the performance of language models by recalling factual information from a knowledge base, and adding that information to the model query.

The goal of this lab is to show how you can use RAG with an IBM Granite model to augment the model query answer using a publicly available document.

Pre-requisite

This lab is a Jupyter notebook. Please follow the instructions in pre-work to run the lab.

Lab

Retrieval Augmented Generation (RAG) with Langchain notebook Retrieval Augmented Generation (RAG) with Langchain notebook

To run the notebook from your command line in Jupyter using the active virtual environment from the pre-work, run:

jupyter notebook notebooks/RAG_with_Langchain.ipynb

The path of the notebook file above is relative to the granite-workshop folder from the git clone in the pre-work.

Credits

This notebook is a modified version of the IBM Granite Community Retrieval Augmented Generation (RAG) with Langchain notebook. Refer to the IBM Granite Community for the official notebooks.