关于 very-long-text-summarization
用于处理超出单个上下文窗口的长文档,适合需要结构化理解而非简短摘要的读者和研究者。它通过分块、多轮提取生成摘要、知识图谱或技能草稿。
主要功能
- 01语义或定长分块并保留重叠
- 02并行执行首轮提取
- 03综合生成结构化知识图谱
- 04可选的技能草稿精炼
- 05摘要、知识图谱和技能草稿模式
适用场景
- 01从长篇手册中提取专业知识
- 02综合多篇研究论文的发现
- 03梳理大型代码库的架构
- 04将手册转化为技能草稿
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ curiositech/ some_claude_skills --skill very-long-text-summarization安装后在 Claude Code 中输入/very-long-text-summarization确认已加载。
附带文件.claude-plugin/plugin.jsonCHANGELOG.md
详细介绍
超长文本摘要
使用大量低成本模型进行分层、多轮提取,处理无法放入单个上下文窗口的文本。生成结构化知识图谱、带索引的摘要和技能草稿,而不只是压缩文本。
适用场景
✅ 适用于:
- 专业手册和教科书(100–1000 页以上)
- 职业传记和回忆录(提取专业知识模式)
- 大型代码库(理解架构层面内容)
- 研究论文合集(综合多篇论文的研究发现)
- 任何超出单个上下文窗口(约 100K 个 token)的文本
❌ 不适用于:
- 短文档(少于 10 页)——直接阅读即可
- 实时对话摘要(使用自动压缩模式)
- 生成代码文档(使用
technical-writer) - 简单的 TL;DR 请求(多轮处理的开销不值得)
架构:三轮分层提取
flowchart TD
D[Document] --> C[Chunk into segments]
C --> P1["Pass 1: Haiku army\n(parallel extraction)"]
P1 --> I[Intermediate summaries]
I --> P2["Pass 2: Sonnet synthesis\n(merge + structure)"]
P2 --> S[Structured knowledge map]
S --> P3["Pass 3: Opus refinement\n(optional, for skill drafts)"]
P3 --> O[Final output]
第 1 轮:分块提取(Haiku 集群)
将文档拆分为有重叠的文本块(每块约 4K 个 token,重叠 500 个 token)。并行地为每个文本块调用一次 Haiku。每次调用都会提取:
extraction_template:
summary: "2-3 sentence summary of this section"
key_claims: ["list of factual claims or assertions"]
processes: ["any step-by-step procedures described"]
decisions: ["any decision points or heuristics mentioned"]
failures: ["any failures, mistakes, or anti-patterns described"]
aha_moments: ["any insights, realizations, or conceptual breakthroughs"]
metaphors: ["any metaphors or mental models used"]
temporal: ["any 'things changed when...' or 'before X, after Y' patterns"]
quotes: ["notable direct quotes worth preserving"]
references: ["any citations, links, or cross-references"]
成本:每个文本块约 $0.001。一本 300 页的书(约 150K 个 token)= 约 38 个文本块 = 第 1 轮总成本约 $0.04。
并行处理:所有文本块同时运行。一本 300 页的书约 3 秒即可完成第 1 轮(实际耗时),而不是 3 分钟。
第 2 轮:综合整理(Sonnet)
将第 1 轮的所有提取结果输入一个或多个 Sonnet 调用。Sonnet 会合并、去重并整理知识结构。
synthesis_template:
document_summary: "1-2 paragraph executive summary"
knowledge_map:
core_concepts:
- concept: "name"
definition: "what it means in this domain"
relationships: ["connects to concept X because..."]
processes:
- name: "process name"
steps: ["ordered steps"]
decision_points: ["where choices are made"]
common_mistakes: ["what goes wrong"]
expertise_patterns:
- pattern: "what experts do differently"
novice_mistake: "what novices do instead"
aha_moment: "the insight that bridges the gap"
temporal_evolution:
- period: "date range"
paradigm: "what was believed/practiced"
change_trigger: "what caused the shift"
key_metaphors:
- metaphor: "how practitioners think about X"
maps_to: "the underlying structure it represents"
index:
- topic: "topic name"
chunk_ids: [3, 7, 12] # Which original chunks cover this
summary: "1 sentence"
成本:约 $0.02–0.05,具体取决于提取内容的数量。索引可追溯到书中的具体章节。
第 3 轮:精炼(Opus,可选)
对于技能草稿输出模式,Opus 会根据知识图谱,按照 skill-architect 模板生成 SKILL.md。这就是“从手册提炼技能”的工作流。
成本:约 $0.10。仅在输出为技能草稿时运行。
分块策略
语义分块(首选)
按照文档结构拆分,例如章节边界、节标题和段落分隔。这样可以保留每个文本块内部的语义连贯性。
def semantic_chunk(text: str, max_tokens: int = 4000, overlap: int = 500) -> list[str]:
"""Split text on structural boundaries with overlap."""
# Split on headings, then merge short sections
sections = split_on_headings(text) # ##, ###, etc.
chunks = []
current = ""
for section in sections:
if count_tokens(current + section) > max_tokens:
chunks.append(current)
# Overlap: keep the last ~500 tokens
current = get_last_n_tokens(current, overlap) + section
else:
current += section
if current:
chunks.append(current)
return chunks
固定大小分块(备用)
适用于没有标题的非结构化文本。按段落边界拆分,目标为每块约 4K 个 token,并重叠 500 个 token。
为什么要重叠?
跨越文本块边界的概念需要同时出现在两个文本块中,才能被提取。没有重叠就会丢失跨边界的知识。
输出模式
模式 1:摘要
生成结构化摘要,包含执行概述、关键概念和索引。
适用于:快速了解长文档;在会议前阅读手册。
模式 2:知识图谱
生成完整的知识图谱:概念、流程、专业知识模式、时间演变和隐喻。采用机器可读格式(YAML/JSON),便于后续处理。
适用于:用于创建技能、开发领域元技能,或进行跨文档分析。
模式 3:技能草稿
按照 skill-architect 模板生成 SKILL.md,将手册中的专业知识编码为决策树、反模式和识别标志。
适用于:将专业手册转化为 Claude 技能。KE 工作流。
成本模型
| 文档规模 | 页数 | 文本块数 | 第 1 轮(Haiku) | 第 2 轮(Sonnet) | 第 3 轮(Opus) | 总计 |
|---|---|---|---|---|---|---|
| 文章 | 10 | 4 | $0.004 | $0.01 | — | $0.014 |
| 章节 | 30 | 10 | $0.01 | $0.02 | — | $0.03 |
| 手册 | 300 | 38 | $0.04 | $0.05 | $0.10 | $0.19 |
| 教科书 | 800 | 100 | $0.10 | $0.10 | $0.10 | $0.30 |
| 百科全书 | 2000+ | 250+ | $0.25 | $0.20 | $0.10 | $0.55 |
处理时间主要取决于耗时最长的单次 Haiku 调用(约 2–3 秒)。完全并行处理时,即使是 2000 页的文本,第 1 轮也能在 5 秒内完成。
反模式
单次摘要
错误做法:将整份文档输入一次 Opus 调用。 原因:超出上下文窗口,或者注意力被稀释,导致对如此长的输入提取效果不佳。 正确做法:采用分层多轮处理。先并行进行低成本提取,再进行高成本综合。
摘要缺乏结构
错误做法:为一本 300 页的手册撰写两段式的散文摘要。 原因:结构本身就是知识。扁平化的摘要会丢失决策树、失败模式和时间演变,而这些正是技能的价值所在。 正确做法:构建结构化知识图谱,并提供索引,以便回溯到源文档的相关章节。
忽略重叠部分
错误做法:按硬边界分块,不设置重叠。 原因:跨越边界的概念会被拆开并丢失。 正确做法:在各块之间设置 500 个 token 的重叠。每个块都包含前一块的尾部内容。
忽略来源追溯
错误做法:提取内容时不记录其来源块。
原因:当某条说法看起来不对时,你需要对照源文档进行核实。没有来源追溯,就无法做到这一点。
正确做法:每条提取结果都附带一个 chunk_id,用于链接回原始文本片段。