Retrieving features
Let’s explore how to retrieve tokenized data, including tokens
, token_ids
, and attention_mask
, from Feast for use with an LLM. The process differs slightly depending on whether we’re accessing features for real-time predictions (online) or training machine learning models (offline). Here’s how we’ll approach both scenarios:
from datetime import datetime from feast import FeatureStore import pandas as pd fs = FeatureStore(repo_path="/path/to/your/feast_project") feature_refs = [ "token_features_view:tokens", "token_features_view:token_ids", "token_features_view:attention_mask", ] entity_keys = [{"input_id": "1"}, {"input_id": "2"}] online_features = fs.get_online_features( entity_rows=entity_keys, feature_refs=feature_refs, ).to_dict()...