How harsh-sensei/ai-chan works
Project Type and Purpose
• The project implements an AI chatbot named “AI-Chan” that supports conversational memory by retrieving relevant past interactions.
• It is primarily a full-stack application where the frontend is built with Streamlit, and the backend consists of conversational model integrations (Mistral7B) along with a retrieval system.
Analyzing the File Structure
• Top-Level Files:
• app.py: Likely the main entry point of the application.
• README.md: Provides high-level project information.
• requirements.txt: Lists dependencies.
• .gitignore: Version control configuration.
• Directories:
• assets/ (with subfolder images): Likely holds static assets used by the UI.
• chatbots/ (with mistral.py): Contains chatbot-related implementations, in this case, using Mistral7B.
• retreival_system/ (with bm25.py and retriever.py): Provides the logic for retrieving past conversation context using BM25 (and ColBERT can be used based on context token limits).
• tests/: Contains test scripts that likely verify the functionality of embeddings in the retrieval system and the Mistral chatbot model.
Key Components and Their Relationships
a. Frontend Component:
• Based on Streamlit for building the user interface.
• Likely handled or launched via app.py.
• Connects to the backend to display responses and collect user inputs.
b. Chatbot Backend:
• Located in the chatbots directory (mistral.py module).
• Uses the Mistral7B model for generating responses.
• This component is invoked by the main application (app.py) after processing user input.
c. Retrieval System:
• Found in the retreival_system directory.
• Utilizes BM25 for fast retrieval of relevant past conversation segments.
• Supports an alternative retrieval engine (ColBERT) if the context is limited to 512 tokens.
• Interfaces with the chatbot backend to supply conversation memory for enhancing context.
d. Assets:
• A collection of images and static files used in the UI.
e. Tests:
• Validates the integrity and performance of both the chatbot model integration and the retrieval logic.