This project is a Retrieval-Augmented Generation (RAG) Q&A bot built in a Jupyter Notebook. It allows users to upload a custom document, which is then processed and stored in a Pinecone vector database using OpenAI embeddings. Users can ask questions about the document's content and receive accurate, context-aware answers generated by an OpenAI language model.
- Dynamic Document Upload: Users can upload their own text-based documents (.txt, .md, etc.) to be used as the knowledge base.
- Vector-Based Retrieval: Utilizes Pinecone's vector database for efficient similarity search and retrieval of relevant document passages.
- AI-Powered Answers: Leverages OpenAI's language models to generate human-like answers based on the retrieved context.
- Interactive Q&A: Provides a simple input prompt for users to ask questions and receive answers directly within the notebook.
The application follows a RAG architecture:
- Upload: The user uploads a document.
- Load & Chunk: The document is loaded and split into smaller, manageable chunks of text.
- Embed & Store: Each text chunk is converted into a numerical vector representation (embedding) using OpenAI's models. These embeddings are then stored in a Pinecone vector index.
- Query: When a user asks a question, their query is also converted into an embedding.
- Retrieve: Pinecone searches the index for the text chunks with embeddings most similar to the user's query embedding.
- Generate: The retrieved text chunks and the original user query are passed to an OpenAI language model, which generates a final, coherent answer.
- Python 3.x
- Jupyter Notebook or JupyterLab
- An OpenAI API key
- A Pinecone API key
-
Clone the repository:
git clone https://github.com/TashonBraganca/RAG-Q-A-.git cd RAG-Q-A- -
Open the notebook: Open the
RAG_Q_A_Bot.ipynbfile in Jupyter Notebook or JupyterLab.
- Run the first cell to install the required Python libraries.
- Run the API key cell. You will be prompted to enter your OpenAI and Pinecone API keys securely.
- Run the file upload cell. You will be prompted to upload your own document.
- Run the remaining cells in order to process your document, set up the Pinecone index, and initialize the Q&A chain.
- Ask a question! In the final cell, enter your question into the input box and run the cell to receive an answer.
- LangChain: The primary framework for building the RAG pipeline.
- OpenAI: Used for generating text embeddings and for the final answer generation.
- Pinecone: The vector database used for storing and retrieving document embeddings.
- Jupyter Notebook: The environment for running the interactive Q&A bot.