Feature Store
Feature platform · Offline/online store
Written by Darjus Kazakevic · reviewed
Compute a feature once, and give training and production the same number.
A model learns from features: a user's orders in the last 30 days, a merchant's chargeback rate. At prediction time it needs the same features, computed the same way. Often they are written twice: a SQL query over the warehouse for training, and service code for live requests. The two drift apart, and the model meets inputs in production it never saw in training. That is training–serving skew, and nothing crashes when it happens.
A feature store fixes this with one definition per feature, written to two stores. The offline store keeps full history for building training sets. The online store keeps the latest value per key for millisecond reads at inference. The subtle part is the offline side: each training row must see a feature as it was when the label was recorded, never a later value.
In essence — A feature store is a promise that training and serving read the same values. Its hardest job is answering what a value was at a past moment.
When to reach for it
Reach for it when
- Several models use the same features, and teams compute them separately
- Models need fresh per-user or per-item values at request time: fraud, ranking, recommendations
- Offline scores look great and production results do not
Reconsider when
- One model scored nightly in batch: a warehouse table and a scheduled job are enough
- The model's context is documents or passages: that is retrieval, not features
- Every input comes with the request, so there is nothing to look up
The parts
- Feature definitions as code
- Each feature is declared in the repo: the entity it belongs to, its source, its transformation and window, its timestamp, its owner and how long a value stays valid. Pipelines and both stores are generated from that one definition, so there is no second copy to drift.
- The offline store
- The full history of feature values, each with its timestamp, kept in a warehouse or columnar files. It builds training sets and runs batch scoring. Throughput matters here, not latency.
- The online store
- The latest value of each feature per entity key, in a key-value store, with Redis, DynamoDB or Cassandra as common examples. Inference reads it in a few milliseconds, many features in one lookup.
- Point-in-time join (As-of join)
- How a training set is built. For each label row, an entity and a timestamp, take the latest feature value known at or before that time. A plain join on the key takes today's value instead, and the model trains on information from the future.
- Materialization (Batch and streaming pipelines)
- The jobs that compute features and write them to both stores. Batch jobs run hourly or daily over the warehouse. Streaming jobs update fast features, such as logins in the last five minutes, within seconds. Freshness is a target you set per feature.
Design rules
- Define once, compute in one place
- The same code must produce the offline history and the online values. A feature that can only be computed at request time, such as the distance from the current location, shares one function between training and serving.
- Join as of the moment the label was known
- Never join training labels to current values. Use the time a value became available, not only its event time: data that landed two hours late was not known when the decision was made.
- Log the features you served
- Record the exact values each prediction used. Comparing them with what the offline store would have produced is the only direct measure of skew, and the logs make a clean training set later.
- Give every feature a freshness budget
- Set a time-to-live and a lag target per feature, and monitor both. An expired value should fall back to the training default, visibly, not be served as if it were fresh.
Common pitfalls
- Joining labels to current feature values, so offline accuracy is a mirage.
- Using event time where arrival time matters, so late data leaks.
- Editing a feature in place under a model trained on the old version.
- Online values with no time-to-live, served stale as if they were fresh.