Spaces:
Sleeping
Sleeping
File size: 6,751 Bytes
6e55aeb 405a3f0 173df96 405a3f0 173df96 405a3f0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | ---
title: SentinelReview AI
emoji: π‘οΈ
colorFrom: blue
colorTo: gray
sdk: docker
app_file: app.py
pinned: false
---
# SentinelReview AI: Multimodal Review Authenticity & Fraud Audit Platform
An enterprise-grade, containerized machine learning application designed to evaluate, verify, and catalog online review authenticity. By auditing textual semantics (DistilBERT), user sentiment metadata (NLTK VADER), and visual contexts (ResNet skeletal projection), SentinelReview AI mitigates review manipulation, helping e-commerce platforms and trust operations teams protect customer trust.
---
## πΌ Business Vision & Case Study
### The Problem: E-Commerce Trust Degradation
In the digital commerce landscape, **reputation is currency**. Fake, paid, and bot-generated reviews degrade user trust, skew search algorithm rankings, and cost retailers billions in return overheads.
Traditional rule-based fraud detection systems are easily bypassed by advanced generative AI reviews that mimic human style, making automated, multi-vector semantic analysis critical.
### Who Uses SentinelReview AI?
* **E-Commerce Marketplaces**: Automated pre-publication filtering of merchant/product reviews.
* **Trust & Safety Operations Teams**: Live-monitoring dashboards to isolate coordinated review manipulation campaigns.
* **Third-Party Review Aggregators**: Auditing platforms (e.g. travel booking sites) requiring independent trust scores for verification.
### Why Multimodal & Multi-Vector AI?
Review manipulators can optimize text to sound perfectly natural, but they fail to balance metadata characteristics:
* **Text Semantics**: DistilBERT evaluates language features, structural flows, and contextual consistency.
* **Metadata Profiling**: NLTK VADER sentiment compound scores, capitalization ratios, and punctuation density check if the emotional tone matches the review length and style.
* **Visual Verification**: Product context images uploaded by customers are tracked alongside the review vectors, presenting audit reviewers with a combined evaluation layout.
---
## ποΈ Platform Architecture
SentinelReview AI utilizes a three-tier decoupled architecture designed for high throughput, thread-safe model evaluation, and low-latency startup cycles.
```mermaid
graph TD
User([Security Auditor Client]) -->|1. Submit Review & Context Image| Server[Flask API Server]
Server -->|2. Query Cache Singletons| Cache[(Memory Resource Cache)]
Cache -->|3. Get model & preprocessors| Inference[Inference Pipeline]
Inference -->|4. Text Tokenization| DBert[DistilBERT Encoder]
Inference -->|5. Metadata Normalization| VADER[VADER Polarity Vector]
Inference -->|6. Concatenate Features| Classifier[Joint FFN Classifier]
Classifier -->|7. Verified / Suspicious log| Response[Audit Report Compiler]
Response -->|8. Request LLM explanation| Nemo[Mistral Nemo API]
Response -->|9. Serve JSON report| User
```
---
## π Project Layout
```text
Fake_Review_Detection/
βββ models/
β βββ DistilBert_resnet.pth # Pre-trained multimodal weights (310MB - Git LFS)
βββ src/
β βββ __init__.py # Package initializer
β βββ config.py # Hardware mapping (CUDA/MPS/CPU) and path configurations
β βββ model.py # ExactDistilBertResNetModel PyTorch architecture
β βββ preprocessing.py # Feature engineering (VADER sentiment & capitalization ratios)
β βββ inference.py # Thread-safe Singletons and LLM explanation clients
βββ static/
β βββ css/
β β βββ style.css # "AI Audit Dashboard" styling (dark theme, scan animation)
β βββ js/
β βββ script.js # Async fetch controls, copy-to-clipboard, drag uploader
βββ templates/
β βββ index.html # Semantic HTML dashboard template
βββ app.py # High-concurrency Flask application server
βββ main.py # Local CLI test utility
βββ Dockerfile # Multi-stage production container manifest
βββ requirements.txt # Locked package dependencies
βββ LICENSE # MIT License
βββ CHANGELOG.md # Update history log
βββ CONTRIBUTING.md # Development guidelines
βββ .gitignore # File ignoring guidelines
```
---
## βοΈ Setup & Local Execution
### 1. Requirements
Ensure you have **Python 3.11** (or compatible release) installed. Create a clean virtual environment:
```bash
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
```
### 2. Install Packages
```bash
pip install -r requirements.txt
```
### 3. Place Pre-Trained Weights
Ensure the weights file `DistilBert_resnet.pth` is placed under the `./models` directory before launching the app.
### 4. CLI Execution Utility
To test the inference pipeline directly from your shell:
```bash
python main.py
```
This utility will prompt you to enter raw review text and outputs a complete terminal audit report.
### 5. Start Flask Server Locally
```bash
python app.py
```
Open [http://localhost:7860](http://localhost:7860) in your web browser.
---
## π³ Docker Deployment
To compile and launch the application inside a local container matching the Hugging Face production environment:
```bash
# Build the container
docker build -t sentinel-review-ai .
# Run the container mapping to port 7860
docker run -p 7860:7860 sentinel-review-ai
```
Navigate to [http://localhost:7860](http://localhost:7860).
---
## π Hugging Face Spaces Deployment
This repository is configured for deployment on Hugging Face Spaces using the Docker SDK:
1. Create a new Space on [Hugging Face](https://huggingface.co/new-space).
2. Choose **Docker** as the SDK (with a Blank/Custom template).
3. Push files to the Hugging Face space repository.
4. The space will automatically build the container and deploy the app.
---
## β οΈ Model Limitations & Future Work
* **Dead ResNet Weights Constraint**: The current pre-trained model was compiled with a zero-filled placeholder for ResNet Conv features during training. Active image processing is bypassed during prediction to preserve identical classification outputs. Future iterations will include full retraining of the ResNet branch using paired image-text datasets.
* **Static Metadata Scaling**: Extracted metadata vectors (e.g. character length ratios) are unnormalized. Introducing z-score scaling relative to catalog averages will improve classifier stability.
|