Install
openclaw skills install corpus-builder语料库构建工具,支持智能分块、AI 标注、向量化存储。可选 LLM 标注(需 DashScope API)或规则降级。
openclaw skills install corpus-builder轻量级语料库构建工具,针对中文小说优化,支持场景智能分块、10 维度 AI 标注、ChromaDB 向量存储。
标注模式:
DASHSCOPE_API_KEY)本技能承诺:
DASHSCOPE_API_KEY 传递~/.openclaw/ 目录或任何全局配置文件设置环境变量(唯一支持的方式):
# 临时设置(当前终端有效)
export DASHSCOPE_API_KEY="sk-xxx"
# 永久设置(添加到 ~/.bashrc)
echo 'export DASHSCOPE_API_KEY="sk-xxx"' >> ~/.bashrc
source ~/.bashrc
⚠️ 注意: 不要将 API Key 提交到 Git 或分享给他人。
无需 API Key,自动使用规则引擎进行标注:
DASHSCOPE_API_KEY 环境变量如果运行时报错 sqlite3 version < 3.35.0:
# 安装 pysqlite3-binary(仅旧系统需要)
pip3 install pysqlite3-binary --user
现代系统(Ubuntu 20.04+, macOS 12+, Python 3.10+)通常不需要。
cd ~/.openclaw/workspace/skills/corpus-builder
# 1. 批量处理小说文本
python3 scripts/build_corpus.py \
--source ~/workspace/novels/reference \
--name 玄幻打斗 \
--genre 玄幻 \
--max-chunk-size 2000
# 2. 查看统计信息
python3 scripts/build_corpus.py \
--stats \
--collection 玄幻打斗
# 3. 导出标注数据
python3 scripts/build_corpus.py \
--export json \
--collection 玄幻打斗 \
--output results.json
💡 需要检索语料? 请使用
corpus-search技能。
{
"scene_type": "打斗",
"emotion": "紧张",
"quality_score": 8,
"original_text": "...",
"source_file": "没钱修什么仙.txt"
}
cd ~/.openclaw/workspace/skills/corpus-builder
pip3 install -r requirements.txt --user
| 包 | 用途 |
|---|---|
| chromadb | 向量数据库 |
| sentence-transformers | 嵌入模型 |
| pyyaml | YAML 处理 |
| rich | CLI 美化 |
| psutil | 内存监控 |
编辑 configs/default_config.yml:
chunking:
max_chunk_size: 2000
min_chunk_size: 100
overlap: 200
processing:
batch_size: 5
embedding_batch_size: 32
max_workers: 3
models:
embedding: "BAAI/bge-small-zh-v1.5"
annotation: "dashscope-coding/qwen3.5-plus"
storage:
persist_directory: "./corpus/chroma"
checkpoint_dir: "./corpus/cache"
# 降低内存限制
python3 scripts/build_corpus.py \
--source ./novels \
--name test \
--memory-limit 1500 \
--batch-size 3
使用规则降级方案,标注结果仍可生成,只是质量得分较低。
删除向量库重新构建:
rm -rf corpus/chroma/{collection_name}
python3 scripts/build_corpus.py --source ./novels --name test
| 脚本 | 用途 |
|---|---|
scripts/build_corpus.py | 主程序(语料库构建) |
Created for OpenClaw 🦞
Version: 1.0.0
Last Updated: 2026-03-28