mcpField
I
indexion-segment

indexion-segment

github.com/trkbt10数据与数据库24.9k 次安装5 周前更新
代码仓库

关于 indexion-segment

indexion-segment 是用于将文本切分为上下文片段的命令行技能,适合准备 RAG、嵌入和细粒度相似度分析的数据。它提供滑动窗口差异度、TF-IDF 和标点边界策略,并可调整片段大小。

主要功能

  1. 01滑动窗口差异度切分
  2. 02基于 TF-IDF 的主题切分
  3. 03按标点和句子边界切分
  4. 04配置片段大小与阈值
  5. 05混合 NCD 与 TF-IDF 模式

适用场景

  1. 01为 RAG 或嵌入流程分块文本
  2. 02将文档拆分为有意义的章节
  3. 03按子文档粒度进行相似度分析

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/trkbt10/indexion-skills --skill indexion-segment

安装后在 Claude Code 中输入/indexion-segment确认已加载。

详细介绍

indexion 分段

使用基于差异度、TF-IDF 或标点符号的策略,将文本拆分为上下文连贯的片段。

适用场景

  • 用户需要为 RAG 或嵌入流程对文本分块
  • 用户想将文档拆分为有意义的章节
  • 用户要求对文本进行分段处理
  • 为文档级别的相似度分析准备文本

用法

# Default window divergence strategy
indexion segment <input-file> <output-dir>

# TF-IDF based segmentation
indexion segment --strategy=tfidf <input-file> <output-dir>

# Punctuation-based segmentation
indexion segment --strategy=punctuation <input-file> <output-dir>

# Custom segment sizes
indexion segment --min-size=200 --max-size=3000 --target-size=800 document.txt output/

# Custom divergence threshold
indexion segment --threshold=0.5 document.txt output/

# Adaptive threshold mode (default)
indexion segment --adaptive document.txt output/

# Hybrid NCD+TF-IDF mode
indexion segment --hybrid --ncd-weight=0.6 --tfidf-weight=0.4 document.txt output/

# Custom window size
indexion segment --window-size=5 document.txt output/

# Custom output prefix
indexion segment --prefix=chunk document.txt output/

选项

选项默认值说明
--strategy=NAMEwindow策略:window、tfidf、punctuation
--min-size=INT100片段的最小字符数
--max-size=INT2000片段的最大字符数
--target-size=INT500片段的目标字符数
--threshold=FLOAT0.42差异度阈值
--window-size=INT3窗口大小
--adaptivetrue自适应阈值模式
--hybridfalseNCD+TF-IDF 混合模式
--ncd-weight=FLOAT0.5混合模式中的 NCD 权重
--tfidf-weight=FLOAT0.5混合模式中的 TF-IDF 权重
--prefix=NAMEsegment输出文件前缀

策略

策略说明
window(默认)使用滑动窗口检测差异度
tfidf基于 TF-IDF 检测主题变化
punctuation基于标点符号或句子边界

工作流

  1. 运行 indexion segment <input-file> <output-dir>,使用默认设置拆分文本
  2. 调整 --threshold 和 --target-size,以控制分段粒度
  3. 对混合内容文档使用 --hybrid 模式,以提高准确性

评论

支持 Markdown