How viswadarshan-024/thirukkural-ai works
Main Components
• User Interface (Frontend): This is primarily handled by Streamlit through files such as app.py and about_page.py. It presents the UI, takes user input (questions), and displays outputs (Thirukkural verses and AI-generated advice).
• Data Storage & Resources: Several static files are used to store the core data, including:
• thirukkural_data.pkl – A pickled dataset containing the text of all Thirukkural verses and their metadata.
• data.json – Likely holds additional metadata or configuration.
• Pre-built vector database files (thirukkural_english_index.faiss and thirukkural_tamil_index.faiss).
• Vector Database & Embeddings Module: Managed by vector_db.py, this component uses a multilingual sentence transformer to create vector embeddings of the dataset and/or initialize/update the FAISS vector databases.
• Query Processing & Semantic Search: When a user query is received, the system converts it into the same vector space as the stored embeddings and performs a similarity search using FAISS to retrieve the most semantically similar couplets.
• LLM Integration & Response Generation: After retrieving candidate matches, the system passes them to the Groq API (model: Llama-3.3-70b-versatile) to rank relevance and generate personalized explanations and advice.
Interactions and Data Flow
• A user submits a question via the Streamlit interface.
• The query processing module transforms the query into an embedding.
• The application then queries the FAISS vector database (using pre-computed indices for both Tamil and English) to retrieve candidate verses.
• The retrieved results are passed to the LLM integration module which, via the Groq API, generates a tailored explanation and advice.
• The result is then returned to the user interface for display.
Architectural Patterns & Design Principles
• Modularity by clearly delineating components (Frontend, Data Management, Vector Search, LLM Integration).
• Notice the separation of concerns: the UI is separate from the data processing and indexing, and both are decoupled from the LLM service.
• The bilingual support is integrated within the vector search, meaning both Tamil and English indices are maintained and queried as needed.
Technologies & Components to Highlight
• Frontend: Streamlit (files: app.py, about_page.py).
• Vector Database: FAISS indexes (thirukkural_english_index.faiss & thirukkural_tamil_index.faiss).
• Embedding Generation: Sentence Transformers.
• LLM Integration: Groq API (using their Llama-3.3-70b-versatile model).
• Data Processing Libraries: Pandas and NumPy.
• Data Sources: thirukkural_data.pkl and data.json.