返回 Papers
AI 底层逻辑 / 经典论文

Feature Stores / Real-Time ML:Feast、Michelangelo 与实时决策

一句话:

314ai-foundations/papers/37-feature-stores-real-time-ml-feast-michelangelo.md

Feature Stores / Real-Time ML 解读

面向对象: AI Architect / Platform PM / Data Product Manager / Risk Product / ML Platform Owner。 核心问题: 为什么实时 AI 决策不能只靠模型服务?Feature Store 如何解决训练-服务一致性、时间正确性、实时新鲜度、复用、监控和治理? 学习目标: 理解 Feast、Uber Michelangelo、offline/online store、point-in-time correctness、training-serving skew、streaming features,并映射到支付欺诈、信贷预审批、KYC、推荐和 Agent 风险决策。


Source Anchors

SourceLink用途
Feast docshttps://docs.feast.dev/理解开源 feature store 的 entity、feature view、offline/online serving
Feast GitHubhttps://github.com/feast-dev/feast理解工程边界、注册表、provider 和 serving 模式
Uber Michelangelohttps://www.uber.com/blog/michelangelo-machine-learning-platform/理解大规模 ML 平台、特征、训练、部署和监控
Metaflow docshttps://docs.metaflow.org/理解 ML/data workflow、版本化、实验和生产流水线
NIST AI RMFhttps://www.nist.gov/itl/ai-risk-management-framework把实时 ML 纳入治理、测量、监控和风险管理

一句话:

Feature Store 是把“模型需要的业务事实”产品化、版本化、可复用、可回放、可监控的 AI 数据基础设施。


1. 为什么 Feature Store 是架构问题

实时 ML 决策常见失败不在模型,而在特征:

  • 训练用的字段和线上服务字段不一致。
  • 标签发生在未来,训练时泄露。
  • 实时特征延迟过高或缺失。
  • 相同特征被多个团队重复计算,口径不同。
  • 新模型上线后因为特征漂移导致性能下降。
  • 审计时无法解释某次决策用的是什么特征值。
  • 批处理特征和流式特征时效不同,模型行为不可预测。

Feature Store 的价值:

能力解决的问题
Feature registry知道有哪些特征、owner、定义、版本
Offline store训练、回放、历史特征
Online store低延迟 serving
Point-in-time join防止未来信息泄露
Materialization把离线/流式特征推到 online store
Feature view管理 entity、schema、freshness、source
Reuse避免团队重复造相同特征
Monitoring新鲜度、缺失率、漂移、质量

2. Offline / Online 一致性

Feature Store 的核心承诺:

training features ~= serving features

2.1 Offline Store

用于:

  • 历史训练集生成。
  • backtesting。
  • point-in-time join。
  • 模型验证。
  • 审计回放。

数据形态:

  • Data warehouse。
  • Lakehouse。
  • Batch tables。
  • Historical event logs。

2.2 Online Store

用于:

  • 毫秒级或低秒级特征读取。
  • 实时欺诈、推荐、定价、风控、Agent gating。
  • serving-time feature lookup。

常见实现:

  • Redis / DynamoDB / Cassandra / Bigtable / key-value store。
  • Streaming materialization。
  • Feature service API。

2.3 一致性难题

问题例子控制
Training-serving skew训练用 SQL 逻辑和线上 Java/Python 逻辑不同统一 feature definition、feature view
Data leakage训练时用了决策后才知道的字段point-in-time join、label cutoff
Freshness drift实时特征 10 分钟未更新freshness SLO、alert
Null mismatch训练填 0,线上返回 nulldefault policy、schema contract
Entity mismatchcustomer_id/account_id/device_id 映射不一致entity registry、identity resolution
Version mismatch模型 v2 读取旧特征口径model-feature dependency registry

3. Point-in-Time Correctness

实时决策系统必须回答:

在当时那个时间点,系统实际能知道什么?

错误示例:

2026-06-01 做信贷预审批
训练样本却使用了 2026-06-05 才出现的逾期结果

这会造成 label leakage,让离线指标虚高,线上失败。

正确思路:

entity_id + event_timestamp
  -> join only feature values available before event_timestamp
  -> enforce feature timestamp and created timestamp rules

高级产品/架构问题:

  • 是否区分 event time、processing time、available time。
  • 特征是否有 late-arriving data。
  • 回放训练集是否能重现当时线上可见状态。
  • 审计是否能取回当时特征值、模型版本、策略版本和输出。

4. Streaming Features 与 Freshness SLO

实时特征例子:

场景实时特征
支付欺诈过去 5 分钟同设备交易次数、同卡失败次数、商户 velocity
信贷预审批最近工资入账、余额变化、外部 bureau 更新状态
KYC文档上传次数、OCR 失败次数、设备/IP 异常
推荐当前 session 点击、搜索、购物车
Agent 工具风险用户刚刚请求的 action、工具失败次数、policy violation count

Freshness SLO 示例:

