Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time


This is refrence code for submission of 6001CEM project

RAG Chatbot

A powerful chatbot implementation utilizing the Retrieval Augmented Generation (RAG) technique for informed, contextually rich responses.

Key Features

Contextual Understanding: Leverages a knowledge index to retrieve relevant documents, providing the chatbot with background information for more comprehensive answers. Natural Response Generation: Fine-tuned generative model produces fluent and human-like text responses. Scalable: Can be adapted to various knowledge bases and domains for versatile use cases. Prerequisites

Requirements: • Hardware: o Computer with Intel Core i7 or equivalent, 32GB RAM, 500GB SSD. o NVIDIA P5000 or equivalent GPU with at least 16GB of memory. • Software: o Ubuntu 20.04 LTS o Pytorch 2.2.2 o Python 3.8 o CUDA 11.4 and cuDNN 8.2 o Jupyter Notebook o NumPy, pandas, Matplotlib • Data: o Access to the hugging face dataset . o Access to the OpenAI API o Access to the Meta llama2 model o Access to the Mistral model o Access to the gemma model o Image labelling and augmentation software. • Access:

Bash pip install -r requirements.txt Use code with caution. Getting Started

Prepare Document Store:

Choose your document source (e.g., Wikipedia articles, company manuals, etc.) Preprocess the documents into a format suitable for indexing by Faiss. Build Faiss Index:

Obtain or train a pre-trained sequence-to-sequence model (e.g., BART, T5). Fine-tune it on your dataset of queries and context-augmented answers. Run the Chatbot

Use code with caution. Example Usage

User: What is the capital of France? Chatbot: (Retrieves relevant documents from the knowledge base) The capital of France is Paris. It is located on the Seine River and is known for its iconic landmarks like the Eiffel Tower.... Customization

Experiment with different retrieval and generative models. Adjust hyperparameters during fine-tuning. Integrate with various chatbot frameworks or messaging platforms. Project Structure Main script to run the chatbot. Handles document preprocessing and indexing. Implements the retrieval component using Faiss. gLoads and uses the fine-tuned generative model. requirements.txt: Lists project dependencies.

RAG chatbots excel in scenarios where grounding responses in factual knowledge is important. Consider the size of your knowledge base and computational resources when choosing model sizes.