当你打开汇丰 App、发起一次支付、甚至只是在后台刷新余额页面——
汇丰智能画像系统(HSBC Profile AI)都在背后实时分析你是谁、是不是你、有没有可能“被操控”。
本篇围绕:
用户画像建模 + 多模态行为融合 + AI 风控推理系统
展开技术解剖,并结合实战代码示例,展示 AI 如何在数百毫秒内判断出“你就是你”。
一、汇丰画像系统架构总览图
二、原始数据来源(全链路行为)
| 来源 | 采集字段示例 |
|---|---|
| App 使用 | 启动时长、点击频率、操作路径、滑动速度 |
| 登录行为 | 登录频率、设备指纹、IP地域、输入节奏 |
| 交易操作 | 金额区间、收款人多样性、输入时间差 |
| 设备传感器 | 重力感应器/光感传感器/移动轨迹(隐式特征) |
三、行为编码器实现(JS/Python 双版本)
🧠 编码器目标:
将原始行为 → 向量编码(行为指纹)
示例行为结构:
{
"click_path": ["home", "account", "transfer", "confirm"],
"screen_duration": [5.1, 2.3, 6.4, 1.2],
"device_id": "iphone14_001",
"location": "HK",
"hour": 9
}
📦 Python版编码器(可部署在服务端):
import numpy as np
def encode_behavior(data):
click_hash = sum([hash(x) for x in data["click_path"]]) % 997
duration_avg = np.mean(data["screen_duration"])
hour_encoded = np.sin(data["hour"] * np.pi / 24)
# 简化后的 3维行为向量
return np.array([click_hash / 1000, duration_avg / 10, hour_encoded])
🧪 输出示例:
[0.672, 0.535, 0.965]
四、画像存储与向量匹配(向量库 + 相似度判定)
💽 使用 Milvus/HNSWLib 向量库:
from hnswlib import Index
index = Index(space='cosine', dim=3)
index.init_index(max_elements=10000, ef_construction=100)
index.add_items([[0.672, 0.535, 0.965]], ids=[8891001])
📏 实时匹配当前用户向量:
current = encode_behavior(current_data)
labels, distances = index.knn_query(current, k=1)
if distances[0][0] > 0.2:
raise Exception("画像偏离过大,触发风控验证")
五、深度融合多模态数据(JS 实现端侧特征组合)
JS 端用户设备侧特征采集示例:
function collectLocalSignals() {
return {
screenSize: window.screen.width + 'x' + window.screen.height,
tzOffset: new Date().getTimezoneOffset(),
motion: window.DeviceMotionEvent ? true : false,
touchSupport: 'ontouchstart' in window
}
}
✅ 此类数据用于行为指纹混合建模。
六、AI 模型推理流程(TensorFlow.js / Python 版本)
📦 TensorFlow.js 简版模型调用:
const model = await tf.loadLayersModel('/models/profile-model.json')
const inputTensor = tf.tensor2d([[0.672, 0.535, 0.965]])
const prediction = model.predict(inputTensor)
返回置信度:
prediction.array().then(res => {
if (res[0][0] < 0.9) alert("检测到异常行为,请验证身份")
})
七、画像偏差判定策略(高风险识别)
| 偏差点 | 判定逻辑 |
|---|---|
| 操作路径完全不同 | 路径编辑距离过大 |
| 输入时长变化过大 | 视为“非熟练操作” |
| IP 跳变 + Device 变化 | 疑似接管 |
| 多次失败再交易 | 高概率撞库 / 爬虫 |
系统可返回风险等级:
{
"risk_score": 87,
"risk_reason": "路径偏离 + 登录频次突增",
"recommend_action": "二次认证 + 限额"
}
八、汇丰画像系统能力一览
| 模块 | 技术说明 |
|---|---|
| 行为向量建模 | 基于路径、滑动、点击节奏等数值映射 |
| 模型推理服务 | TensorFlow.js + Python 模型部署 |
| 向量库匹配 | HNSWLib / Milvus 高性能索引 |
| 多模态数据融合 | 端侧传感器、IP、时区等行为补强 |
| 风控集成 | 分值打标 + 审计日志记录 |
🎯 彩蛋:
“不是你告诉我你是谁,而是你的‘习惯’会泄露你是谁。”