source: kdnuggets: feature stores from scratch: a minimal working implementation
level: technical
a feature store solves training-serving skew by defining features once and keeping offline and online stores in sync. this implementation uses duckdb for point-in-time joins on parquet files, redis for sub-millisecond online lookups, and fastapi to serve features. the same design also supplies structured user context to llm agents and rag pipelines at inference time.
the system has five components: a feature registry as a single source of truth, an offline store for historical data, an online store for latest values, a materialization pipeline to push updates, and a retrieval api. the registry is a python dataclass mapping feature names to entity, dtype, and source. offline queries use asof joins to prevent data leakage. online storage uses redis hashes keyed by entity:id for fast hmget calls.
materialization runs on a schedule, pulling the latest row per entity from parquet and writing to redis. the fastapi endpoint accepts a user id and returns requested features, which can be injected into an llm prompt. common mistakes include computing features inside model services, treating the online store as the source of truth, skipping the registry, and confusing vector databases with feature stores. the full code is about 200 lines and mirrors production systems like feast.
why it matters: a feature store ensures consistent, low-latency feature retrieval for both traditional ml models and llm applications, reducing drift and duplication in production pipelines.
source: kdnuggets: feature stores from scratch: a minimal working implementation