用户兴趣图谱构建方案
电商推荐系统实施步骤:
- Data preparation:将用户行为日志转化为
[用户, 行为类型, 商品, 时间戳]
四元组 - 图谱初始化::
graph.add_node(''User'', id=''U123'')
创建用户节点 - dynamic update (Internet): By
graph.merge_edge()
方法实时更新用户-商品交互权重 - semantic enhancement: for
浏览/收藏/购买
等不同行为类型设置差异化边缘属性
查询示例:MATCH (u:User)-[r:购买|浏览]->(p:Product) WHERE r.timestamp > date()-duration(''P7D'') RETURN p
可获取近期兴趣商品。
This answer comes from the articleGraphiti: dynamic knowledge graph construction and query tool (time-aware long memory scheme)The