How nogibjj/astrology-bot works
Project Type and Purpose
• The project is essentially a chatbot application focused on astrological readings (horoscope and tarot) that leverages a fine-tuned LLaMA-2-7B language model.
• It uses a RAG pipeline: text data is chunked, embedded via a BGE-Large model, indexed (with Pinecone as mentioned in the README), and then queried to retrieve contextual text.
• The UI is deployed (via Streamlit) and also includes a web interface component (with HTML/CSS/JS under the “interface” folder).
Breaking Down the File Structure into Major Components
• Data Layer:
• Data files are in the “data” directory (csv files, parquet of embeddings, notebooks for webscraping).
• This is where horoscope and tarot data is stored and pre-processed.
• RAG Pipeline Components:
• The “RAG” folder houses scripts for chunking text (chunk_data.py), indexing data (index_data.py), orchestrating the main pipeline (main.py), and miscellaneous utilities (utils.py).
• This layer performs the key steps: chunking, embedding text data (can be linked to models under the “model” directory), and managing retrieval.
• Model Module:
• The “model” directory includes code related to creating embeddings (embedding_model.py) and running/inferencing (inference_model.py). There’s also a notebook for fine-tuning LLaMA-2-7B.
• This module shows the integration of the chosen models with the RAG system.
• Interface / Frontend:
• The “interface” directory contains the code for handling responses (get_answer_horoscope.py, get_response.py, inference.py) along with the HTML, JS, and CSS files to render the UI.
• A separate UI.py at the root level and a .streamlit folder (with deployment config files like secrets.toml) indicate that a Streamlit application powers the user interface.
• Deployment and Configuration:
• Files like .gitignore, LICENSE, USE_POLICY.md, and requirements.txt represent standard configuration and deployment support.
• The README and notebooks indicate how to test and run the experiments.
Key Relationships and Interactions
• Data ingestion (via web scrapers and CSVs) flows from the “data” directory into the processing pipeline in the RAG layer.
• The RAG component processes raw text data by executing chunking (with “chunk_data.py”), indexing (through “index_data.py”), and then feeding into the model.
• The embedding and inference occur in the “model” module using embedding functions and the fine-tuned LLaMA-2-7B model.
• End-user queries are sent to the UI (handled by Streamlit and an HTML/CSS/JS front-end) which communicates with the “interface” scripts to route the request to the inference backend.
• In production, configuration and secrets (in .streamlit) ensure secure and correct deployments, while the README explains the pipeline.
Detailed Implementation Steps
• Sketch the overall layout starting from the data acquisition stage (data scraping and stored CSVs) leading into the RAG system.
• Step of the pipeline:
• Data is chunked (chunk_data.py) and indexed (index_data.py).
• The embedding layer (embedding_model.py) transforms text data for similarity search.
• The query processing component replicates these embedding steps to retrieve context via cosine similarity.
• The inference module (inference_model.py) with LLaMA-2-7B fine-tuning produces and post-processes the final answer.
• Separate the user-facing side:
• The Streamlit deployment and the web interface components (HTML, JS, CSS) form a distinct group connecting to the processing backend.