modelscope.cn

personal-knowledge-base-qa

Execute the local personal knowledge base intelligent QA system powered by NVIDIA GPU.

Installation

$ npx skills add https://modelscope.cn

Summary

  • Execute the local personal knowledge base intelligent QA system powered by NVIDIA GPU.
  • This skill supports uploading PDF, DOCX, PPTX, XLSX documents, parsing them into Markdown format, building AI summaries, and providing intelligent question answering capabilities.
  • All processing is done locally with Ollama qwen2:7b model.

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from modelscope.cn · top by installs.

npx skills add https://modelscope.cn

Browse all from modelscope.cn

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 5,511 B

History

  1. First recorded snapshot · 0 installs

SKILL.md

私人知识库智能问答系统

技能描述

本技能自动化执行"私人知识库智能问答系统"项目,提供文档上传、解析、AI摘要和智能问答功能。所有处理均在本地完成,基于NVIDIA GPU加速推理,零API成本。

核心功能:

  • 📁 文档上传 — 支持PDF、DOCX、PPTX、XLSX格式
  • 📝 文档解析 — 自动转换为Markdown格式,按文件类型分类存储
  • 🤖 AI摘要生成 — 使用Ollama qwen2:7b模型生成文档摘要
  • 🔍 智能问答 — 通过LLM驱动的文档检索和问答,支持关键词回退机制
  • 📋 索引管理 — 三层索引结构(路径、文件名、内容概括)

技术特色:

  • ✅ 完全本地运行,数据隐私保护
  • ✅ 基于NVIDIA GPU加速推理(CUDA)
  • ✅ 零API费用,无需Key
  • ✅ 使用Ollama qwen2:7b模型
  • ✅ 支持Intel AI PC(通过OpenVINO)
  • ✅ 三重检索策略:LLM语义检索 → 关键词检索 → 规则式回退

前置要求

系统要求

  • 操作系统: Windows 10/11(推荐)、Linux、macOS
  • Python: 3.10+
  • 处理器: NVIDIA GPU(推荐 RTX 4050 及以上)或 Intel AI PC(Core Ultra)
  • 内存: 最低 8 GB,推荐 16 GB
  • 显存: 最低 8 GB(qwen2:7b INT8约占用7GB显存)
  • 存储: 至少 10 GB 可用空间(模型文件约 7 GB)

依赖工具

  • pip(Python 包管理器)
  • Ollama(用于本地LLM推理)

目录结构

<skill-root>/                   # 本 SKILL.md 所在目录
├── SKILL.md                    # 本技能定义文件
├── scripts/                    # 核心脚本包(Python 包)
│   ├── __init__.py
│   ├── main.py                 # Gradio Web 应用入口
│   ├── gradio_app.py           # Gradio 界面定义
│   ├── document_processor.py   # 文档处理管道
│   ├── index_manager.py        # 索引管理
│   ├── knowledge_base.py       # 知识库管理
│   ├── llm_service.py          # LLM 服务
│   ├── summary_generator.py    # 摘要生成
│   ├── parsers/                # 文档解析器
│   │   ├── __init__.py
│   │   ├── pdf_parser.py
│   │   ├── docx_parser.py
│   │   ├── pptx_parser.py
│   │   └── xlsx_parser.py
│   └── requirements.txt        # Python 依赖列表
└── user_data/                  # 用户数据目录(运行时生成)
    ├── pdf/
    ├── docx/
    ├── pptx/
    ├── xlsx/
    └── index.md

执行步骤

步骤 1: 安装 Python 依赖

# 确保在 skill 根目录下执行
cd /path/to/skill-root
pip install -r scripts/requirements.txt

步骤 2: 启动 Ollama 服务

# 启动 Ollama 服务(后台运行)
ollama serve

# 在另一个终端拉取 qwen2:7b 模型
ollama pull qwen2:7b

说明:

  • 模型文件约 7 GB,下载时间取决于网络速度
  • 首次下载后会自动缓存,后续启动无需重新下载

步骤 3: 启动 Gradio Web 应用

python scripts/main.py

启动后浏览器访问 http://localhost:8000,即可在图形界面中使用所有功能。


🎯 核心功能说明

功能 1: 文档上传

位置: Web 界面「📤 文档上传」Tab

支持上传 PDF、DOCX、PPTX、XLSX 格式文件,系统自动解析并按文件类型分类存储。上传后会自动生成AI摘要。

功能 2: 智能问答

位置: Web 界面「💬 智能问答」Tab

输入问题后,系统会:

  1. 将问题和索引传给 LLM,由 LLM 判断需要检索哪些文档
  2. 如果LLM选文件失败,自动触发关键词检索
  3. 如果关键词检索也失败,使用规则式2-gram/3-gram切分进行回退检索
  4. 读取相关文档内容,根据关键词位置动态截取上下文
  5. 将问题和文档内容一起传给 LLM 生成回答

功能 3: 文档管理

位置: Web 界面「📋 文档管理」Tab

查看已上传的文档列表,支持搜索、删除和重建索引。


🚀 使用方式

方式一:Web 界面(推荐)

python scripts/main.py

打开浏览器访问 http://localhost:8000,按「上传文档 → 智能问答」流程使用。

方式二:Intel AI PC 部署

如需在 Intel AI PC 上运行(使用 NPU 加速):

# 安装 OpenVINO 依赖
pip install openvino optimum-intel

# 转换模型为 OpenVINO 格式
optimum-cli export openvino \
  --model Qwen/Qwen2-7B-Instruct \
  --quantization int4 \
  --output models/qwen2-7b-int4-ov

📝 API 接口说明

API 路径 方法 功能
/api/upload POST 上传文档(支持.pdf, .docx, .pptx, .xlsx)
/api/documents GET 获取文档列表
/api/search GET 搜索文档(参数:q)
/api/ask POST 智能问答(参数:question)
/api/documents/{file_path} DELETE 删除文档
/api/rebuild POST 重建索引

📄 许可证

MIT License