Spaces:
Running on Zero
Running on Zero
Upload 34 files
Browse files- DEPLOY.md +13 -10
- README.md +3 -3
- app.py +102 -34
- src/anomaly_model.py +1 -1
DEPLOY.md
CHANGED
|
@@ -19,11 +19,11 @@ Two ways to deploy: the web UI (easiest, no git needed) or the CLI/git route.
|
|
| 19 |
|
| 20 |
1. Go to https://huggingface.co/new-space
|
| 21 |
2. Fill in:
|
| 22 |
-
- **Space name:** e.g. `
|
| 23 |
- **License:** MIT (or your choice)
|
| 24 |
- **Select the Space SDK:** **Gradio**
|
| 25 |
- **Space hardware:** CPU basic (free tier is enough for this app)
|
| 26 |
-
- Visibility: **Public** (so you can share the link with
|
| 27 |
3. Click **Create Space**.
|
| 28 |
4. On the new Space page, click **Files β Add file β Upload files**, and
|
| 29 |
upload the *entire project folder contents* (keep the folder structure:
|
|
@@ -32,7 +32,7 @@ Two ways to deploy: the web UI (easiest, no git needed) or the CLI/git route.
|
|
| 32 |
5. Wait for the Space to build (check the **Logs** tab if it fails β almost
|
| 33 |
always a missing/incompatible package version).
|
| 34 |
6. Once it shows "Running", your demo is live at:
|
| 35 |
-
`https://huggingface.co/spaces/<your-username>/
|
| 36 |
|
| 37 |
## Option B β git (recommended if you'll keep iterating)
|
| 38 |
|
|
@@ -42,11 +42,11 @@ pip install huggingface_hub
|
|
| 42 |
huggingface-cli login
|
| 43 |
|
| 44 |
# 2. Create the Space (or create it via the web UI first, then just clone it)
|
| 45 |
-
huggingface-cli repo create
|
| 46 |
|
| 47 |
# 3. Clone it, copy in the project files, and push
|
| 48 |
-
git clone https://huggingface.co/spaces/<your-username>/
|
| 49 |
-
cd
|
| 50 |
cp -r /path/to/this/project/* .
|
| 51 |
git add .
|
| 52 |
git commit -m "Initial commit: Smart Warehouse AI Assistant"
|
|
@@ -57,7 +57,7 @@ The Space will automatically build from `requirements.txt` and launch
|
|
| 57 |
`app.py` (as declared in the README's YAML front matter: `sdk: gradio`,
|
| 58 |
`app_file: app.py`).
|
| 59 |
|
| 60 |
-
## Enabling the LLM (recommended before sharing
|
| 61 |
|
| 62 |
By default the Space runs in **retrieval-only fallback mode** β it still
|
| 63 |
works, but answers are extractive rather than LLM-generated. To turn on
|
|
@@ -103,14 +103,17 @@ git commit -m "Retrain models"
|
|
| 103 |
git push
|
| 104 |
```
|
| 105 |
|
| 106 |
-
## Sharing
|
| 107 |
|
| 108 |
Once it's live, share the Space URL directly:
|
| 109 |
|
| 110 |
```
|
| 111 |
-
https://huggingface.co/spaces/<your-username>/
|
| 112 |
```
|
| 113 |
|
| 114 |
Consider also linking the **Model Evaluation** tab specifically in your
|
| 115 |
application/cover letter, since it's the clearest evidence of rigorous,
|
| 116 |
-
reproducible ML work rather than just a UI demo.
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
1. Go to https://huggingface.co/new-space
|
| 21 |
2. Fill in:
|
| 22 |
+
- **Space name:** e.g. `smart-warehouse-ai`
|
| 23 |
- **License:** MIT (or your choice)
|
| 24 |
- **Select the Space SDK:** **Gradio**
|
| 25 |
- **Space hardware:** CPU basic (free tier is enough for this app)
|
| 26 |
+
- Visibility: **Public** (so you can share the link with recruiters/employers)
|
| 27 |
3. Click **Create Space**.
|
| 28 |
4. On the new Space page, click **Files β Add file β Upload files**, and
|
| 29 |
upload the *entire project folder contents* (keep the folder structure:
|
|
|
|
| 32 |
5. Wait for the Space to build (check the **Logs** tab if it fails β almost
|
| 33 |
always a missing/incompatible package version).
|
| 34 |
6. Once it shows "Running", your demo is live at:
|
| 35 |
+
`https://huggingface.co/spaces/<your-username>/smart-warehouse-ai`
|
| 36 |
|
| 37 |
## Option B β git (recommended if you'll keep iterating)
|
| 38 |
|
|
|
|
| 42 |
huggingface-cli login
|
| 43 |
|
| 44 |
# 2. Create the Space (or create it via the web UI first, then just clone it)
|
| 45 |
+
huggingface-cli repo create smart-warehouse-ai --type space --space_sdk gradio
|
| 46 |
|
| 47 |
# 3. Clone it, copy in the project files, and push
|
| 48 |
+
git clone https://huggingface.co/spaces/<your-username>/smart-warehouse-ai
|
| 49 |
+
cd smart-warehouse-ai
|
| 50 |
cp -r /path/to/this/project/* .
|
| 51 |
git add .
|
| 52 |
git commit -m "Initial commit: Smart Warehouse AI Assistant"
|
|
|
|
| 57 |
`app.py` (as declared in the README's YAML front matter: `sdk: gradio`,
|
| 58 |
`app_file: app.py`).
|
| 59 |
|
| 60 |
+
## Enabling the LLM (recommended before sharing this project)
|
| 61 |
|
| 62 |
By default the Space runs in **retrieval-only fallback mode** β it still
|
| 63 |
works, but answers are extractive rather than LLM-generated. To turn on
|
|
|
|
| 103 |
git push
|
| 104 |
```
|
| 105 |
|
| 106 |
+
## Sharing this project
|
| 107 |
|
| 108 |
Once it's live, share the Space URL directly:
|
| 109 |
|
| 110 |
```
|
| 111 |
+
https://huggingface.co/spaces/<your-username>/smart-warehouse-ai
|
| 112 |
```
|
| 113 |
|
| 114 |
Consider also linking the **Model Evaluation** tab specifically in your
|
| 115 |
application/cover letter, since it's the clearest evidence of rigorous,
|
| 116 |
+
reproducible ML work rather than just a UI demo. Since everything here is
|
| 117 |
+
built on synthetic, self-generated data, this same Space link works as-is
|
| 118 |
+
for applications to multiple companies β no company-specific data or
|
| 119 |
+
branding needs to change.
|
README.md
CHANGED
|
@@ -21,7 +21,7 @@ with a full **Model Evaluation** tab reporting real accuracy/F1/ROC-AUC
|
|
| 21 |
metrics on held-out test data.
|
| 22 |
|
| 23 |
π **Live demo:** add your Space URL here once deployed, e.g.
|
| 24 |
-
`https://huggingface.co/spaces/<your-username>/
|
| 25 |
|
| 26 |
## Tabs
|
| 27 |
|
|
@@ -50,7 +50,7 @@ metrics on held-out test data.
|
|
| 50 |
|
| 51 |
```bash
|
| 52 |
git clone <this-repo>
|
| 53 |
-
cd
|
| 54 |
pip install -r requirements.txt
|
| 55 |
|
| 56 |
# (re)generate datasets, train models, produce evaluation plots/metrics
|
|
@@ -85,7 +85,7 @@ See [`DEPLOY.md`](./DEPLOY.md) for full step-by-step instructions.
|
|
| 85 |
## Project structure
|
| 86 |
|
| 87 |
```
|
| 88 |
-
|
| 89 |
βββ app.py # Gradio app (5 tabs)
|
| 90 |
βββ build_artifacts.py # generates data, trains models, evaluates, saves plots
|
| 91 |
βββ requirements.txt
|
|
|
|
| 21 |
metrics on held-out test data.
|
| 22 |
|
| 23 |
π **Live demo:** add your Space URL here once deployed, e.g.
|
| 24 |
+
`https://huggingface.co/spaces/<your-username>/smart-warehouse-ai`
|
| 25 |
|
| 26 |
## Tabs
|
| 27 |
|
|
|
|
| 50 |
|
| 51 |
```bash
|
| 52 |
git clone <this-repo>
|
| 53 |
+
cd smart-warehouse-ai
|
| 54 |
pip install -r requirements.txt
|
| 55 |
|
| 56 |
# (re)generate datasets, train models, produce evaluation plots/metrics
|
|
|
|
| 85 |
## Project structure
|
| 86 |
|
| 87 |
```
|
| 88 |
+
smart-warehouse-ai/
|
| 89 |
βββ app.py # Gradio app (5 tabs)
|
| 90 |
βββ build_artifacts.py # generates data, trains models, evaluates, saves plots
|
| 91 |
βββ requirements.txt
|
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
"""
|
| 2 |
Smart Warehouse AI Assistant
|
| 3 |
=============================
|
| 4 |
-
A
|
| 5 |
Space. Combines:
|
| 6 |
|
| 7 |
1. An LLM-powered assistant (RAG: TF-IDF retrieval + hosted LLM via the
|
|
@@ -15,7 +15,7 @@ Space. Combines:
|
|
| 15 |
5. A Model Evaluation tab reporting real accuracy/F1/ROC-AUC metrics
|
| 16 |
computed by build_artifacts.py.
|
| 17 |
|
| 18 |
-
Author: (your name here) -- built as
|
| 19 |
"""
|
| 20 |
|
| 21 |
import json
|
|
@@ -176,10 +176,20 @@ def test_llm_fn():
|
|
| 176 |
ASSISTANT_EXAMPLES = [
|
| 177 |
"The conveyor belt in Zone C is making noise",
|
| 178 |
"How many units of SKU-1042 are in Zone B?",
|
|
|
|
| 179 |
"What's the difference between an AGV and an AMR?",
|
| 180 |
"A forklift near-miss was reported in Zone A",
|
| 181 |
"What's the fastest picking route for a high volume order?",
|
| 182 |
"Is Crane-03 operational?",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
]
|
| 184 |
|
| 185 |
|
|
@@ -303,30 +313,83 @@ ABOUT_MD = f"""
|
|
| 303 |
# π Smart Warehouse AI Assistant
|
| 304 |
|
| 305 |
**A portfolio project demonstrating an applied-AI approach to intralogistics
|
| 306 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 307 |
|
| 308 |
## What this demonstrates
|
| 309 |
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
|
| 316 |
-
|--
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
|
| 323 |
## Tech stack
|
| 324 |
|
| 325 |
- **UI / deployment:** [Gradio](https://gradio.app) on Hugging Face Spaces
|
| 326 |
- **LLM:** Hosted instruct model via the Hugging Face **Inference API**
|
| 327 |
-
(`huggingface_hub.InferenceClient`),
|
| 328 |
-
|
| 329 |
-
|
|
|
|
| 330 |
- **Retrieval:** TF-IDF + cosine similarity over a small hand-written
|
| 331 |
warehouse-operations knowledge base (simple, fast, fully local RAG).
|
| 332 |
- **Intent classification:** TF-IDF + Logistic Regression (scikit-learn) --
|
|
@@ -337,7 +400,8 @@ on top of that kind of system:
|
|
| 337 |
unsupervised on scaled sensor features.
|
| 338 |
- **Evaluation:** scikit-learn metrics + matplotlib, all computed by
|
| 339 |
`build_artifacts.py` and saved as static artifacts the app loads at
|
| 340 |
-
startup (fast, reproducible Space boot
|
|
|
|
| 341 |
|
| 342 |
## Architecture
|
| 343 |
|
|
@@ -363,19 +427,19 @@ on top of that kind of system:
|
|
| 363 |
Sensor stream ββββΊ StandardScaler ββββΊ IsolationForest ββββΊ anomaly / normal
|
| 364 |
```
|
| 365 |
|
| 366 |
-
## Why this
|
| 367 |
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
|
| 376 |
## Limitations & next steps
|
| 377 |
|
| 378 |
-
- All data here is **synthetic**, for portfolio/demo purposes
|
| 379 |
version would connect to real WMS/WCS APIs and historical sensor logs.
|
| 380 |
- The intent set (8 classes) and knowledge base (10 articles) are intentionally
|
| 381 |
small to keep the demo fast and auditable; both are easy to extend.
|
|
@@ -384,8 +448,8 @@ reproducible evaluation numbers rather than cherry-picked demo runs.
|
|
| 384 |
semi-supervised model once labelled failure data is available.
|
| 385 |
|
| 386 |
---
|
| 387 |
-
*Built as
|
| 388 |
-
linked repository. Feedback welcome.*
|
| 389 |
"""
|
| 390 |
|
| 391 |
|
|
@@ -430,7 +494,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"), css=CUSTOM_CSS, title="
|
|
| 430 |
"π§ͺ <b>Source:</b> hand-written by the developer β 10 original knowledge-base "
|
| 431 |
"articles on warehouse operations (AS/RS, AGV/AMR, WMS, sortation, picking, "
|
| 432 |
"maintenance, safety) plus ~480 template-generated example queries. Not scraped "
|
| 433 |
-
"or sourced from
|
| 434 |
"<b>What it describes:</b> generic intralogistics/automation concepts and "
|
| 435 |
"operational scenarios (equipment faults, safety incidents, order/inventory "
|
| 436 |
"questions) β general domain knowledge, not any specific facility's live data.<br>"
|
|
@@ -460,8 +524,8 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"), css=CUSTOM_CSS, title="
|
|
| 460 |
gr.HTML(data_badge(
|
| 461 |
f"π§ͺ <b>Source:</b> randomly generated by the developer's code "
|
| 462 |
f"(`src/data_generation.py`, fixed seed) β {len(inventory_df)} synthetic SKU "
|
| 463 |
-
f"records and {len(orders_df)} synthetic orders. Not exported from
|
| 464 |
-
"
|
| 465 |
"<b>What it describes:</b> a stand-in inventory table (SKU, category, zone, "
|
| 466 |
"on-hand units, reorder point, unit cost) and orders table (order ID, status, "
|
| 467 |
"line count, priority, zone) β realistic in shape and ranges, but fictional "
|
|
@@ -485,6 +549,10 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"), css=CUSTOM_CSS, title="
|
|
| 485 |
"What's the status of order #10007?",
|
| 486 |
"Show me low stock items",
|
| 487 |
"Any delayed orders?",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 488 |
],
|
| 489 |
inputs=inv_input,
|
| 490 |
)
|
|
@@ -498,7 +566,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"), css=CUSTOM_CSS, title="
|
|
| 498 |
gr.HTML(data_badge(
|
| 499 |
"π§ͺ <b>Source:</b> randomly generated by the developer's code "
|
| 500 |
"(`src/data_generation.py`, fixed seed) β 1,000 synthetic sensor readings "
|
| 501 |
-
"(900 normal + 100 simulated-fault). Not logged from real
|
| 502 |
"<b>What it describes:</b> conveyor/crane motor sensor readings β temperature, "
|
| 503 |
"vibration, current draw, and belt speed β with the 'anomaly' readings modelled "
|
| 504 |
"on realistic failure signatures (elevated temp/vibration/current with reduced "
|
|
|
|
| 1 |
"""
|
| 2 |
Smart Warehouse AI Assistant
|
| 3 |
=============================
|
| 4 |
+
A warehouse/intralogistics AI copilot demo, built for a Hugging Face
|
| 5 |
Space. Combines:
|
| 6 |
|
| 7 |
1. An LLM-powered assistant (RAG: TF-IDF retrieval + hosted LLM via the
|
|
|
|
| 15 |
5. A Model Evaluation tab reporting real accuracy/F1/ROC-AUC metrics
|
| 16 |
computed by build_artifacts.py.
|
| 17 |
|
| 18 |
+
Author: (your name here) -- built as a portfolio / job-application project.
|
| 19 |
"""
|
| 20 |
|
| 21 |
import json
|
|
|
|
| 176 |
ASSISTANT_EXAMPLES = [
|
| 177 |
"The conveyor belt in Zone C is making noise",
|
| 178 |
"How many units of SKU-1042 are in Zone B?",
|
| 179 |
+
"What's the status of order #10007?",
|
| 180 |
"What's the difference between an AGV and an AMR?",
|
| 181 |
"A forklift near-miss was reported in Zone A",
|
| 182 |
"What's the fastest picking route for a high volume order?",
|
| 183 |
"Is Crane-03 operational?",
|
| 184 |
+
"Route AGV-12 to picking station 5",
|
| 185 |
+
"What is cycle counting?",
|
| 186 |
+
"Redirect AGV-07 around the blocked aisle in Zone B",
|
| 187 |
+
"How does an AS/RS crane retrieve a pallet?",
|
| 188 |
+
"What KPIs matter most in warehouse automation?",
|
| 189 |
+
"Schedule maintenance for Sorter-02",
|
| 190 |
+
"Should we batch pick these orders together?",
|
| 191 |
+
"What is predictive maintenance?",
|
| 192 |
+
"Log a safety incident involving AMR-21",
|
| 193 |
]
|
| 194 |
|
| 195 |
|
|
|
|
| 313 |
# π Smart Warehouse AI Assistant
|
| 314 |
|
| 315 |
**A portfolio project demonstrating an applied-AI approach to intralogistics
|
| 316 |
+
and warehouse automation operations.**
|
| 317 |
+
|
| 318 |
+
Modern warehouse automation platforms β automated storage & retrieval
|
| 319 |
+
systems (AS/RS), conveyor & sortation lines, AGVs/AMRs, and the WMS/WCS
|
| 320 |
+
software that orchestrates them β generate huge volumes of operational
|
| 321 |
+
data: equipment telemetry, transactions, safety logs, and ad-hoc questions
|
| 322 |
+
from floor staff. This project is a compact, end-to-end example of how an
|
| 323 |
+
AI layer can sit on top of that kind of system: routing requests correctly,
|
| 324 |
+
answering from real operational context instead of guessing, catching
|
| 325 |
+
equipment problems early, and doing all of it with **honest, reproducible
|
| 326 |
+
evaluation** rather than a demo that just "looks like it works."
|
| 327 |
|
| 328 |
## What this demonstrates
|
| 329 |
|
| 330 |
+
| Capability | Where | Techniques used |
|
| 331 |
+
|---|---|---|
|
| 332 |
+
| **LLM-powered natural-language assistant**, grounded with retrieval (RAG) so it answers from real domain knowledge rather than hallucinating | *AI Assistant* tab | TF-IDF retrieval + hosted LLM (HF Inference API) |
|
| 333 |
+
| **Intent classification** to route free-text requests (maintenance, safety, navigation, inventory, etc.) the way a real ops system would triage tickets | *AI Assistant* / *Inventory* tabs | TF-IDF + Logistic Regression |
|
| 334 |
+
| **Predictive maintenance** via unsupervised anomaly detection on conveyor/crane sensor streams β catching bearing wear or misalignment before an unplanned stoppage | *Predictive Maintenance* tab | Isolation Forest, unsupervised |
|
| 335 |
+
| **NL-to-structured-query** over inventory/order data, a lightweight stand-in for a WMS query tool | *Inventory & Order Query* tab | Regex slot extraction + intent routing |
|
| 336 |
+
| **Rigorous, reproducible evaluation** of every ML component (accuracy, F1, ROC-AUC, retrieval hit-rate, latency) rather than just a demo that "looks like it works" | *Model Evaluation* tab | scikit-learn metrics, held-out test splits |
|
| 337 |
+
|
| 338 |
+
## Dataset overview β what the data is and where it's from
|
| 339 |
+
|
| 340 |
+
**Every dataset in this project is synthetically generated by the project's
|
| 341 |
+
own code** (`src/data_generation.py` and `src/knowledge_base.py`), not
|
| 342 |
+
scraped, exported, or sourced from any real company's systems. This was a
|
| 343 |
+
deliberate choice: it keeps the project fully self-contained, reproducible,
|
| 344 |
+
and shareable without any data-privacy or licensing concerns, while still
|
| 345 |
+
being realistic enough to demonstrate the underlying ML techniques properly.
|
| 346 |
+
|
| 347 |
+
| Dataset | What it is | Size | How it's generated |
|
| 348 |
+
|---|---|---|---|
|
| 349 |
+
| **Knowledge base** | Original, hand-written articles on generic warehouse-automation concepts (AS/RS, AGV/AMR, WMS, sortation, picking strategy, predictive maintenance, safety, inventory accuracy, KPIs, energy efficiency) | 10 articles | Written by the developer specifically for this project |
|
| 350 |
+
| **Intent queries** | Example free-text operational questions/requests across 8 categories | ~480 examples | ~8 templates per category with randomised SKU codes, zone names, order IDs, and equipment IDs slotted in |
|
| 351 |
+
| **Inventory table** | SKU records with category, zone, on-hand units, reorder point, unit cost | 60 SKUs | Randomised within realistic ranges (fixed seed) |
|
| 352 |
+
| **Orders table** | Order records with status, line count, priority, zone | 80 orders | Randomised within realistic ranges (fixed seed) |
|
| 353 |
+
| **Sensor readings** | Conveyor/crane motor telemetry: temperature, vibration, current, belt speed | 1,000 readings (900 normal + 100 anomalous) | Normal readings drawn from realistic operating ranges; anomalies simulate known failure signatures (elevated temp/vibration/current + reduced belt speed) |
|
| 354 |
+
| **Retrieval eval set** | Hand-labelled (question β expected knowledge-base article) pairs | 10 pairs | Written by the developer to check retrieval accuracy |
|
| 355 |
+
|
| 356 |
+
## How each model works (function)
|
| 357 |
+
|
| 358 |
+
| Model | Purpose | Algorithm | Input β Output |
|
| 359 |
+
|---|---|---|---|
|
| 360 |
+
| **Intent classifier** | Decide what kind of request a query is (maintenance, safety, inventory, order status, navigation, picking, system status, general FAQ) | TF-IDF + Logistic Regression | Free text β intent label + confidence |
|
| 361 |
+
| **KB retriever** | Find the most relevant knowledge-base passage(s) for a query, to ground the LLM's answer | TF-IDF + cosine similarity | Free text β top-k ranked passages |
|
| 362 |
+
| **LLM assistant** | Generate a natural-language answer grounded in the retrieved context | Hosted instruct LLM (HF Inference API), multi-model fallback chain | Query + context β grounded answer (or an extractive fallback if the LLM is unavailable) |
|
| 363 |
+
| **Inventory/order query** | Turn a question into a filtered table lookup | Regex slot extraction (SKU / order ID / zone) + intent routing | Free text β filtered inventory or orders table |
|
| 364 |
+
| **Anomaly detector** | Flag abnormal equipment sensor readings before they cause a stoppage | Isolation Forest (unsupervised), StandardScaler | 4 sensor features β anomaly / normal + anomaly score |
|
| 365 |
+
|
| 366 |
+
## How to test this project
|
| 367 |
+
|
| 368 |
+
1. **AI Assistant** β try one of the example questions, or ask your own
|
| 369 |
+
(e.g. *"The conveyor belt in Zone C is making noise"*). Check the
|
| 370 |
+
metadata line under each answer to see the detected intent, which
|
| 371 |
+
knowledge-base article(s) were retrieved, and whether the LLM or the
|
| 372 |
+
fallback path answered. If the LLM path isn't working, open the
|
| 373 |
+
**LLM connection diagnostics** accordion and click "Test LLM connection"
|
| 374 |
+
for a precise error message.
|
| 375 |
+
2. **Inventory & Order Query** β try *"How many units of SKU-1042 are in
|
| 376 |
+
Zone B?"* or *"What's the status of order #10007?"*, or browse the full
|
| 377 |
+
synthetic tables in the accordion below the search box.
|
| 378 |
+
3. **Predictive Maintenance** β load one of the presets (Normal / Early
|
| 379 |
+
bearing wear / Severe fault) or drag the sliders yourself, then click
|
| 380 |
+
*"Check for anomaly"* to see the model's verdict and recommended action.
|
| 381 |
+
4. **Model Evaluation** β every chart here is generated on **held-out test
|
| 382 |
+
data** by `build_artifacts.py`, not cherry-picked from a live run. Run
|
| 383 |
+
that script yourself to reproduce every number from scratch.
|
| 384 |
|
| 385 |
## Tech stack
|
| 386 |
|
| 387 |
- **UI / deployment:** [Gradio](https://gradio.app) on Hugging Face Spaces
|
| 388 |
- **LLM:** Hosted instruct model via the Hugging Face **Inference API**
|
| 389 |
+
(`huggingface_hub.InferenceClient`), with a multi-model fallback chain and
|
| 390 |
+
auto provider routing. Configurable via the `LLM_MODEL_ID` env var. Falls
|
| 391 |
+
back gracefully to a retrieval-only answer if no API token is configured
|
| 392 |
+
or every candidate model fails, so the public demo never just breaks.
|
| 393 |
- **Retrieval:** TF-IDF + cosine similarity over a small hand-written
|
| 394 |
warehouse-operations knowledge base (simple, fast, fully local RAG).
|
| 395 |
- **Intent classification:** TF-IDF + Logistic Regression (scikit-learn) --
|
|
|
|
| 400 |
unsupervised on scaled sensor features.
|
| 401 |
- **Evaluation:** scikit-learn metrics + matplotlib, all computed by
|
| 402 |
`build_artifacts.py` and saved as static artifacts the app loads at
|
| 403 |
+
startup (fast, reproducible Space boot, self-healing if the deployed
|
| 404 |
+
scikit-learn version ever drifts from the one used to train the models).
|
| 405 |
|
| 406 |
## Architecture
|
| 407 |
|
|
|
|
| 427 |
Sensor stream ββββΊ StandardScaler ββββΊ IsolationForest ββββΊ anomaly / normal
|
| 428 |
```
|
| 429 |
|
| 430 |
+
## Why this approach
|
| 431 |
|
| 432 |
+
The value of AI in a warehouse-automation context isn't a flashy chatbot β
|
| 433 |
+
it's **routing, grounding, and reliability**: correctly triaging a request,
|
| 434 |
+
answering from real operational context instead of guessing, and flagging
|
| 435 |
+
equipment problems before they cause downtime. Every component here was
|
| 436 |
+
chosen to be as simple as it can be while still doing that job well and
|
| 437 |
+
being honestly evaluated, rather than reaching for the biggest available
|
| 438 |
+
model by default.
|
| 439 |
|
| 440 |
## Limitations & next steps
|
| 441 |
|
| 442 |
+
- All data here is **synthetic**, for portfolio/demo purposes β a production
|
| 443 |
version would connect to real WMS/WCS APIs and historical sensor logs.
|
| 444 |
- The intent set (8 classes) and knowledge base (10 articles) are intentionally
|
| 445 |
small to keep the demo fast and auditable; both are easy to extend.
|
|
|
|
| 448 |
semi-supervised model once labelled failure data is available.
|
| 449 |
|
| 450 |
---
|
| 451 |
+
*Built as a portfolio/application project. Source code available on request
|
| 452 |
+
or in the linked repository. Feedback welcome.*
|
| 453 |
"""
|
| 454 |
|
| 455 |
|
|
|
|
| 494 |
"π§ͺ <b>Source:</b> hand-written by the developer β 10 original knowledge-base "
|
| 495 |
"articles on warehouse operations (AS/RS, AGV/AMR, WMS, sortation, picking, "
|
| 496 |
"maintenance, safety) plus ~480 template-generated example queries. Not scraped "
|
| 497 |
+
"or sourced from any real company.<br>"
|
| 498 |
"<b>What it describes:</b> generic intralogistics/automation concepts and "
|
| 499 |
"operational scenarios (equipment faults, safety incidents, order/inventory "
|
| 500 |
"questions) β general domain knowledge, not any specific facility's live data.<br>"
|
|
|
|
| 524 |
gr.HTML(data_badge(
|
| 525 |
f"π§ͺ <b>Source:</b> randomly generated by the developer's code "
|
| 526 |
f"(`src/data_generation.py`, fixed seed) β {len(inventory_df)} synthetic SKU "
|
| 527 |
+
f"records and {len(orders_df)} synthetic orders. Not exported from any real "
|
| 528 |
+
"company's WMS.<br>"
|
| 529 |
"<b>What it describes:</b> a stand-in inventory table (SKU, category, zone, "
|
| 530 |
"on-hand units, reorder point, unit cost) and orders table (order ID, status, "
|
| 531 |
"line count, priority, zone) β realistic in shape and ranges, but fictional "
|
|
|
|
| 549 |
"What's the status of order #10007?",
|
| 550 |
"Show me low stock items",
|
| 551 |
"Any delayed orders?",
|
| 552 |
+
"Is SKU-1015 in stock at Zone A?",
|
| 553 |
+
"Do we have enough SKU-1030 to fulfill 200 units?",
|
| 554 |
+
"Track order #10021 for me",
|
| 555 |
+
"Show the fulfillment status of #10045",
|
| 556 |
],
|
| 557 |
inputs=inv_input,
|
| 558 |
)
|
|
|
|
| 566 |
gr.HTML(data_badge(
|
| 567 |
"π§ͺ <b>Source:</b> randomly generated by the developer's code "
|
| 568 |
"(`src/data_generation.py`, fixed seed) β 1,000 synthetic sensor readings "
|
| 569 |
+
"(900 normal + 100 simulated-fault). Not logged from real equipment.<br>"
|
| 570 |
"<b>What it describes:</b> conveyor/crane motor sensor readings β temperature, "
|
| 571 |
"vibration, current draw, and belt speed β with the 'anomaly' readings modelled "
|
| 572 |
"on realistic failure signatures (elevated temp/vibration/current with reduced "
|
src/anomaly_model.py
CHANGED
|
@@ -5,7 +5,7 @@ Isolation Forest based anomaly detector for conveyor / crane motor sensor
|
|
| 5 |
streams (motor temperature, vibration, current draw, belt speed). This
|
| 6 |
powers the "Predictive Maintenance" tab -- flags abnormal equipment
|
| 7 |
behaviour before it causes an unplanned stoppage, which is exactly the kind
|
| 8 |
-
of workload
|
| 9 |
generate continuously in production.
|
| 10 |
"""
|
| 11 |
|
|
|
|
| 5 |
streams (motor temperature, vibration, current draw, belt speed). This
|
| 6 |
powers the "Predictive Maintenance" tab -- flags abnormal equipment
|
| 7 |
behaviour before it causes an unplanned stoppage, which is exactly the kind
|
| 8 |
+
of workload modern intralogistics platforms (e.g. AS/RS, sorters, AGVs)
|
| 9 |
generate continuously in production.
|
| 10 |
"""
|
| 11 |
|