Files
myWiki/concepts/global-context-hash-tree.md
2026-06-01 10:46:01 +08:00

1.5 KiB
Raw Blame History

title, created, updated, type, tags, sources
title created updated type tags sources
Global Context Hash Tree (全局上下文哈希树) 2026-05-29 2026-05-29 concept
distributed-systems
hashing
caching
LLM
https://mp.weixin.qq.com/s/MUWV7eug14bktUMlqsxfQw

Global Context Hash Tree (全局上下文哈希树)

Global Context Hash Treedistributed-prompt-caching 中的核心标识机制:将 Prompt 按层级结构Global → Project → Session → Message组织成树每层独立计算 SHA-256组合成 128 字节的复合键作为会话的分布式唯一标识符UID

结构

[Global Layer SHA] → [Project Layer SHA] → [Session Layer SHA] → [Current Turn SHA]

四层哈希组合成 128 字节的二进制复合键Composite Key

设计优势

  • 确定性:相同的上下文产生相同的哈希,可重复定位
  • 分层性:符合 LLM Prompt 的自然组织方式
  • 紧凑性128 字节即可标识任意大小的上下文
  • 跨服务商兼容:不依赖特定 LLM 提供商的缓存句柄格式

在路由中的作用

复合键作为 distributed-cache-routing 的主键,使任何节点都能通过本地哈希计算瞬间查询某前缀在各物理节点和服务商端的"热态"分布。

相关