20260514:增加新内容

This commit is contained in:
2026-05-14 13:54:52 +08:00
parent 56c4d3ef7c
commit b116710e4c
294 changed files with 10682 additions and 255 deletions

View File

@@ -0,0 +1,38 @@
---
title: "Greedy Context Screening贪心上下文筛选"
created: 2026-05-11
updated: 2026-05-11
type: concept
tags: [algorithm, context-design, screening]
sources: [[ramsey-context-construction]]
---
# Greedy Context Screening贪心上下文筛选
## 定义
贪心上下文筛选是基于 [[ramsey-context-graph|拉姆齐上下文图]] 的快速上下文组装算法。利用蓝色边的**稠密性保证**(由拉姆齐维护策略提供),用 O(可接受) 的贪心搜索替代 NP-hard 的最大团搜索。
## 三步流程
### 1. 相关性投射
对用户 prompt 解析后,每个节点计算相关度分数 s_i ∈ [0,1](向量检索 + 规则打分)。
### 2. 高相关子图
仅保留相关度高于阈值的节点,形成**诱导子图**。由于原始图蓝色边稠密,子图中大概率仍含蓝色团。
### 3. 贪心团扩展
- **种子**:相关度最高的节点
- **扩展**:依次加入与当前团全蓝边的节点,按"边际收益/成本"排序
- **终止**:达到目标 t 值或 token 预算耗尽
- **反遗忘约束**:低频长节点受惩罚
## 性能
蓝色边稠密条件下,贪心解与最优解的差距通常在 **5% 以内**,耗时毫秒级。
## 相关概念
- [[context-blue-clique|上下文蓝色团]]
- [[ramsey-context-graph|拉姆齐上下文图]]
- [[ramsey-context-template|拉姆齐上下文模板]]