SKILL.md
唯讀
名稱
indexion-segment
描述
將文字分割成適合 RAG/嵌入管線的上下文區塊。透過 window、tfidf、punctuation 或混合策略進行文件分段與章節提取,並依意圖自動選擇策略。
indexion segment
使用基於分歧度、TF-IDF 或標點符號的策略,將文字分割成上下文區塊。
使用時機
- 使用者需要將文字分塊以用於 RAG 或嵌入管線
- 使用者希望將文件分割成有意義的章節
- 使用者要求對文字進行分段處理
- 準備在子文件層級進行相似度分析的文字
使用方式
# 預設視窗分歧策略
indexion segment <input-file> <output-dir>
# 基於 TF-IDF 的分段
indexion segment --strategy=tfidf <input-file> <output-dir>
# 基於標點符號的分段
indexion segment --strategy=punctuation <input-file> <output-dir>
# 自訂區塊大小
indexion segment --min-size=200 --max-size=3000 --target-size=800 document.txt output/
# 自訂分歧閾值
indexion segment --threshold=0.5 document.txt output/
# 自適應閾值模式(預設)
indexion segment --adaptive document.txt output/
# 混合 NCD+TF-IDF 模式
indexion segment --hybrid --ncd-weight=0.6 --tfidf-weight=0.4 document.txt output/
# 自訂視窗大小
indexion segment --window-size=5 document.txt output/
# 自訂輸出前綴
indexion segment --prefix=chunk document.txt output/
選項
| 選項 | 預設值 | 說明 |
|---|---|---|
--strategy=NAME |
window | 策略:window、tfidf、punctuation |
--min-size=INT |
100 | 最小區塊字元數 |
--max-size=INT |
2000 | 最大區塊字元數 |
--target-size=INT |
500 | 目標區塊字元數 |
--threshold=FLOAT |
0.42 | 分歧閾值 |
--window-size=INT |
3 | 視窗大小 |
--adaptive |
true | 自適應閾值模式 |
--hybrid |
false | NCD+TF-IDF 混合模式 |
--ncd-weight=FLOAT |
0.5 | 混合模式中 NCD 的權重 |
--tfidf-weight=FLOAT |
0.5 | 混合模式中 TF-IDF 的權重 |
--prefix=NAME |
segment | 輸出檔案前綴 |
策略
| 策略 | 說明 |
|---|---|
window(預設) |
滑動視窗分歧偵測 |
tfidf |
基於 TF-IDF 的主題變化偵測 |
punctuation |
基於標點符號/句子邊界 |
工作流程
- 執行
indexion segment <input-file> <output-dir>以預設值分割文字 - 調整
--threshold和--target-size來微調分段粒度 - 對混合內容的文件使用
--hybrid模式以獲得更好的準確度






