
Feature Store Integration at Serving Time
How to use the Vertex AI Feature Store for low-latency feature lookups at serving time.
Real-time Features for Real-time Predictions
When making a prediction in real-time, you often need to fetch the latest feature values for the user or item. For example, to predict if a user will click on an ad, you might need to know their average click-through rate over the last hour.
The Vertex AI Feature Store is designed for this exact purpose. It provides a low-latency online store for feature values that can be queried at serving time.
1. Online vs. Offline Store
The Feature Store has two components:
- Offline Store: A BigQuery table that stores the historical feature values. This is used for training.
- Online Store: A low-latency database (like Bigtable) that stores the latest feature values. This is used for serving.
Data is ingested into the offline store, and then synced to the online store.
2. Fetching Features at Serving Time
When a prediction request comes in, your serving code needs to:
- Get the user or item ID from the request.
- Query the Feature Store's online store to get the latest feature values for that ID.
- Pass the feature values to the model to get a prediction.
Example: Online Feature Fetching
from google.cloud import aiplatform
# Get the latest feature values for user '123'
features = aiplatform.gapic.FeaturestoreOnlineServingServiceClient().read_feature_values(
entity_type="users",
entity_id="123",
feature_selector={"ids": ["avg_ctr_1h", "avg_spend_1d"]},
)
# Pass the features to the model
prediction = model.predict(features)
3. Benefits of Using the Feature Store
- Low Latency: The online store is designed for low-latency feature lookups, which is essential for real-time prediction.
- Consistency: The Feature Store ensures that the same feature values are used for both training and serving, which helps to prevent training-serving skew.
- Centralization: The Feature Store provides a central place to manage your features, which makes it easier to share features across different models and teams.
Knowledge Check
?Knowledge Check
You are serving a model that requires real-time features from the Vertex AI Feature Store. What is the primary benefit of using the online store for serving?