本地 OpenClaw 知识库初探:电力见证报表入库与 memory 检索
·
D1 把 OpenClaw 接到了 Ollama 本地模型。D2 继续验证:docx、xlsx 这类业务报表,能不能在内网建库、搜得到、对话里用得上。
我用的是一批电力见证资料(见证表模板、实施表、检查项目等),不是网上下的 demo 数据。
整体思路
OpenClaw 的 memory-core 直接索引 Markdown,当前路径是:
docx/xlsx → 转成 md → 放进 workspace → Ollama embedding → memory index → 对话检索
对话模型:qwen2.5:7b
嵌入模型:nomic-embed-text(本机 Ollama)
关键配置
"memorySearch": {
"provider": "ollama",
"model": "nomic-embed-text",
"remote": { "baseUrl": "http://host.docker.internal:11434" },
"extraPaths": ["knowledge/power-witness"],
"query": { "maxResults": 3 }
},
"tools": {
"profile": "messaging",
"alsoAllow": ["group:memory"]
},
"plugins": { "slots": { "memory": "memory-core" } }
tools.allow 会把工具列表锁死,应使用 alsoAllow。JSON 数组在 PowerShell 里建议用单引号或变量传递。
索引与验证:
docker compose run --rm --entrypoint node openclaw-gateway dist/index.js memory index --force
docker compose run --rm --entrypoint node openclaw-gateway dist/index.js memory search "逆变器见证"
最终索引 8 个文件、218 个 chunk,CLI 搜索能命中。
踩坑记录
- PowerShell 脚本里
[ERR]会报语法错,方括号在双引号中有特殊含义,改用普通文本输出。 - 中文目录路径导致脚本找不到文件,目录改用英文
power-witness后正常。 memory status显示 0/0,原因是尚未执行memory index --force。- 浏览器报 tools 不可用,
tools.allow误配,改为alsoAllow并启用plugins.slots.memory。 - Context overflow:7B 上下文有限,见证表体积又大,需 New Chat、缩短提问,并设置
query.maxResults。 - 配置中写了无效的
limits字段导致 Gateway 无法启动,应使用 schema 支持的query.maxResults。
小结
D2 完成了内网「入库 → 索引 → 搜索 → 对话调用 memory」的闭环。
当前方案仍有局限:docx 转 md 会丢格式,大表 chunk 多、泛问容易混到结构相近的文档,扫描件和复杂 Excel 也需要单独处理。商用场景需要按格式做解析、为 chunk 补充元数据(文件名、sheet、设备类型),并在回答中标注来源。
后续计划
- xlsx、PDF 分格式入库,不再依赖 Word 一键转 md
- 对话回答附带出处(文件名、段落)
- 文件夹增量监控与自动索引
本地 7B 适合试点 Demo,检索准确度更多取决于解析与引用机制,而不只是换更大的模型。
更多推荐


所有评论(0)