---
title: Model Serving with automatic feature lookup
description: Databricks Model Serving automatically looks up feature values from a Databricks Online Feature Store or a third-party online store when scoring a model.
canonical_url: https://docs.databricks.com/aws/en/machine-learning/feature-store/automatic-feature-lookup
---

# Model Serving with automatic feature lookup

[Model Serving](https://docs.databricks.com/aws/en/machine-learning/model-serving/index.md) can automatically look up feature values from a [Databricks Online Feature Store](https://docs.databricks.com/aws/en/machine-learning/feature-store/online-feature-store.md) or a [third-party online store](https://docs.databricks.com/aws/en/machine-learning/feature-store/third-party-online-stores.md). For real-time serving of feature values, Databricks recommends using [Databricks Online Feature Stores](https://docs.databricks.com/aws/en/machine-learning/feature-store/online-feature-store.md).

## Requirements

* The model must have been logged with `FeatureEngineeringClient.log_model` (for Feature Engineering in Unity Catalog) or `FeatureStoreClient.log_model` (for legacy Workspace Feature Store), requires v0.3.5 and above).

- For third-party online stores, the online store must be [published with read-only credentials](https://docs.databricks.com/aws/en/machine-learning/feature-store/fs-authentication.md#provide-online-store-credentials-using-databricks-secrets).

> [!NOTE]
>
> You can publish the feature table at any time prior to model deployment, including after model training.

## <a id="automatic-feature-lookup" />Automatic feature lookup

Databricks [Model Serving](https://docs.databricks.com/aws/en/machine-learning/model-serving/index.md) supports automatic feature lookup from these online stores:

* [Databricks Online Feature Store](https://docs.databricks.com/aws/en/machine-learning/feature-store/online-feature-store.md)
* Amazon DynamoDB (v0.3.8 and above)

Automatic feature lookup is supported for the following data types:

* `IntegerType`
* `FloatType`
* `BooleanType`
* `StringType`
* `DoubleType`
* `LongType`
* `TimestampType`
* `DateType`
* `ShortType`
* `ArrayType`
* `MapType`

## Override feature values in online model scoring

All features required by the model (logged with `FeatureEngineeringClient.log_model` or `FeatureStoreClient.log_model`) are automatically looked up from online stores for model scoring. To override feature values when scoring a model using a REST API with [Model Serving](https://docs.databricks.com/aws/en/machine-learning/model-serving/create-manage-serving-endpoints.md#score) include the feature values as a part of the API payload.

> [!NOTE]
>
> The new feature values must conform to the feature's data type as expected by the underlying model.

## <a id="log" /> Save the augmented DataFrame in the inference table

You can configure a model serving endpoint to log the augmented DataFrame that contains the looked-up feature values and function return values. The DataFrame is saved in the MLflow trace in the inference table for the served model.

For instructions on setting this configuration, see [ Log feature lookup DataFrames to inference tables](https://docs.databricks.com/aws/en/machine-learning/model-serving/store-env-variable-model-serving.md#features).

For information about inference tables, see [Log requests and responses for serving endpoints (legacy)](https://docs.databricks.com/aws/en/ai-gateway/inference-tables-serving-endpoints.md).

## <a id="example" />Notebook examples

With Databricks Runtime 13.3 LTS and above, any Delta table in Unity Catalog with a primary key can be used as a feature table. When you use a table registered in Unity Catalog as a feature table, all Unity Catalog capabilities are automatically available to the feature table.

### Databricks Online Feature Store

The following notebook illustrates how to publish features to a Databricks Online Feature Store for real-time serving and automated feature lookup.

#### Databricks online store demo notebook

[Get notebook](https://docs.databricks.com/notebooks/source/machine-learning/online-feature-store.html)

### Third-party online stores

This example notebook illustrates how to publish features to a third-party online store and then serve a trained model that automatically looks up features from the online store.

#### Third-party online store example notebook (Unity Catalog)

[Get notebook](https://docs.databricks.com/notebooks/source/machine-learning/feature-store-with-uc-online-example-dynamodb.html)

### Workspace Feature Store (legacy)

This example notebook illustrates how to publish features to an online store and then serve a trained model that automatically looks up features from the online store.

#### Third-party online store example notebook (Workspace Feature Store)

[Get notebook](https://docs.databricks.com/notebooks/source/machine-learning/feature-store-online-example-dynamodb.html)
