Warning: This is an experimental feature. To our knowledge, this is stable, but there are still rough edges in the experience. Contributions are welcome!
GitBook Assistant
Overview
Static Artifacts Loading allows you to load models, lookup tables, and other static resources once during feature server startup instead of loading them on each request. These artifacts are cached in memory and accessible to on-demand feature views for real-time inference.
GitBook Assistant
This feature optimizes the performance of on-demand feature views that require external resources by eliminating the overhead of repeatedly loading the same artifacts during request processing.
GitBook Assistant
Why Use Static Artifacts Loading?
Static artifacts loading enables data scientists and ML engineers to:
GitBook Assistant
Improve performance: Eliminate model loading overhead from each feature request
GitBook Assistant
Enable complex transformations: Use pre-trained models in on-demand feature views without performance penalties
GitBook Assistant
Share resources: Multiple feature views can access the same loaded artifacts
GitBook Assistant
Simplify deployment: Package models and lookup tables with your feature repository
GitBook Assistant
Common use cases include:
GitBook Assistant
Sentiment analysis using pre-trained transformers models
GitBook Assistant
Text classification with small neural networks
GitBook Assistant
Lookup-based transformations using static dictionaries
GitBook Assistant
Embedding generation with pre-computed vectors
GitBook Assistant
How It Works
Feature Repository Setup: Create a static_artifacts.py file in your feature repository root
GitBook Assistant
Server Startup: When feast serve starts, it automatically looks for and loads the artifacts
GitBook Assistant
Memory Storage: Artifacts are stored in the FastAPI application state and accessible via global references
GitBook Assistant
Request Processing: On-demand feature views access pre-loaded artifacts for fast transformations
GitBook Assistant
Example 1: Basic Model Loading
Create a static_artifacts.py file in your feature repository:
GitBook Assistant
Use the pre-loaded model in your on-demand feature view:
GitBook Assistant
Example 2: Multiple Artifacts with Lookup Tables
Load multiple types of artifacts:
GitBook Assistant
Use multiple artifacts in feature transformations:
GitBook Assistant
Container Deployment
Static artifacts work with containerized deployments. Include your artifacts in the container image:
GitBook Assistant
The server will automatically load static artifacts during container startup.
GitBook Assistant
Supported Artifact Types
Recommended Artifacts
Small ML models: Sentiment analysis, text classification, small neural networks
GitBook Assistant
Lookup tables: Label mappings, category dictionaries, user segments
GitBook Assistant
Configuration data: Model parameters, feature mappings, business rules
GitBook Assistant
Pre-computed embeddings: User vectors, item features, static representations
GitBook Assistant
Not Recommended
Large Language Models: Use dedicated serving solutions (vLLM, TensorRT-LLM, TGI)
# example_repo.py
import pandas as pd
from feast.on_demand_feature_view import on_demand_feature_view
# Global references for static artifacts
_sentiment_model = None
_lookup_tables: dict = {}
_config: dict = {}
@on_demand_feature_view(
sources=[text_input_request, user_input_request],
schema=[
Field(name="predicted_sentiment", dtype=String),
Field(name="is_priority_user", dtype=Bool),
Field(name="domain_category", dtype=String),
],
)
def enriched_prediction(inputs: pd.DataFrame) -> pd.DataFrame:
"""Multi-artifact feature transformation."""
global _sentiment_model, _lookup_tables, _config
results = []
for i, row in inputs.iterrows():
text = row["input_text"]
user_id = row["user_id"]
domain = row.get("domain", "")
# Use pre-loaded model
predictions = _sentiment_model(text)
sentiment_scores = {pred["label"]: pred["score"] for pred in predictions}
# Use lookup tables
predicted_sentiment = _lookup_tables["sentiment_labels"].get(
max(sentiment_scores, key=sentiment_scores.get),
_config["default_sentiment"]
)
is_priority = user_id in _lookup_tables["priority_users"]
category = _lookup_tables["domain_categories"].get(domain, "unknown")
results.append({
"predicted_sentiment": predicted_sentiment,
"is_priority_user": is_priority,
"domain_category": category,
})
return pd.DataFrame(results)
GitBook AssistantAskCopy
FROM python:3.11-slim
# Install dependencies
COPY requirements.txt .
RUN pip install -r requirements.txt
# Copy feature repository including static_artifacts.py
COPY feature_repo/ /app/feature_repo/
WORKDIR /app/feature_repo
# Start feature server
CMD ["feast", "serve", "--host", "0.0.0.0"]
GitBook AssistantAskCopy
@on_demand_feature_view(...)
def robust_prediction(inputs: pd.DataFrame) -> pd.DataFrame:
global _sentiment_model
results = []
for text in inputs["input_text"]:
if _sentiment_model is not None:
# Use pre-loaded model
predictions = _sentiment_model(text)
sentiment = max(predictions, key=lambda x: x["score"])["label"]
else:
# Fallback when artifacts aren't available
sentiment = "neutral"
results.append({"predicted_sentiment": sentiment})
return pd.DataFrame(results)