build-feature-store
关于
This skill builds a Feast-based feature store for centralized ML feature management, handling both batch and real-time serving. It enables defining feature views with transformations and point-in-time correct joins for consistent training and inference. Use it when managing features across multiple models, ensuring training-serving consistency, or needing low-latency feature serving.
快速安装
Claude Code
推荐npx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/build-feature-store在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
Build Feature Store
See Extended Examples for complete config files + templates.
Centralized feature mgmt w/ Feast → consistent feature serving across training + inference.
Use When
- Managing features for many ML models across teams
- Training-serving consistency for features
- Point-in-time correct historical features
- Low-latency features for real-time inference
- Reusing feature defs across projects
- Versioning feature transformations
- Feature catalog for discovery + governance
- Prevent feature leakage in training pipelines
In
- Required: Raw data sources (DBs, data lakes, warehouses)
- Required: Python env w/ Feast installed
- Required: Offline store backend (BigQuery, Snowflake, Redshift, Parquet)
- Required: Online store backend (Redis, DynamoDB, Cassandra, SQLite for dev)
- Optional: Feature transformation logic (Python, SQL, Spark)
- Optional: Entity key defs (user_id, product_id, etc.)
- Optional: K8s cluster for Feast server deploy
Do
Step 1: Init Feast Repo
Set up Feast project structure + config storage backends.
# Install Feast with required extras
pip install 'feast[redis,postgres]' # Add backends as needed
# Initialize new feature repository
feast init my_feature_repo
cd my_feature_repo
# Directory structure created:
# my_feature_repo/
# ├── feature_store.yaml # Configuration
# ├── features.py # Feature definitions
# └── data/ # Sample data (dev only)
Config feature_store.yaml:
# feature_store.yaml
project: customer_analytics
registry: data/registry.db # SQLite for dev, use S3/GCS for prod
provider: local
# Offline store for training data
offline_store:
type: postgres
# ... (see EXAMPLES.md for complete implementation)
Prod config w/ cloud backends:
# feature_store.prod.yaml
project: customer_analytics
registry: s3://feast-registry/prod/registry.db
provider: aws
offline_store:
type: bigquery
project_id: my-gcp-project
# ... (see EXAMPLES.md for complete implementation)
→ Feast repo init'd w/ config, sample feature defs, offline+online stores configured, registry accessible.
If err: Verify DB/Redis credentials (psql -U feast_user -h localhost), check conn string format, ensure DBs exist (CREATE DATABASE feature_store), verify cloud perms for S3/BigQuery/DynamoDB, test connectivity, check Feast ver compat w/ backends (feast version).
Step 2: Entities + Data Sources
Entity defs + connect to raw sources.
# entities.py
from feast import Entity, ValueType
# Define entities (primary keys for features)
customer = Entity(
name="customer",
description="Customer entity",
value_type=ValueType.INT64,
# ... (see EXAMPLES.md for complete implementation)
Data sources:
# data_sources.py
from feast import FileSource, BigQuerySource, RedshiftSource
from feast.data_format import ParquetFormat
from datetime import timedelta
# Development: File-based source
customer_transactions_source = FileSource(
path="data/customer_transactions.parquet",
# ... (see EXAMPLES.md for complete implementation)
→ Entity defs ref correct ID cols, sources connect to raw data, event_timestamp_col exists, created_timestamp_col allows point-in-time queries.
If err: Verify source files exist + readable, check BigQuery/Redshift credentials + table access, ensure timestamp cols correct format (Unix/ISO8601), verify Kafka connectivity + topic existence, check schema compat sources ↔ entities.
Step 3: Feature Views + Transformations
Feature views → how raw data becomes ML-ready features.
# feature_views.py
from feast import FeatureView, Field
from feast.types import Float32, Int64, String, Bool
from datetime import timedelta
from entities import customer, product
from data_sources import customer_features_source
# Simple feature view without transformations
# ... (see EXAMPLES.md for complete implementation)
→ Feature views registered, schema matches source, transformations execute w/o errs, TTL values appropriate, on-demand views combine batch + req features.
If err: Verify field names match source cols exactly, check dtype compat (Int64 vs Int32), ensure entity refs exist, validate transformation w/ sample data, check div-by-zero in calcs, verify req source schema matches inference payload.
Step 4: Apply Defs + Materialize
Deploy defs to registry, materialize to online store.
# Apply feature definitions to registry
feast apply
# Expected output:
# Created entity customer
# Created feature view customer_stats
# Created on demand feature view customer_segments
# ... (see EXAMPLES.md for complete implementation)
Programmatic materialization:
# materialize_features.py
from feast import FeatureStore
from datetime import datetime, timedelta
# Initialize feature store
fs = FeatureStore(repo_path=".")
# Materialize all feature views
# ... (see EXAMPLES.md for complete implementation)
→ Defs applied to registry w/o conflicts, materialization job completes, online store populated, freshness w/in TTL.
If err: Check offline store query succeeds (feast feature-views describe customer_stats), verify time range has data, ensure online store writable (Redis/DynamoDB perms), check dup feature names across views, verify entity keys in source, monitor materialization logs, check disk space for local stores.
Step 5: Retrieve for Training
Point-in-time correct historical features for model training.
# get_training_data.py
from feast import FeatureStore
import pandas as pd
from datetime import datetime
# Initialize feature store
fs = FeatureStore(repo_path=".")
# ... (see EXAMPLES.md for complete implementation)
Point-in-time correctness validation:
# validate_pit_correctness.py
import pandas as pd
from datetime import datetime, timedelta
def validate_point_in_time_correctness(training_df, entity_df):
"""
Ensure features don't leak future information.
"""
# ... (see EXAMPLES.md for complete implementation)
→ Historical features retrieved, entity_df timestamps preserved, no NaN for materialized features, point-in-time correct (no future leak), feature service groups logically.
If err: Check entity_df has req cols (entity names + event_timestamp), verify feature view names match registry, ensure offline store has data for time range, check timezone mismatches (use UTC), verify entity IDs in source, inspect SQL query err logs, validate TTL covers time range.
Step 6: Serve for Real-Time Inference
Low-latency features from online store for model serving.
# serve_features.py
from feast import FeatureStore
import time
# Initialize feature store
fs = FeatureStore(repo_path=".")
def get_inference_features(customer_ids: list, request_data: dict = None):
# ... (see EXAMPLES.md for complete implementation)
FastAPI integration:
# api.py
from fastapi import FastAPI
from pydantic import BaseModel
from feast import FeatureStore
import mlflow
app = FastAPI()
fs = FeatureStore(repo_path=".")
# ... (see EXAMPLES.md for complete implementation)
→ Online features retrieved in <10ms for single entity, batch scales efficiently, on-demand transformations execute, request-time + batch features merged, API <50ms e2e.
If err: Check online store populated (materialize if empty), verify Redis/DynamoDB connectivity + latency, ensure entity keys in online store, check cold start (warm cache), verify on-demand logic, monitor online store mem/CPU, check network latency service ↔ online store.
Check
- Feast repo init'd + configured
- Offline + online stores connected
- Entity defs match source data
- Feature views registered in registry
- On-demand transformations execute correctly
- Materialization completes w/o errs
- Historical features retrieved w/ PIT correctness
- Online features served low-latency (<10ms)
- Feature freshness w/in TTL
- Training-serving consistency verified
- Feature catalog accessible for discovery
Traps
- Feature leakage: Future data in historical features → always validate PIT correctness, use created_timestamp col
- Inconsistent transformations: Diff logic training vs serving → use Feast on-demand views for consistency
- Stale features: Online store not materialized regularly → scheduled materialization jobs (cron/Airflow)
- Missing entity keys: Entities in training not in online store → comprehensive materialization, handle missing gracefully
- Type mismatch: Schema types don't match source → validate dtypes before apply, explicit Field defs
- Slow online retrieval: Network latency or overloaded online store → co-locate w/ inference service, use conn pooling
- Large feature views: Millions of entities slow → partition by date, incremental materialization, optimize offline queries
- No feature versioning: Breaking changes affect prod models → version views, backward compat
- Timezone confusion: Mixing tz → incorrect joins. Always UTC
- Ignoring TTL: Serving expired features → set appropriate TTL, monitor freshness
→
track-ml-experiments— log feature metadata in MLflow experimentsorchestrate-ml-pipeline— schedule feature materialization jobsversion-ml-data— version raw data sources for feature engdeploy-ml-model-serving— integrate feature store w/ model servingserialize-data-formats— choose efficient storage for featuresdesign-serialization-schema— design schemas for feature sources
GitHub 仓库
相关推荐技能
content-collections
元Content Collections 是一个 TypeScript 优先的构建工具,可将本地 Markdown/MDX 文件转换为类型安全的数据集合。它专为构建博客、文档站和内容密集型 Vite+React 应用而设计,提供基于 Zod 的自动模式验证。该工具涵盖从 Vite 插件配置、MDX 编译到生产环境部署的完整工作流。
polymarket
元这个Claude Skill为开发者提供完整的Polymarket预测市场开发支持,涵盖API调用、交易执行和市场数据分析。关键特性包括实时WebSocket数据流,可监控实时交易、订单和市场动态。开发者可用它构建预测市场应用、实施交易策略并集成实时市场预测功能。
creating-opencode-plugins
元该Skill帮助开发者创建OpenCode插件,用于接入命令、文件、LSP等25+种事件。它提供了插件结构、事件API规范和JavaScript/TypeScript实现模式,适合需要拦截操作、扩展功能或自定义事件处理的场景。开发者可通过它快速构建响应式模块来增强OpenCode AI助手的能力。
sglang
元SGLang是一个专为LLM设计的高性能推理框架,特别适用于需要结构化输出的场景。它通过RadixAttention前缀缓存技术,在处理JSON、正则表达式、工具调用等具有重复前缀的复杂工作流时,能实现极速生成。如果你正在构建智能体或多轮对话系统,并追求远超vLLM的推理性能,SGLang是理想选择。
