Spaces:
Running on Zero
Running on Zero
| title: Smart Warehouse AI Assistant | |
| emoji: π | |
| colorFrom: blue | |
| colorTo: indigo | |
| sdk: gradio | |
| sdk_version: 5.9.1 | |
| app_file: app.py | |
| pinned: false | |
| license: mit | |
| short_description: LLM warehouse copilot with predictive maintenance | |
| # π Smart Warehouse AI Assistant | |
| An LLM-powered, retrieval-grounded AI copilot for automated warehouse | |
| operations -- built as a portfolio / application project. Combines an | |
| **LLM assistant (RAG)**, an **intent classifier**, an **inventory/order | |
| query layer**, and an **Isolation-Forest predictive-maintenance model**, | |
| with a full **Model Evaluation** tab reporting real accuracy/F1/ROC-AUC | |
| metrics on held-out test data. | |
| π **Live demo:** add your Space URL here once deployed, e.g. | |
| `https://huggingface.co/spaces/<your-username>/daifuku-warehouse-ai` | |
| ## Tabs | |
| 1. **π¬ AI Assistant** β ask free-text warehouse-ops questions; answers are | |
| grounded via TF-IDF retrieval over a small knowledge base and generated | |
| by a hosted LLM (Hugging Face Inference API, with a multi-model fallback | |
| chain), with a transparent retrieval-only fallback and a built-in | |
| **"Test LLM connection" diagnostics button** if no API key is configured | |
| or the call fails. Includes an "About the data" panel explaining the | |
| knowledge base and training data. | |
| 2. **π¦ Inventory & Order Query** β natural-language queries over synthetic | |
| inventory / order tables (SKU, zone, order-id extraction), with an | |
| "About the data" panel describing the synthetic tables. | |
| 3. **β οΈ Predictive Maintenance** β Isolation Forest anomaly detector over | |
| conveyor/crane motor sensor readings (temperature, vibration, current, | |
| belt speed), with an "About the data" panel describing the synthetic | |
| sensor dataset and failure patterns. | |
| 4. **π Model Evaluation** β accuracy, macro-F1, confusion matrices, | |
| ROC-AUC, retrieval hit-rate, and latency benchmarks, all computed on | |
| held-out data by `build_artifacts.py` and rendered as charts (bar | |
| charts, confusion matrices, ROC curve, feature-distribution histograms) | |
| alongside the underlying tables. | |
| 5. **βΉοΈ About** β project write-up, architecture diagram, tech stack. | |
| ## Quick start (local) | |
| ```bash | |
| git clone <this-repo> | |
| cd daifuku-warehouse-ai | |
| pip install -r requirements.txt | |
| # (re)generate datasets, train models, produce evaluation plots/metrics | |
| python build_artifacts.py | |
| # run the app | |
| python app.py | |
| ``` | |
| Open the printed local URL (usually `http://127.0.0.1:7860`). | |
| ## Enabling full LLM responses | |
| The app works out of the box in **retrieval-only fallback mode** (no | |
| external API calls). To enable real LLM-generated answers: | |
| 1. Create a Hugging Face access token: https://huggingface.co/settings/tokens | |
| 2. Set it as an environment variable / Space secret named `HF_TOKEN`. | |
| 3. (Optional) Set `LLM_MODEL_ID` to override the default model | |
| (`Qwen/Qwen2.5-7B-Instruct`) with any chat-capable model available via | |
| HF Inference Providers. | |
| ```bash | |
| export HF_TOKEN=hf_xxxxxxxxxxxxxxxxxxxx | |
| python app.py | |
| ``` | |
| ## Deploying to Hugging Face Spaces | |
| See [`DEPLOY.md`](./DEPLOY.md) for full step-by-step instructions. | |
| ## Project structure | |
| ``` | |
| daifuku-warehouse-ai/ | |
| βββ app.py # Gradio app (5 tabs) | |
| βββ build_artifacts.py # generates data, trains models, evaluates, saves plots | |
| βββ requirements.txt | |
| βββ src/ | |
| β βββ data_generation.py # synthetic intent / inventory / sensor datasets | |
| β βββ knowledge_base.py # warehouse-ops knowledge base (RAG source docs) | |
| β βββ retriever.py # TF-IDF retriever | |
| β βββ intent_model.py # intent classifier (train/predict) | |
| β βββ anomaly_model.py # Isolation Forest anomaly detector | |
| β βββ llm_client.py # HF Inference API client + fallback | |
| β βββ inventory_db.py # NL -> structured query helpers | |
| βββ models/ # trained model artifacts (.joblib) | |
| βββ data/ # generated datasets + evaluation JSON | |
| βββ assets/ # evaluation plots (confusion matrices, ROC curve) | |
| ``` | |
| ## Evaluation summary | |
| See the in-app **Model Evaluation** tab for full details (confusion | |
| matrices, per-class precision/recall, retrieval hit-rate table, latency | |
| benchmark). Headline numbers from the included run: | |
| | Component | Metric | Score | | |
| |---|---|---| | |
| | Intent classifier | Accuracy | ~99% | | |
| | Intent classifier | Macro F1 | ~99% | | |
| | Anomaly detector | F1 | ~97% | | |
| | Anomaly detector | ROC-AUC | ~1.00 | | |
| | RAG retriever | Hit-rate@2 | 100% | | |
| *(Computed on synthetic, held-out test data β see the Evaluation tab for | |
| methodology notes.)* | |
| ## License | |
| MIT β feel free to fork and adapt. | |