Building an Open, Flexible and ACID-Compliant Data Lakehouse for AI/ML with Delta Lake
The Rise of AI/ML and the Need for New Data Architectures
Artificial intelligence (AI) and machine learning (ML) are transforming virtually every industry. From healthcare and finance to retail and manufacturing, ML models are delivering more accurate predictions, intelligent automation and tailored user experiences. According to McKinsey, AI could deliver an additional global economic output of around $13 trillion by 2030, and 97 million new jobs could be created by 2025 as companies adopt AI/ML technologies.
However, implementing AI/ML at scale introduces new requirements for data platforms. ML workflows need to rapidly ingest and process massive volumes of structured and unstructured data. Data scientists need to frequently experiment with new datasets, features and modeling approaches. ML inference requires fast, real-time access to data to make predictions.
Traditional data architectures like data warehouses struggle with the scale and variety of data used in ML. At the same time, data lakes lack critical capabilities around data integrity, quality and performance. Teams are forced to stitch together complex piecemeal architectures for their ML pipelines.
Just as the data lakehouse is emerging as a new paradigm for data platforms, it‘s also well suited for AI/ML use cases. With a lakehouse architecture powered by Delta Lake, organizations can simplify their data and ML infrastructure with an open, reliable and scalable foundation.
Key Benefits of Lakehouses for AI/ML
A data lakehouse enabled by Delta Lake provides several key benefits for ML workloads:
-
Support for diverse data types – ML often relies on complex, unstructured and semi-structured data like text, images, video and time series. A Delta Lake can store these diverse data types in open formats like Parquet at scale.
-
Cost-effective and elastic – Training large ML models and running batch inference can require huge volumes of data and compute resources. With decoupled storage and compute, Delta Lake allows cost-effectively scaling storage and compute separately for these variable workloads.
-
ACID transactions – Inconsistent or corrupted data can silently degrade model performance. Delta Lake‘s ACID transactions ensure reliable data for the entire ML workflow from feature engineering to model training and inference.
-
Data versioning and time travel – Reproducing models and experiments is critical in ML. Delta Lake‘s time travel capabilities allow data scientists to query data as it existed at a specific point in time for reproducible results.
-
Schema evolution – As ML initiatives mature, data schemas inevitably change. New signals are added and features are refined. Delta Lake supports schema evolution so models can adapt to changing data over time.
-
Integration with ML tools – Through the Delta Lake ecosystem, data scientists can access data in Delta Lake using their preferred tools and frameworks like PyTorch, Tensorflow, SciKit Learn, Pandas and more.
By implementing Delta Lake, enterprise data teams can deliver a reliable, scalable and performant lakehouse to power their AI/ML initiatives while maintaining flexibility and openness.
Delta Lake Adoption for AI/ML
Thousands of enterprises across industries are using Delta Lake in production for their ML use cases. Adoption has accelerated as more organizations seek to deploy ML rapidly and at scale.
- The Delta Lake open source project has been downloaded over 1M times per month with 5000+ stars on GitHub
- There are 100+ contributing developers to the Delta Lake project
- Delta Lake is deployed at thousands of enterprises including Shell, Comcast, Walmart and more
- Databricks‘ fully-managed Delta Lake service has 5000+ customers processing exabytes of data
This strong adoption across data-driven organizations demonstrates the maturity and capabilities of Delta Lake for reliable and scalable AI/ML use cases.
Delta Lake for ML Workflows
Let‘s walk through an example architecture and workflow for an ML use case on Delta Lake. Consider a retail company building an ML model to predict customer churn.
First, data engineers can ingest raw data from various source systems like clickstream logs, CRM, support tickets and transaction history into a "Bronze" Delta Lake table. Delta Lake provides auto schema inference and evolution to handle changing data structure over time.
Data scientists can then directly explore and query this data using Python and SQL notebooks. They may choose to materialize cleaned and validated data into new Silver and Gold Delta tables. PySpark can be used to join data across tables and engineer relevant features for the churn model like customer engagement metrics.
With ML Libraries like Scikit-Learn, PyTorch or Tensorflow, data scientists can train the churn model using the curated feature data in Delta Lake. Delta Lake‘s time travel capabilities allow them to reproduce experiments on a specific version of data. The trained model can be registered in the MLflow model registry along with the Delta table version used.
For real-time inference, the model can be deployed to a REST endpoint using a tool like MLflow Model Serving. Batch inference can directly read features from Delta Lake and score large datasets.
As new data is collected, ML pipelines can easily read updated data in Delta Lake to retrain models with new information. Delta Lake‘s ACID transactions ensure that the pipeline always has a consistent version of data to train on.
Here‘s an example PySpark code snippet for reading a Delta table and training a simple model:
from pyspark.sql import SparkSession
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
spark = SparkSession.builder.appName("ChurnPredictor").getOrCreate()
# Read curated features from Delta table
features_df = spark.read.format("delta").load("/ml/features/churn")
# Convert to pandas DataFrame for training
pd_df = features_df.toPandas()
X = pd_df.drop(["user_id", "churn"], axis=1)
y = pd_df["churn"]
# Train model
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33)
model = RandomForestClassifier(n_estimators=100, max_depth=5)
model.fit(X_train, y_train)
print(f"Train accuracy: {model.score(X_train, y_train)}")
print(f"Test accuracy: {model.score(X_test, y_test)}")
This example shows loading data from a Delta Lake table and training a RandomForest model to predict customer churn. The same data in Delta Lake can be used for batch scoring or retraining the model over time as new data arrives.
Delta Lake Roadmap for AI/ML
As an open source project, Delta Lake continues to evolve to better support AI/ML use cases. Some key capabilities on the roadmap include:
- Streaming ingestion support for real-time data used in ML
- Efficient updates/deletes for rapidly changing data
- Improved performance and indexing
You can view the full Delta Lake roadmap and release notes on the project wiki.
Resources to Learn More
Here are some helpful resources to dive deeper into Delta Lake and AI/ML:
- Data + AI Summit 2022 Lakehouse Keynote – Overview of latest advancements in Lakehouse architecture
- Productionizing Machine Learning with Delta Lake – Talk on challenges productionizing ML and how Delta Lake can help
- ML Reproducibility with Time Travel in Delta Lake – Post on using Delta Lake time travel for reproducible ML experiments
- Integrating MLOps and Delta Lake – Whitepaper on building production ML pipelines with Delta Lake
- The Emerging Lakehouse Paradigm for Data and AI – Technical paper on the Lakehouse architecture
Conclusion
The data lakehouse enabled by Delta Lake is becoming a key architecture for AI/ML platforms. It provides the openness, flexibility and scale needed for modern ML workloads, without compromising on data reliability and performance.
With a simplified data architecture powered by Delta Lake, data scientists and ML engineers can focus on rapidly building and deploying models while being confident in the integrity of the underlying data platform.
As data volumes and ML use cases continue to grow, the lakehouse will be a critical foundation for enterprises looking to become model-driven. Those that adopt architectures like Delta Lake will be best positioned to realize the transformative potential of AI/ML.