Spaces:
Runtime error
Runtime error
Aryan Mishra commited on
Commit Β·
ae0eb95
1
Parent(s): e5158d5
docs: improve README with comprehensive project documentation
Browse files
README.md
CHANGED
|
@@ -1,53 +1,113 @@
|
|
| 1 |
-
#
|
| 2 |
-
Multilingual Aspect-Based Sentiment Analysis (ABSA) supporting English, Hindi, and Hinglish. It leverages XLM-RoBERTa and IndicBERT to perform aspect term extraction and sentiment classification for multilingual product reviews.
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
Multilingual-Absa/
|
| 6 |
-
βββ .github/
|
| 7 |
-
|
| 8 |
-
βββ config/ #
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
βββ
|
| 12 |
-
βββ
|
| 13 |
-
βββ
|
| 14 |
-
βββ
|
| 15 |
-
βββ
|
| 16 |
-
βββ
|
| 17 |
-
βββ
|
| 18 |
-
βββ
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
| 31 |
```bash
|
| 32 |
-
# 1. Clone and install
|
| 33 |
git clone <repository-url>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
pip install -r requirements.txt
|
|
|
|
| 35 |
|
| 36 |
-
|
|
|
|
| 37 |
cp .env.example .env
|
| 38 |
-
#
|
|
|
|
| 39 |
|
| 40 |
-
#
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
| 42 |
```
|
| 43 |
|
| 44 |
-
## ML Pipeline (DVC)
|
|
|
|
|
|
|
| 45 |
```bash
|
| 46 |
-
dvc
|
| 47 |
-
dvc
|
|
|
|
| 48 |
```
|
| 49 |
|
| 50 |
-
##
|
|
|
|
|
|
|
| 51 |
```bash
|
| 52 |
-
cd api
|
|
|
|
| 53 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Multilingual Aspect-Based Sentiment Analysis (ABSA)
|
|
|
|
| 2 |
|
| 3 |
+

|
| 4 |
+

|
| 5 |
+

|
| 6 |
+

|
| 7 |
+

|
| 8 |
+
|
| 9 |
+
A production-ready, highly optimized Aspect-Based Sentiment Analysis (ABSA) system designed to process multilingual product reviews in **English, Hindi, and Hinglish**. It accurately extracts aspects and classifies their underlying sentiments.
|
| 10 |
+
|
| 11 |
+
The system leverages state-of-the-art models like **XLM-RoBERTa** and **IndicBERT**, optimized using ONNX runtime, and includes a highly robust, zero-download, pure-Python rule-based fallback engine for instant inference.
|
| 12 |
+
|
| 13 |
+
## β¨ Key Features
|
| 14 |
+
|
| 15 |
+
- **Multilingual Support**: First-class support for English, Hindi, and code-mixed Hinglish.
|
| 16 |
+
- **Dual Inference Engine**:
|
| 17 |
+
- **Neural Path**: Uses custom fine-tuned, INT8-quantized ONNX models (XLM-RoBERTa based) for extremely fast and accurate token classification and sequence classification.
|
| 18 |
+
- **Rule-Based Fallback**: An instantaneous, pure-Python fallback leveraging a curated multi-lingual lexicon to handle aspect extraction and sentiment scoring without any heavy downloads.
|
| 19 |
+
- **Modern Tech Stack**:
|
| 20 |
+
- **Backend**: Asynchronous, high-performance API built with FastAPI.
|
| 21 |
+
- **Frontend**: A sleek, responsive dashboard built with React and TailwindCSS. Features real-time predictions, batch analytics, and system monitoring.
|
| 22 |
+
- **MLOps Integrated**: Complete integration with DVC (Data Version Control) for pipeline reproducibility, MLflow for experiment tracking, and Evidently AI for data drift monitoring.
|
| 23 |
+
- **Scalable Architecture**: Support for async tasks via Celery + Redis, robust data storage via PostgreSQL, and metric exporting using Prometheus.
|
| 24 |
+
|
| 25 |
+
## ποΈ Repository Structure
|
| 26 |
+
|
| 27 |
+
```text
|
| 28 |
Multilingual-Absa/
|
| 29 |
+
βββ .github/workflows/ # CI/CD pipelines
|
| 30 |
+
βββ api/ # FastAPI backend and inference services
|
| 31 |
+
βββ config/ # DVC and Docker configuration files
|
| 32 |
+
βββ dashboard/ # React frontend for inference & monitoring
|
| 33 |
+
βββ data/ # Dataset directory (DVC-tracked)
|
| 34 |
+
βββ docs/ # Extended documentation
|
| 35 |
+
βββ mlflow/ # MLflow tracking
|
| 36 |
+
βββ models/ # Model artifacts (DVC-tracked)
|
| 37 |
+
βββ monitoring/ # Monitoring configurations (Prometheus, Evidently)
|
| 38 |
+
βββ notebooks/ # Exploratory Data Analysis & Prototyping
|
| 39 |
+
βββ scripts/ # Utility and automation scripts
|
| 40 |
+
βββ src/ # Machine Learning pipeline source code
|
| 41 |
+
βββ tests/ # Unit and integration test suite
|
| 42 |
+
βββ requirements.txt # Python dependencies
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
## π Getting Started
|
| 46 |
+
|
| 47 |
+
### Prerequisites
|
| 48 |
+
- Python 3.10+
|
| 49 |
+
- Node.js (for Dashboard)
|
| 50 |
+
- Docker & Docker Compose (Optional, but recommended)
|
| 51 |
+
|
| 52 |
+
### 1. Local Setup
|
| 53 |
+
|
| 54 |
+
Clone the repository and install the backend dependencies:
|
| 55 |
```bash
|
|
|
|
| 56 |
git clone <repository-url>
|
| 57 |
+
cd Multilingual-Absa
|
| 58 |
+
|
| 59 |
+
# Create a virtual environment and install dependencies
|
| 60 |
+
python -m venv .venv
|
| 61 |
+
source .venv/bin/activate # On Windows use `.venv\Scripts\activate`
|
| 62 |
pip install -r requirements.txt
|
| 63 |
+
```
|
| 64 |
|
| 65 |
+
Set up your environment variables:
|
| 66 |
+
```bash
|
| 67 |
cp .env.example .env
|
| 68 |
+
# Edit .env with your specific configurations
|
| 69 |
+
```
|
| 70 |
|
| 71 |
+
### 2. Run with Docker (Recommended)
|
| 72 |
+
|
| 73 |
+
The easiest way to get the entire stack (API, Dashboard, Redis, Postgres) running is via Docker Compose:
|
| 74 |
+
```bash
|
| 75 |
+
docker-compose -f config/docker/docker-compose.yml up --build
|
| 76 |
```
|
| 77 |
|
| 78 |
+
### 3. Manual ML Pipeline Execution (DVC)
|
| 79 |
+
|
| 80 |
+
To reproduce the ML pipeline or sync artifacts:
|
| 81 |
```bash
|
| 82 |
+
dvc pull # Pull data/models from remote storage
|
| 83 |
+
dvc repro # Run the full end-to-end ML training pipeline
|
| 84 |
+
dvc push # Push newly generated artifacts to remote
|
| 85 |
```
|
| 86 |
|
| 87 |
+
### 4. Running the Application Locally
|
| 88 |
+
|
| 89 |
+
**Start the API Server:**
|
| 90 |
```bash
|
| 91 |
+
cd api
|
| 92 |
+
uvicorn main:app --reload --host 0.0.0.0 --port 8000
|
| 93 |
```
|
| 94 |
+
*API Documentation will be available at `http://localhost:8000/docs`.*
|
| 95 |
+
|
| 96 |
+
**Start the Dashboard:**
|
| 97 |
+
```bash
|
| 98 |
+
cd dashboard
|
| 99 |
+
npm install
|
| 100 |
+
npm run dev
|
| 101 |
+
```
|
| 102 |
+
*Access the dashboard at `http://localhost:5173`.*
|
| 103 |
+
|
| 104 |
+
## π¬ How it Works
|
| 105 |
+
|
| 106 |
+
1. **Prediction API**: When a review is submitted, the language is auto-detected.
|
| 107 |
+
2. **Inference**: The `ABSAPipeline` attempts to load INT8 quantized ONNX models for extraction and sentiment scoring.
|
| 108 |
+
3. **Fallback Mechanism**: If the custom models are not downloaded, the engine automatically falls back to a dictionary/rule-based engine tailored for product reviews, guaranteeing zero downtime and instant availability.
|
| 109 |
+
4. **Monitoring**: All predictions are logged. Performance metrics and data drift are tracked via Evidently and Prometheus.
|
| 110 |
+
|
| 111 |
+
## π‘οΈ License
|
| 112 |
+
|
| 113 |
+
This project is licensed under the MIT License - see the LICENSE file for details.
|