CoolFace
Modelpublic

SyedaArisha/predictive-maintenance-rag-system

sourceHugging Facemitupdated 21d agoView on Hugging Face
0likes
Model Card

Predictive Maintenance RAG System

Author: Syeda Arisha Hassan Domain: FMCG & Industrial Manufacturing Stack: XGBoost · Random Forest · PyTorch LSTM · 1D-CNN-LSTM · FAISS · SmolLM2-135M


Overview

An end-to-end, closed-loop predictive maintenance platform built for FMCG and continuous industrial manufacturing. The system integrates four ML/DL pipelines with a Retrieval-Augmented Generation (RAG) layer to deliver actionable, plain-language diagnostics and automated production rescheduling.

Unexpected machine breakdowns in FMCG plants cost $10,000 to $36,000 per hour (McKinsey). This system addresses that by predicting failures before they happen and automatically reallocating production jobs to healthy machines.


Repository Contents

models/
├── classification/
│   ├── ai4i_ensemble_model.pkl        # XGBoost + RF soft-voting ensemble (AI4I 2020)
│   └── pump_ensemble_model.pkl        # XGBoost + RF soft-voting ensemble (Pump Sensor)
├── regression/
│   ├── best_cmapss_lstm_checkpoint.pt     # 2-Layer PyTorch LSTM (NASA CMAPSS FD001)
│   └── best_cmapss_cnn-lstm_checkpoint.pt # 1D-CNN-LSTM Regressor (NASA CMAPSS FD001)
└── rag/
    ├── faiss_index.bin                # FAISS IndexFlatL2 — 7,966 vectors × 384-d
    └── faiss_texts.pkl                # Synthesized maintenance log corpus

System Architecture

[ Sensor Telemetry ] → [ ML Classifiers ] → [ Risk Score ]
                     → [ DL RUL Regressor ] → [ Hours Remaining ]
                     → [ FAISS Retrieval ] → [ Historical Context ]
                     → [ LLM Explainer (SmolLM2) ] → [ Diagnostic Report ]
                     → [ Production Scheduler ] → [ Adjusted Job Schedule ]

Pipelines & Datasets

1. AI4I 2020 — Milling Machine Classification

  • Dataset: 10,000 records, 14 features (UCI Machine Learning Repository)
  • Task: Binary failure classification (3.4% class imbalance)
  • Approach: Optuna-tuned XGBoost + Random Forest, Soft Voting Ensemble, SMOTE oversampling
  • Results:
  • ROC-AUC: 0.9726
  • Recall: 0.87 (87% of true failures detected)
  • Confusion Matrix: [[1892, 40], [9, 59]]

2. Pump Sensor — Temporal Early Warning

  • Dataset: 220,320 minute-interval readings, 52 sensors (April–August 2018)
  • Task: 60-minute lookahead pre-failure warning classification
  • Approach: Strict temporal 50/50 train/test split, TimeSeriesSplit Optuna tuning, RECOVERING rows dropped to eliminate target leakage
  • Model: models/classification/pump_ensemble_model.pkl

3. NASA CMAPSS FD001 — Turbofan Engine RUL Regression

  • Dataset: 100 training engines, 100 test engines, 26 sensor channels
  • Task: Remaining Useful Life (RUL) regression in cycles
  • Approach: 3D sliding window sequences (N × 30 × 24), MinMaxScaler, piecewise RUL capping at 125 cycles
  • Architectures:
  • 2-Layer LSTM: Hidden sizes 64→32, LayerNorm, early stopping (patience=10)
  • 1D-CNN-LSTM: Conv1D spatial extraction + LSTM temporal recurrence
  • Results: MAE ~14.2–16.8 cycles, RMSE ~18.9–22.4 cycles
  • Checkpoints: models/regression/

4. Microsoft Azure PdM — Fleet RAG Database

  • Dataset: 876k hourly telemetry rows across 100 machines + error/maintenance/failure logs
  • Approach: 7,966 natural language maintenance records synthesized, embedded with all-MiniLM-L6-v2 (384-d), indexed in FAISS
  • Index: models/rag/faiss_index.bin (12.2 MB, exact L2 search)
  • LLM Explainer: HuggingFaceTB/SmolLM2-135M-Instruct running on CPU with deterministic anti-parroting post-processor

Risk Status Thresholds

RangeStatus
0% – 15%Healthy
16% – 40%At Risk
41%+Critical

How to Load the Models

python
import joblib
import torch

# Load classification ensemble
ensemble = joblib.load("models/classification/ai4i_ensemble_model.pkl")
scaler   = joblib.load("data/processed/ai4i_scaler.pkl")

# Load LSTM checkpoint
checkpoint = torch.load("models/regression/best_cmapss_lstm_checkpoint.pt",
                        map_location="cpu")

# Load FAISS index
import faiss, pickle
index = faiss.read_index("models/rag/faiss_index.bin")
with open("models/rag/faiss_texts.pkl", "rb") as f:
    texts = pickle.load(f)

Serving Dashboard

The full system is served via a FastAPI backend with an interactive web dashboard featuring:

  • Real-time failure probability gauge and RUL countdown per machine
  • Fleet health overview across all 100 machines
  • LLM-generated Markdown diagnostic reports (RAG + SmolLM2)
  • Automated production rescheduling with job reallocation audit log
bash
pip install -r requirements.txt
python -m uvicorn app:app --host 127.0.0.1 --port 8000

Citation

If you use these models or datasets in your research, please credit the original dataset sources:

  • AI4I 2020: UCI Machine Learning Repository
  • NASA CMAPSS: NASA Prognostics Center of Excellence
  • Microsoft Azure PdM: Microsoft Azure AI Gallery