🚀 一、业务背景与挑战
Google Ads 是全球最大的广告平台之一,服务于:
- 搜索广告(Search Ads)
- 展示广告(GDN)
- YouTube 视频广告
- App 内广告(AdMob)
其核心挑战是:
维度 | 要求 |
---|---|
毫秒响应 | 用户搜索结果页需 < 100ms 返回广告 |
广告精准性 | 保证高 CTR、CVR 和用户相关性 |
商业变现 | 优先展示出价高但质量也高的广告 |
风控与合规 | 过滤低质量广告,避免违法内容展示 |
🏗 二、核心架构总览图

🧠 三、排序系统核心组成
1️⃣ Bid:出价(CPC/CPM)
广告主设置:
- CPC(点击付费)
- CPM(千次展示付费)
- CPA(转化付费) → 后续智能出价模块转换为等价出价
2️⃣ Quality Score:广告质量得分
QS 由多个因子决定:
python
def compute_qs(ctr, lp_exp, ad_relevance):
return 0.5 * ctr + 0.3 * lp_exp + 0.2 * ad_relevance
- CTR(历史点击率)
- LP Exp(落地页体验)
- Ad Relevance(广告与关键词匹配度)
系统采用 TensorFlow 模型训练,结合特征交叉:
makefile
# 示例:交叉特征生成
keywords = tf.feature_column.categorical_column_with_vocabulary_list(
"keyword", ["shoes", "running", "cheap"]
)
device = tf.feature_column.categorical_column_with_vocabulary_list(
"device", ["mobile", "desktop"]
)
crossed = tf.feature_column.crossed_column([keywords, device], hash_bucket_size=1000)
训练完成后,部署在 Vertex AI + TensorRT 上,支持批量推理加速。
🧮 四、实时竞价系统(RTB 引擎)
Google Ads 使用变体的 [Vickrey-Clarke-Groves 拍卖机制 (VCG)]:
- 出价不等于最终支付价格
- 实时系统根据其他竞价者行为动态计算付款金额
示例:两位广告主竞价
广告主 | 出价(Bid) | 质量分(QS) | 综合得分 Bid × QS |
---|---|---|---|
A | $2.0 | 0.8 | 1.6 |
B | $1.5 | 0.9 | 1.35 |
最终展示顺序:A > B
A 实际支付金额为:B 的得分 ÷ A 的 QS = 1.35 / 0.8 = $1.6875
🧩 五、模型系统实战代码(TFX + Flink + Serving)
🎯 CTR 模型训练(TensorFlow)
ini
# 特征组合
features = tf.concat([user_emb, ad_emb, context_features], axis=1)
# MLP 网络
x = tf.keras.layers.Dense(256, activation='relu')(features)
x = tf.keras.layers.Dense(128, activation='relu')(x)
logits = tf.keras.layers.Dense(1)(x)
训练后输出 SavedModel,自动部署到线上推理系统:
arduino
gcloud ai models upload --region=us-central1 --display-name="ctr_model_v2" --artifact-uri=gs://my-bucket/ctr_model
⚡ 实时特征计算(Flink)
ini
val clickEvents = env.fromSource(clickStream)
val featureStream = clickEvents
.keyBy(_.userId)
.window(TumblingEventTimeWindows.of(Time.minutes(5)))
.aggregate(new CTRFeatureAggregator())
⚙️ 模型线上调用(Python)
ini
import google.cloud.aiplatform.prediction as aip
result = aip.PredictRequest(
endpoint="projects/xxx/endpoints/ctr-v2",
instances=[{"user_id": 123, "ad_id": 456, "device": "mobile"}],
)
📊 六、实战效果数据(AB 实验)
指标 | 旧系统 | 新系统(模型 + VCG + QS) | 提升 |
---|---|---|---|
平均点击率 CTR | 1.4% | 2.1% | ↑50% |
每千次展示收益 eCPM | $2.9 | $4.2 | ↑44% |
用户投诉广告无关率 | 0.72% | 0.41% | ↓43% |
🔐 七、风控体系:广告审核 + 欺诈检测
Google 使用多层机制审核广告内容:
- BERT + ViT 检测低俗/虚假内容
- Flink 检测异常点击/刷广告行为
- 落地页实时解析检测跳转劫持行为
python
def detect_fake_ad(ad_text):
score = nlp_model.predict(ad_text)
if score['fake'] > 0.9:
return True
return False
🧠 八、未来展望
- 引入 RL 训练的 Bid Adjustment(策略价值最大化)
- 广告多目标排序(收益 + 品牌好感 + 内容相关性)
- 高可用微服务系统拆解与 AI 编排调度平台落地(KubeFlow + AutoML)
✅ 总结(Google Ads 智能竞价团队技术负责人)
"广告排序系统并不是最贵者得,而是最相关、最有价值的人赢。"
我们的任务,就是让机器能在 100 毫秒内判断这场拍卖谁该赢,而且结果不能错。