RepoSnowflake (Arctic)Snowflake (Arctic)published Feb 27, 2026seen 5d

Snowflake-Labs/sfguide-golden-batch-process-optimization-with-cortex-ai

Python

Open original ↗

Captured source

source ↗

Snowflake-Labs/sfguide-golden-batch-process-optimization-with-cortex-ai

Description: AI-powered Golden Batch optimization for confectionery manufacturing using Snowflake Cortex AI, Snowpark ML, and Streamlit

Language: Python

License: Apache-2.0

Stars: 0

Forks: 1

Open issues: 0

Created: 2026-02-27T21:00:57Z

Pushed: 2026-03-13T13:13:05Z

Default branch: main

Fork: no

Archived: no

README:

Golden Batch Process Optimization with Cortex AI

AI-powered manufacturing intelligence for Golden Batch process optimization on Snowflake.

Overview

This solution transforms process manufacturing from reactive troubleshooting to proactive optimization. Using a confectionery production line as a representative example, it unifies historian telemetry, MES events, LIMS quality results, and ERP data into a medallion architecture, then applies XGBoost prediction with SHAP explainability to identify optimal "Golden Batch" parameters. While the demo uses chocolate manufacturing data, the architecture applies to any batch process industry.

Key capabilities:

  • Cortex Analyst — Natural language queries over production metrics
  • Cortex Search — RAG retrieval from maintenance documentation
  • XGBoost + SHAP — Yield prediction with instant root cause attribution
  • What-If Simulation — Pre-computed scenarios for parameter optimization

Prerequisites

> Note on Privileges: This guide uses ACCOUNTADMIN for simplicity in demo and learning environments. For production deployments, follow the principle of least privilege by creating a dedicated role with only the specific grants required.

Quick Start

Step 1: Run Setup

1. Open Snowsight: ProjectsWorksheets 2. Click +Add New to create a new SQL worksheet 3. Copy the entire contents of `scripts/setup.sql` 4. Paste and click Run All

> Note: Setup automatically executes the ML notebook SWEET_SPOT_ML_NOTEBOOK, which trains XGBoost models and populates SHAP explainability data. The notebook is idempotent and can be re-run manually in Snowsight: Switch to role SWEET_SPOT_ROLEProjectsNotebooksSWEET_SPOT_ML_NOTEBOOK if needed.

Step 2: Access the Dashboard

Navigate in Snowsight:

1. Switch to role SWEET_SPOT_ROLE 2. ProjectsStreamlitSWEET_SPOT_DASHBOARD

The dashboard has 7 pages:

| Page | Description | |------|-------------| | Home | Executive summary with KPI metrics, platform capabilities, and recent alerts | | Process Overview | Real-time monitoring across all 5 manufacturing stages (Ganache Prep, Tempering, Depositing, Cooling, Enrobing) with stage-level metrics and trends | | Golden Batch Analysis | Identifies optimal parameter ranges that produce the highest yield — compare golden vs. non-golden batches across process variables | | Root Cause Analysis | SHAP-based explainability showing why specific batches failed, with operator note correlation and equipment signature detection | | What-If Simulation | Pre-computed scenario comparisons (supplier switching, environmental conditions) plus dynamic predictions via the ML model UDF | | AI Assistant | Natural language queries over production data via Cortex Analyst, and semantic search over maintenance manuals via Cortex Search | | About | Architecture overview, data dictionary, and platform documentation |

What Gets Created

| Object | Name | |--------|------| | Database | YO_SWEET_SPOT | | Schemas | RAW, ATOMIC, YO_SWEET_SPOT | | Warehouse | SWEET_SPOT_WH | | Compute Pool | SWEET_SPOT_COMPUTE_POOL | | Role | SWEET_SPOT_ROLE | | Cortex Search | MAINTENANCE_MANUAL_SEARCH | | Streamlit | SWEET_SPOT_DASHBOARD | | Notebook | `SWEET_SPOT_ML_NOTEBOOK` | | UDF | PREDICT_BATCH_OUTCOME |

Cleanup

1. Open Snowsight: ProjectsWorksheets 2. Click +Add New to create a new SQL worksheet 3. Copy contents of `scripts/teardown.sql` 4. Paste and click Run All

Conclusion

You now have a complete AI-powered manufacturing intelligence platform that:

  • Deploys realistic manufacturing data across a medallion architecture
  • Trains XGBoost models with SHAP explainability in Snowpark
  • Enables natural language analytics via Cortex Analyst
  • Provides RAG-powered document retrieval via Cortex Search
  • Delivers insights through a 7-page Streamlit dashboard

Transform your plant from reactive firefighting to proactive optimization — where AI prevents quality failures before they cascade.

License

Copyright (c) Snowflake Inc. All rights reserved.

The code in this repository is licensed under the Apache 2.0 License.

Notability

notability 3.0/10

Routine guide repo from Snowflake