How notshrirang/loomrag works
Project Overview and Purpose
• LoomRAG is a multimodal retrieval-augmented generation system. It integrates various input modalities (text, images, audio, PDFs) for search and retrieval, powered by deep learning models – notably OpenAI’s CLIP for image and text embeddings and Whisper for audio processing. It also features an image annotation interface and supports model fine-tuning.
• The README clearly describes major functions such as data indexing, query processing, response generation, image annotation, and model fine-tuning. This confirms that it’s a full-fledged end-to-end system with both data processing and user interactivity.
Analyzing the File Structure
• Top-level files such as app.py, requirements.txt, LICENSE, and README.md indicate that this is a self-contained project.
• Directories like data_annotations, data_search, and data_upload suggest separate modules dedicated to different kinds of user interactions and use cases.
• The model_finetuning directory contains modules related to training and selection, indicating a well-modularized approach for adapting the CLIP model.
• The presence of configuration (config/constants.py), utility (utils.py, vectordb.py), and weights directories further emphasizes clear separation of concerns: configuration, business logic, data embedding, and pre-trained model artifacts.
a. User Interface & Frontend:
• The Streamlit interface launched via app.py acts as the front-end portal for users.
• It provides multiple pages: Data Upload, Data Search/Retrieval, Data Annotation, and Model Fine-Tuning.
b. Data Processing Modules:
• Data Upload: Handles image, audio, PDF, and URL inputs.
• Data Search: Implements the embedding-based search functionality using CLIP embeddings.
• Data Annotation: Provides a page for managing and annotating images.
c. Core AI/ML Components:
• Embedding Generation: Utilizes OpenAI’s CLIP and Whisper for converting inputs into vector embeddings.
• Model Fine-Tuning: Consists of a training pipeline (model_training_component.py, selection_component.py) for custom CLIP model adjustments.
• External dependencies include vector database support using FAISS for similarity search.
d. Backend Services/Utilities:
• Vector Database (via vectordb.py) that stores embeddings from processed inputs.
• Utility components (utils.py and adapter_utils.py) aiding in data transformation and integration.
• Configuration management via the config folder.
Relationships and Interactions
• Data Flow:
• User interactions occur through the Streamlit UI; input data (text, image, audio, PDFs) is sent to the respective processing modules.
• The system’s preprocessing converts these inputs into embeddings.
• These embeddings are stored in and retrieved from a vector database (likely using FAISS).
• On retrieval, the system searches nearest neighbors for similar embeddings and returns text, image, and audio results.
• Model Fine-Tuning Cycle:
• Annotated data from the Annotation module feed into the CLIP fine-tuning pipeline.
• Fine-tuned weights (stored in the weights folder) then integrate back into the search component for improved results.
• External Integration:
• Web scraping (through URL input) and audio recording integration are additional layers that connect external data sources into the indexing pipeline.
Architectural Patterns
• Modular Design: Different modules are clearly separated (upload, search, annotation, fine-tuning) indicating high cohesion and low coupling.
• MVC-like Separation: The UI (View) in Streamlit, business logic in separate Python modules, and persisted state in the vector database reflect a model separation pattern.
• Data Flow and Pipeline Architecture: The process from data ingestion to embedding generation and retrieval is best presented as a pipeline.