How-To Guide

How to Version Features and Stay Point-in-Time Correct

Version features and compute training sets point-in-time correctly, so a model sees only what was knowable at the moment of each prediction.

On this page

  1. Introduction
  2. What Point-in-Time Correctness Means
  3. The As-Of Join
  4. Feature Versioning
  5. Training-Serving Consistency
  6. Backfills and Late Data
  7. Serving Freshness and Caching
  8. Common Pitfalls and Conclusion

Introduction

A model trained on features that leak information from the future performs beautifully offline and fails in production. The classic mistake is computing a training set with the latest feature values, so a row from last month is labelled with a feature value that did not exist until today. Point-in-time correctness fixes this by joining each labelled example to the feature value as it was at the example’s timestamp. Feature versioning is the companion: when a feature’s definition changes, the old values must remain reproducible for models trained on them.

What Point-in-Time Correctness Means

For each training example, the features must be the values that were actually available at the time of the prediction, not the values known now. If a feature is a customer’s lifetime spend, a training example from January must use the lifetime spend as of January, not the current total. Using the current total leaks the future into the past.

The same applies to labels: the label is the outcome known after the prediction window, and the split between feature time and label time must be respected. Getting this wrong produces a model that looks accurate offline and disappoints in production, because offline it was cheating.

# the leakage
training row: event at 2026-01-15, label = did they churn by 2026-02-15
features computed:  lifetime_spend = current_value (2026-10)
=> the model saw 9 months of future spend; offline metrics are inflated
# point-in-time: join features AS OF 2026-01-15, label from the window after

The As-Of Join

Point-in-time correctness is an as-of join: for each example at time T, find the feature record with the greatest timestamp less than or equal to T. Event-based features are naturally as-of; snapshot features need a history table with valid-from timestamps. The join then takes the version valid at T, not the latest.

Efficient as-of joins use an index on (entity_id, valid_from) and, per example, a lookup of the latest row not exceeding T. In warehouse SQL this is a lateral join or a windowed lookup; the key is that the join condition includes the time bound, not just the entity.

-- As-of join: the feature row valid at the example's time, per entity.
SELECT e.entity_id, e.event_time, e.label,
       f.lifetime_spend
FROM training_examples e
LEFT JOIN LATERAL (
  SELECT lifetime_spend
  FROM customer_features f
  WHERE f.entity_id = e.entity_id
    AND f.valid_from <= e.event_time       -- the as-of bound
  ORDER BY f.valid_from DESC
  LIMIT 1
) f ON true;

Feature Versioning

A feature is not just a name; it is a definition. When the definition changes, for example a churn score computed with a new rule, the feature’s meaning changes while the name may not. Versioning means each feature has a version and each value records which version produced it, so a model trained on v1 can still read v1 values.

Versioning prevents the subtle disaster of a model reading values produced by a definition it was not trained on. A new definition becomes a new feature version; models opt into it explicitly. Old versions stay computable or at least readable until every model that used them is retired.

-- Feature rows carry a definition version.
CREATE TABLE customer_features (
  entity_id      bigint NOT NULL,
  feature_name   text   NOT NULL,
  feature_version int   NOT NULL,
  valid_from     timestamptz NOT NULL,
  value          double precision,
  PRIMARY KEY (entity_id, feature_name, feature_version, valid_from)
);
-- a model records the (feature_name, feature_version) set it was trained on

Training-Serving Consistency

The features used in training must be computed the same way as those served at inference. A training pipeline that computes a feature in SQL and a serving path that computes it in application code will drift, and the drift can be invisible until the model underperforms. Sharing the computation, or validating that the two agree on a sample, is essential.

A common safeguard is to log the served feature vector and compare it, after the fact, to the same features computed by the training pipeline for that timestamp. Divergence points at a bug in one of the two paths before it degrades the model. This is the feedback loop that keeps training and serving honest.

# training-serving skew guard
serving:  compute + log feature vector (with entity + event_time)
later:    recompute from the offline store AS OF that event_time
compare:  served vs recomputed -> must match within a tolerance
# a mismatch => the two paths disagree; fix before it hurts the model

Backfills and Late Data

When a feature’s historical values were computed with a bug, you must backfill: recompute the affected history with the corrected logic, and retrain the models that used it. This is possible only if the feature is a deterministic function of the source data, so keep the raw inputs.

Late-arriving data complicates as-of joins: a value that should have been known at time T may arrive after T. Decide the rule explicitly: either the model must use what was available at T (strict, but then the value is missing), or the pipeline must know which late data would have been available. Most systems choose strict as-of, accepting that some late data is not used, because using it would leak.

# backfill + late data
backfill: recompute history with fixed logic -> retrain models on it
          (possible only if features are deterministic from raw inputs)
late data: a value that arrives after T
  strict as-of: use only what was available at T (may be missing) -> no leak
  lenient:      use late data -> risks leaking the future
# choose strict; document that late data is not used in training

Serving Freshness and Caching

Online serving must provide the feature value as of now, or as of the request, quickly. A feature store caches the latest values for low-latency serving and reads history for as-of training, which is why feature stores separate the online and offline views. The two views must be consistent, computed from the same source.

Caching latest values is fine for serving, but the cache must have a bounded staleness, and the training set must never read from the serving cache. Keep the offline store as the source of truth for features, and treat the online store as a materialised view of the latest values for serving.

# online vs offline feature views
online store: latest value per entity, low latency, bounded staleness
              -> used at inference only
offline store: full history with valid_from, as-of joins
              -> used to build training sets (never the serving cache)
# both computed from the SAME source; validate they agree on a sample

Common Pitfalls and Conclusion

Do not build a training set from the latest feature values; that leaks the future. Do not let the training and serving paths compute features differently. Do not change a feature’s definition under the same version. Do not ignore late data silently; decide the rule. And do not forget that labels have a time too, and the split between features and labels must be respected.

Point-in-time correctness joins each training example to the feature value valid at its time, and feature versioning keeps values readable after a definition changes. Build training sets with as-of joins, version each feature, keep training and serving consistent from one source, backfill when logic changes, and choose an explicit rule for late data. Then a model’s offline metrics mean something in production.

Sources: Feast: Point-in-time correctness, Google: Rules of Machine Learning, Databricks: Feature store.

FAQ

What is feature leakage?
Using feature values that were not available at the time of the prediction, such as the current lifetime spend for a training example from months ago. It inflates offline metrics because the model saw the future, and it disappears in production where the future is unknown.
Why version a feature rather than just changing it?
Because a changed definition changes the meaning of the values, so a model trained on the old definition would read incompatible values. A new version lets models opt in explicitly and keeps the old values readable for models still using them.

Related Examples