Feast
Feast
An open-source feature store. Offline/online feature serving.
Feast
An open-source feature store. Offline/online feature serving.
Feast (Feature Store) is an open-source feature store for machine learning. A feature store is a system that centrally manages and serves the features used for ML model training and inference. Feast ensures that the same features can be used consistently in offline (batch) training and online (real-time) inference.
Feast was first developed at Gojek in 2019 and was later released as open source in collaboration with Google Cloud. It is currently developed primarily by Tecton and is a project of the Linux Foundation AI & Data. It open-sources the concept of feature stores that large companies built internally, such as Uber's Michelangelo and Airbnb's Zipline.
The core concepts of Feast are Feature View, Entity, and Feature Service. An Entity is the object that features are linked to (user ID, product ID, etc.), and a Feature View is a mapping between a group of features and a data source. A Feature Service bundles the features that a specific model needs. Training data is retrieved from the offline store (BigQuery, Snowflake, etc.), and features are served in real time from the online store (Redis, DynamoDB, etc.).
In practice, Feast solves problems such as feature reuse, preventing Training-Serving Skew, and feature versioning. Features created by a data team are shared across multiple ML teams, and training and inference are performed with the same feature definitions. In particular, Point-in-time Join makes it possible to accurately join time-series features without Data Leakage.
# feature_store.yaml (프로젝트 설정)
"""
project: my_feature_store
registry: data/registry.db
provider: local
online_store:
type: redis
connection_string: localhost:6379
offline_store:
type: file
"""
# features.py (피처 정의)
from datetime import timedelta
from feast import Entity, FeatureView, Field, FileSource
from feast.types import Float32, Int64, String
# Entity 정의 - 피처가 연결되는 대상
user = Entity(
name="user_id",
description="고객 고유 ID"
)
# 데이터 소스 정의
user_features_source = FileSource(
path="data/user_features.parquet",
timestamp_field="event_timestamp"
)
# Feature View 정의
user_features_view = FeatureView(
name="user_features",
entities=[user],
ttl=timedelta(days=1), # 온라인 스토어 TTL
schema=[
Field(name="age", dtype=Int64),
Field(name="total_purchases", dtype=Int64),
Field(name="avg_purchase_amount", dtype=Float32),
Field(name="membership_level", dtype=String),
],
online=True,
source=user_features_source,
)
# main.py (피처 스토어 사용)
from feast import FeatureStore
import pandas as pd
from datetime import datetime
# 피처 스토어 초기화
store = FeatureStore(repo_path=".")
# 1. 오프라인: 학습 데이터셋 생성 (Point-in-time Join)
entity_df = pd.DataFrame({
"user_id": [1001, 1002, 1003],
"event_timestamp": [
datetime(2024, 1, 15, 10, 0, 0),
datetime(2024, 1, 15, 11, 0, 0),
datetime(2024, 1, 15, 12, 0, 0),
]
})
training_df = store.get_historical_features(
entity_df=entity_df,
features=[
"user_features:age",
"user_features:total_purchases",
"user_features:avg_purchase_amount",
]
).to_df()
print("학습 데이터:")
print(training_df)
# 2. 피처를 온라인 스토어에 Materialize
store.materialize_incremental(end_date=datetime.now())
# 3. 온라인: 실시간 추론을 위한 피처 조회
feature_vector = store.get_online_features(
features=[
"user_features:age",
"user_features:total_purchases",
"user_features:avg_purchase_amount",
],
entity_rows=[{"user_id": 1001}]
).to_dict()
print("실시간 피처:", feature_vector)
# CLI 명령어
# feast apply # 피처 정의 적용
# feast materialize # 오프라인 -> 온라인 스토어 동기화
# feast serve # REST API 서버 실행
"We have three recommendation models, and each has its own separate feature pipeline, so the operational burden is heavy. If we build a feature store with Feast, we can define features once and share them across multiple models. The online store can respond within 10ms with Redis, and for offline we can just integrate with BigQuery."
"We keep running into Training-Serving Skew problems, and Feast's Point-in-time Join is the solution. It automatically prevents future data that could not have been known at training time from getting mixed in. You can be guaranteed exactly the same feature values in training and serving."
"The reason a feature store is needed is the scalability of ML systems. If you build a separate feature pipeline for each model, duplicated development, consistency problems, and operating costs rise sharply. Feast lets you manage feature definitions as code and version them, which is also good from a feature governance perspective."
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free
Set the interval of the materialize job that syncs features to the online store appropriately. If it runs too often, costs increase, and if it runs too rarely, features return stale values. If you need real-time features, consider Streaming Feature View.
If the online store's TTL is too short, features expire and null is returned. Conversely, if it is too long, stale data is served. Set the TTL differently depending on the characteristics of the feature (how often it changes).
Entity Keys are hard to change, so design them carefully at the beginning. If a composite key is needed, it must be defined as a separate Entity. Also, if Entity Key values contain special characters or long strings, it can affect online store performance.