Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RAG-Powered Chatbot using Generative AI

Introduction

AI Chatbot is a Retrieval-Augmented Generation (RAG) solution designed to provide accurate and context-aware answers from a company's internal knowledge base. Built using Google Gemini, LangChain, FAISS, and Streamlit, the application retrieves relevant information from approved business documents and generates reliable responses based on that context. The solution helps organizations streamline information access, reduce repetitive inquiries, and ensure consistent communication across teams. By combining semantic search with advanced language models, users can interact with company knowledge through a simple and intuitive conversational interface.

Installation

Prerequisites

  • Python 3.10 or above
  • Google Gemini API Key

Clone the Repository

git clone https://github.com/archna13/RAG-Powered-Chatbot-using-Generative-AI.git

Create a Virtual Environment

python -m venv .venv

Activate the Environment

.venv\Scripts\activate     # Windows
source .venv/bin/activate  # Linux/Mac

Install Dependencies

pip install -r requirements.txt

Configure Environment Variables

Create a .env file in the project root directory.

GOOGLE_API_KEY=your_google_api_key

Start the Application

streamlit run app.py

Features

Context-Aware Question Answering

The chatbot provides accurate and context-aware responses based on information available within the organization's approved knowledge base. This enables users to access relevant company information through a conversational interface.

Retrieval-Augmented Generation (RAG)

The application combines semantic search with Generative AI to retrieve relevant information before generating a response. This approach helps the chatbot provide responses that are grounded in the available company knowledge.

Google Gemini Integration

The application uses Gemini 2.5 Flash for response generation and Gemini Embedding 2 Preview for creating embeddings. These Gemini models support both the retrieval and response-generation stages of the RAG workflow.

Semantic Search

The system uses FAISS to perform vector similarity search across the stored knowledge base embeddings. This allows the application to identify and retrieve the most relevant content for a user's query.

Interactive Chat Interface

The application provides a clean and user-friendly conversational interface using Streamlit. Users can interact with the company knowledge base through a simple chat experience while maintaining session history.

Process Flow

  • Knowledge Base Loading: The application reads company information from the configured knowledge base file. This information serves as the primary source of knowledge for retrieving relevant context during conversations.

  • Document Chunking: The loaded content is divided into smaller, overlapping text chunks to make the information easier to process and retrieve. Overlapping chunks help preserve relevant context between different sections of the knowledge base.

  • Embedding Generation: Each text chunk is converted into a vector representation using the Gemini Embedding 2 Preview model. These embeddings capture the semantic meaning of the content and enable similarity-based retrieval.

  • Vector Storage: The generated embeddings are stored in a FAISS vector database for efficient similarity search. The stored vectors allow the system to quickly identify relevant knowledge based on a user's query.

  • User Query Processing: When a user submits a question, the query is converted into an embedding using the same embedding approach. The resulting vector is then used to search for relevant information within the stored knowledge base.

  • Context Retrieval: The system compares the query embedding with the stored vectors and retrieves the most relevant knowledge base chunks. These retrieved chunks provide the context required for generating an appropriate response.

  • Response Generation: The retrieved context is combined with the user's query and provided to Gemini 2.5 Flash. The model uses the retrieved information to generate a relevant response based on the available company knowledge.

  • Chat Response Delivery: The validated response is displayed through the Streamlit chat interface. The conversation is also maintained within the session history to provide a continuous chat experience.

Technology Stack

Component Technology
User Interface Streamlit
Large Language Model Gemini 2.5 Flash
Embedding Model Gemini Embedding 2 Preview
Framework LangChain
Vector Database FAISS
Programming Language Python
Environment Management python-dotenv

Conclusion

AI Chatbot provides a practical and scalable approach to enterprise knowledge retrieval by combining semantic search and generative AI. The solution transforms static documentation into an interactive knowledge platform, enabling faster access to information, improved productivity, and a consistent user experience across the organization.

About

Developed a chatbot using LLMs and RAG to provide accurate, context-aware answers from company knowledge bases. It uses embeddings and vector retrieval with FAISS to retrieve relevant information and Gemini to generate reliable responses.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages