AIFeed

Show HN: Docxtract – 将文档转换为清晰的 LLM 上下文和学习指南

Translation(model translation, not the source's own text)

docxtract

通用文档爬虫、高密度 Markdown 提取器与 BYOLLM 合成工具包

PyPI version
PyPI version
为 LLM 上下文窗口而生(Token 噪声降低 70%+):标准网页爬虫会倾倒数兆字节的原始 HTML、重复的导航菜单、cookie 横幅和 script 标签,这些内容会耗尽上下文窗口并稀释模型注意力。docxtract 专为生成紧凑、高密度、简洁的 Markdown 提取物而设计。它保留代码块、YAML schema、markdown 表格和视频讲解链接,同时消除 70%+ 的网页噪声——为你的本地或云端 LLM 提供纯净、高信号的上下文,零 token 冗余。

为什么选择 docxtract?

功能标准网页爬虫(Firecrawl、Puppeteer)docxtract
上下文密度Token 冗余高(导航栏、页脚、cookie 横幅)剥离 70%+ 噪声;纯内容信号
视频流被剥离或丢失保留 <mux-player> M3U8、Loom 和 YouTube 嵌入
合成引擎仅原始 markdown 转储内置多阶段 Map-Reduce 生成 master_review.md
本地 LLM 支持侧重云 API原生 BYOLLM( llama.cpp 、Ollama、vLLM、LM Studio)
思考模型提示词冗余触发上下文上限针对 DeepSeek-R1 的 token 耗尽防护
IDE 集成需要自定义脚本原生 Model Context Protocol (MCP) 服务器,支持 Claude 与 Cursor
用户界面仅 CLI交互式 Web UI( localhost:7860 )与一键 Colab

架构


        ┌─────────────────────────────────────────┐
                       │ Target Documentation / Course Portal    │
                       └────────────────────┬────────────────────┘
                                            │
                                            ▼
                       ┌─────────────────────────────────────────┐
                       │         docxtract Crawl Engine          │
                       │  - Cleans boilerplate, nav & footers    │
                       │  - Extracts Mux streams, iframes, video │
                       │  - Generates structured Markdown files  │
                       └────────────────────┬────────────────────┘
                                            │
                                            ▼
                       ┌─────────────────────────────────────────┐
                       │     Universal BYOLLM Client Layer       │
                       │  - llama.cpp (http://localhost:8080/v1) │
                       │  - Ollama (http://localhost:11434/v1)   │
                       │  - LM Studio / vLLM / OpenAI / Groq     │
                       └────────────────────┬────────────────────┘
                                            │
                                            ▼
                       ┌─────────────────────────────────────────┐
                       │   Master Review & Synthesis Engine      │
                       │  - Stage 1: Document Distillation       │
                       │  - Stage 2: Executive Synthesis         │
                       │  - Stage 3: Master Compendium Assembly  │
                       └─────────────────────────────────────────┘
      

真实案例展示

查看从 Warp Software Factory 工程课程的 12 篇文章中生成的真实提取与合成结果:👉 查看 1,220 行的 Master Technical Review

  • 原始 HTML 大小:约 115,000 tokens
  • docxtract Markdown 大小:约 18,000 tokens(token 减少 84%)
  • 合成时间:使用本地 Ollama(llama3.3)约 2 分钟

快速开始

1. 安装

通过 PyPI 安装:


        pip install docxtract-ai
      

或从源码安装:


        git clone https://github.com/raycollabs/docxtract.git
cd docxtract
pip install -e .
      

2. 启动 Web UI


        docxtract ui
      

在浏览器中打开 http://localhost:7860 。配置目标 URL、选择模型预设、测试端点,然后运行流水线!

CLI 用法

测试端点连接


        # Check local llama.cpp
docxtract test-llm --base-url http://localhost:8080/v1

# Check local Ollama
docxtract test-llm --base-url http://localhost:11434/v1 --model llama3.3
      

抓取文档


        docxtract crawl https://www.warp.dev/learn --depth 2 --output ./output
      

合成主复习指南


        docxtract synthesize ./output --base-url http://localhost:11434/v1 --model llama3.3
      

Model Context Protocol (MCP) 服务器

docxtract 内置一个原生 stdio MCP 服务器,适用于 Claude Desktop、Cursor 和 Windsurf。你的 AI 助手可以直接在你的 IDE 内抓取并合成文档!

添加到 Claude Desktop (claude_desktop_config.json)


        {
  "mcpServers": {
    "docxtract": {
      "command": "docxtract",
      "args": ["mcp"]
    }
  }
}
      

添加到 Cursor (.cursor/mcp.json)


        {
  "mcpServers": {
    "docxtract": {
      "command": "docxtract",
      "args": ["mcp"]
    }
  }
}
      

暴露的 MCP 工具:

  • crawl_docs: 将整个文档门户抓取为干净的 markdown。
  • extract_page: 即时将单个文档 URL 提取为高密度 markdown,用于提示注入。
  • synthesize_docs: 使用本地 BYOLLM 将文档文件夹合成为 master_review.md。

文档

  • 概览与能力
  • 架构与内部机制
  • BYOLLM 配置指南(llama.cpp、Ollama、vLLM、Cloud)
  • Web UI 用户指南
  • Google Colab 部署指南
  • CLI 参考
  • 社区发布与分发套件

许可证

依据 Apache-2.0 许可证分发。详见 LICENSE。

The translation is machine-generated and individual terms may be off. Nothing is rewritten or cut; the original is authoritative.

Published by HN AI
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