Online vs offline features

Offline features are computed and stored for training models and batch scoring, usually in a warehouse or lakehouse that keeps their full history. Online features are the same features served at low latency to a model answering a live request, usually as the latest value per key in a key-value store. A model only behaves in production as it did in testing when both come from the same definition.

By Alex DeanUpdated

What is the difference between online and offline features?

An offline feature is a value computed for training or batch scoring and kept with its history, so you can ask what it was for any customer at any past moment. An online feature is the same value kept current and served to a model while a request waits, so you can ask what it is right now. The feature is the same idea in both places. What differs is the question each store answers, and what that does to how it is built.

Most feature stores split along this line. Feast describes its offline store as the place to build training datasets from time-series features, and its online store as holding only the latest values for each entity key. Hopsworks draws the same split: historical values in a lake or warehouse, latest values in a low-latency database.

Offline store Online store
Purpose Build training sets, run batch scoring Serve features to a model at inference
Data held Full history, one row per value over time The latest value per key
Read pattern Large scans and joins across many keys Single-key lookups, one request at a time
Freshness As of the last batch run As current as the pipeline writing to it
Latency needs Throughput matters more than response time Has to answer inside a live request’s budget
Typical storage Warehouse or lakehouse: Snowflake, BigQuery, Databricks, files in Delta or Iceberg Key-value store: Redis, DynamoDB, Cassandra, RonDB

The online side has its own explainer: what is an online feature store. This page is about how the two halves relate.

Why does offline training data need point-in-time correctness?

A training row pairs an outcome with the features as they stood just before it. If the features are read as they stand today, they can include what happened after the outcome, and the model learns from information it will never have in production. This is label leakage.

An example. A checkout model predicts, when a visitor opens the basket, whether they will buy. One input is pages viewed this session. Computed over the finished session, a buyer’s count includes the payment and order confirmation pages, so in training, long sessions look like purchases. In production the model reads the count at the moment the basket opens, before any of those pages exist. It scored well offline and scores worse live, for a reason nobody can see in the model.

A point-in-time correct training set fixes this by joining each label to the value every feature had at that label’s timestamp. Feast calls this a point-in-time join: it reproduces the state of features at a past moment by looking back from each row’s timestamp. The online store never needs this, because the only moment it serves is now.

Why do online and offline features drift apart?

The two stores are usually filled by different code on different schedules. A data scientist writes the feature in SQL against the warehouse, an engineer rewrites it for the serving path, and the two disagree on details nobody wrote down: nulls, time zones, late events, which key a row belongs to. When the value a model reads in production differs from the one it trained on, that is training-serving skew.

Timing adds a second gap. The offline value is computed after the fact from complete history. The online value is whatever the pipeline had written when the request arrived, which may lag behind what the customer just did. That lag is feature freshness, and an online store is only as current as the pipeline feeding it.

How do teams keep the online and offline store in step?

There are four common patterns. They differ in where the feature logic lives and how many copies of it exist.

  1. Dual write. The application or a pipeline writes each value to both stores. It is simple to start, but there are now two writes that can fail separately, and the offline history only holds what was written, so a new feature has no past.
  2. Materialization from offline to online. Features are computed in the warehouse, then the latest value per key is copied to the online store on a schedule. Feast’s materialize command and Databricks’ publish_table work this way. There is one definition, but the online value is as old as the last copy.
  3. Streaming into both. A streaming job computes the feature from events and writes the current value online, while the same events land in the warehouse for history. The online value is fresh. The risk is that the streaming job and the warehouse query are still two implementations, and they disagree on late and out-of-order events.
  4. One definition, computed for both. The feature is declared once, and the platform runs it in a streaming engine for the online value and a batch engine for history and training sets. This removes the second implementation, which is the most common cause of skew. It still depends on the platform handling time correctly on both sides.

Where do streaming and on-demand features fit?

A streaming feature is updated as events arrive, such as searches this session or items in the basket. It belongs in the online store, but a model still needs its history to train on, so it has to be reproducible offline at past moments too. That is the hardest case for patterns 1 to 3.

An on-demand feature is computed at request time from data that only exists in the request, such as the distance between a delivery address and a store. Tecton’s realtime feature views are an example: they are not precomputed or stored, and for training they are computed again per row using that row’s timestamp. Neither store holds them, but the same function has to run in both paths.

Example: one attribute in the training table and the online lookup

Signals calls each feature an attribute: a value computed from events about one key, such as a session. Here a checkout model uses the number of searches in the visit, defined once with the Signals Python SDK:

from snowplow_signals import Attribute, Event, StreamAttributeGroup, domain_sessionid

search = Event(name="search", vendor="com.example", version="1-0-0")

searches_session = Attribute(
    name="searches_session",
    type="int32",
    events=[search],
    aggregation="counter",
    default_value=0,
)

session_features = StreamAttributeGroup(
    name="session_features",
    version=1,
    attribute_key=domain_sessionid,
    owner="you@example.com",
    attributes=[searches_session],
)

Offline. The dataset builder reads that group and the outcome you name, here a transaction event. It writes one row per labeled moment to a table in the warehouse, with searches_session computed from only the events before that moment, so nothing that happened afterwards reaches the row.

from snowplow_signals import AtomicProperty, Criteria, Criterion, TrainingSpan

run = sp_signals.submit_dataset_run_with_session_anchors(
    attribute_groups=[session_features],
    goal_criteria=Criteria(all=[Criterion.eq(AtomicProperty(name="event"), "transaction")]),
    training_span=TrainingSpan(start_time=start, end_time=end),
)

Online. The same definition runs in the streaming engine, which updates searches_session for every open session as each search arrives. At inference, the model reads it from a service that holds the group:

features = sp_signals.get_service_attributes(
    name="checkout_features",
    attribute_key="domain_sessionid",
    identifier=session_id,
)
score = model.predict(features)

There is no second implementation to keep in step, so the count the model trained on and the count it reads come from the same logic. This is pattern 4 above, and Signals is one option built that way for behavioral features. The limits are stated on its pages: the dataset builder supports Snowflake today, and if your features come from sources other than events, a general feature store may suit you better. The feature stores topic covers the rest of the picture.

See it on your own traffic

Add the SDK, define one attribute, and see an attribute updating against your own traffic in the first session. The free tier runs on the real engine: no card, no sales call.