Feature tierFreshnessMissing tolerance使用场景
Critical real-time< 5snear 0支付拦截、account takeover
Operational real-time< 60svery lowKYC routing、客服 Agent gating
Near real-time< 15mlow推荐、next-best-action
Batchdaily/weeklymedium长期客户画像、策略分析

设计问题:

  • 特征过期时是拒绝、降级、改用 batch 特征还是人工复核。
  • streaming pipeline 出现 lag 时如何保护客户和业务。
  • online store 返回 stale value 是否被模型感知。
  • freshness alert 是否和 model serving、risk workflow 联动。

5. Feature Contract

Feature Contract 是数据产品和模型产品之间的契约。

字段说明
Feature name稳定命名,不跟随临时项目
Entitycustomer、account、device、merchant、case
Definition业务口径和计算逻辑
Source系统、表、topic、owner
Timestamp semanticsevent time、processing time、available time
Freshness SLO最大可接受延迟
Null/default policy缺失如何处理
Allowed use训练、serving、monitoring、analysis
Prohibited use不得用于某些自动决策或客户细分
Privacy classPII、sensitive、consent required
Quality checksrange、distribution、missing、drift
Consumers模型、规则、dashboard、Agent
Approval ownerdata owner、risk owner、privacy owner

高级判断:

  • Feature 不是字段,是带 owner、语义、时效、权限和质量承诺的数据产品。
  • Feature Contract 应进入模型发布门禁。
  • 高风险特征需要 purpose limitation 和解释边界。

6. 实时决策架构

Event / Request
  -> identity and entity resolution
  -> online feature lookup
  -> real-time feature computation
  -> model score
  -> rules / policy engine
  -> decision service
  -> action / recommendation / escalation
  -> trace log
  -> feedback / label capture
  -> offline training and replay

6.1 决策服务不是模型服务

模型服务输出 score,决策服务输出 action:

输出责任
Feature servicefeature vector数据时效、口径、权限
Model servicescore / probability / embedding预测质量
Rule/policy serviceallow/deny/escalate constraints合规和业务规则
Decision serviceapprove/reject/review/recommend业务决策编排
Workflow servicecase/action/task人机流程

6.2 金融零售案例

支付欺诈:

transaction event
  -> card/account/device/merchant velocity features
  -> fraud model
  -> policy rules
  -> approve / step-up / decline / manual review
  -> customer notification and dispute path

信贷预审批:

customer context
  -> eligibility features
  -> bureau / income / relationship features
  -> model score
  -> policy boundary
  -> marketing eligibility or manual review

Agent 工具授权:

agent wants to call tool
  -> user role + customer context + action risk + recent behavior features
  -> policy model/rules
  -> allow / require approval / block
  -> audit trace

7. Monitoring 与 Release Gate

Feature monitoring:

指标含义
freshness lag特征延迟
missing rate缺失率
distribution drift分布漂移
schema driftschema/类型变化
online/offline parity训练和服务口径差异
entity coverageentity 是否匹配
fallback rate降级或默认值比例
decision impact特征异常影响了多少决策

发布门禁:

  1. 所有 critical features 有 contract。
  2. point-in-time dataset 通过 leakage check。
  3. online/offline parity 通过抽样验证。
  4. freshness SLO 有监控和 alert。
  5. 特征缺失和默认值策略通过风险评审。
  6. 模型版本绑定 feature view 版本。
  7. 可回放某次决策的完整 feature vector。
  8. 高风险动作有 policy engine 和人工升级路径。

8. 面试表达

30 秒版本

Feature Store 解决的是实时 ML 的生产一致性问题。它把特征定义、历史训练、线上 serving、point-in-time correctness、新鲜度、复用和监控统一起来,避免训练-服务偏差和数据泄露。在支付欺诈、信贷、KYC、推荐和 Agent 工具授权里,特征平台往往比模型本身更决定系统是否可靠。

2 分钟版本

我会把实时 AI 决策拆成 feature service、model service、policy service、decision service 和 workflow service。Feature Store 负责 offline/online 一致性,offline store 生成历史训练集和回放,online store 支撑低延迟 serving。关键控制是 point-in-time correctness,确保训练样本只使用当时可见的信息,避免 leakage。实时场景还要定义 freshness SLO,例如支付欺诈 velocity 特征可能要求 5 秒内更新,而客户画像可以日更。上线时我会要求 feature contract、schema/quality/freshness monitoring、online-offline parity、模型-特征版本绑定和决策回放能力。

架构师版本

Feature Store 是企业 AI 平台的数据控制面。它不是缓存表,而是特征定义、entity 语义、时间语义、权限、质量、SLO、版本和 lineage 的组合系统。没有它,实时决策会陷入重复计算、口径不一致、无法审计和模型漂移不可控。


9. 作品集任务

选择一个实时决策场景,产出:

  1. 实时决策架构图。
  2. 10 个 feature contracts。
  3. freshness SLO matrix。
  4. point-in-time training dataset 设计。
  5. online/offline parity 测试方案。
  6. feature monitoring dashboard 草图。
  7. release gate checklist。
  8. 一页 incident 回放: 某个 stale feature 导致错误决策时如何定位和回滚。