How hitrong/rag-student-chatbot works
Project Type & Purpose
• This project is a full-stack application intended to help Vietnamese students by providing a chatbot that supports both a normal LLM chat mode and a Retrieval Augmented Generation (RAG) chat mode.
• The system not only provides chatbot responses but also manages document data (Word and PDF) using a vector database (using FAISS) to offer context-based responses.
Analyzing the File Structure
• The top-level files include configuration files (db_config.yml, history_config.yml, model_config.yml) that set up model paths and database settings.
• The main application file is application.py, which is initiated using Streamlit.
• There are several modules like llm_chain.py (LLM chain logic), history_handle.py (session management), prompt_template.py (prompts), vectordb.py (handling vector database interactions), and utils.py.
• The data_store folder contains documents (example Word docs) and a vector_db directory with FAISS index files.
• The structure shows separation between core logic (chaining, history, and vector database management) and static configuration/document resources.
Key Components
a. Frontend / UI Layer:
• Streamlit Web Application (application.py) that acts as the user interface where students interact with the chatbot.
b. Chatbot Logic Layer (Business Logic):
• Normal LLM Chatbot Module (using llm_chain.py) that uses a standard prompt template from prompt_template.py.
• RAG Chatbot Module (same llm_chain.py but with added retrieval process) that queries the Vector Database.
c. Data Retrieval / Vector Database:
• A VectorDB module (vectordb.py) that handles document embedding, similarity searches, and interacts with FAISS indices (data_store/vector_db/faiss) to retrieve relevant context.
• Local Document Storage (data_store/word, and wherever PDF/documents are stored) that are indexed.
d. Session & History Management:
• A session system backed by history_handle.py that captures and manages conversation history, including extracting session names using keywords.
e. Configuration & Model Management:
• Model configuration is managed through model_config.yml (e.g., specifying the path for the Vinallama model from Hugging Face).
• Other configuration files (db_config.yml, history_config.yml) set up underlying system parameters.
f. External Dependencies & Libraries:
• Hugging Face’s Sentence Transformer for embeddings.
• LangChain (LLMChain and RetrievalQA patterns) which orchestrate the LLM interactions.
• FAISS for the vector database.
• Streamlit for delivering the web UI.