llmsherpa

Developer APIs to Accelerate LLM Projects

open-sourcetool-integration
1.8k
Stars
+8
Stars/month
0
Releases (6m)

Star Growth

+1 (0.1%)
1.7k1.8k1.8kMar 27Apr 1

Overview

LLM Sherpa 是一个专为大型语言模型项目设计的开发者 API 工具,主要解决传统 PDF 解析器无法保留文档布局信息的问题。其核心功能 LayoutPDFReader 能够智能解析 PDF 文档,提取层次化的布局结构,包括章节标题、段落、表格、列表等元素及其相互关系。该工具特别适合需要高质量文档理解的 RAG(检索增强生成)应用场景,能够实现更精确的文档分块和上下文保留。LLM Sherpa 现已完全开源(Apache 2.0 许可证),支持 Docker 部署,除 PDF 外还支持 DOCX、PPTX、HTML、TXT、XML 等多种文件格式,内置 OCR 功能,并提供坐标信息用于精确定位文档元素。

Deep Analysis

Key Differentiator

vs PyPDF/unstructured/pdfplumber: preserves document hierarchy (sections, subsections, tables-in-context) that other parsers discard — enables semantically optimal chunks for RAG instead of arbitrary line-break splits

Capabilities

  • PDF parsing preserving hierarchical section structure
  • Paragraph reconstruction across arbitrary line breaks
  • Table extraction with contextual section information
  • Nested list handling and cross-page content joining
  • Header/footer/watermark removal
  • Bounding box coordinates for layout elements
  • Smart chunking optimized for vectorization

🔗 Integrations

LlamaIndexOpenAIGoogle Gemini ProCohere Embed3nlm-ingestor (self-hosted parser)

Best For

  • RAG applications needing structure-aware PDF chunking
  • Table extraction with section context preservation
  • Document analysis where layout semantics matter for LLM accuracy

Not Ideal For

  • Scanned documents or image-heavy PDFs without text layers
  • Universal PDF parsing requiring 100% accuracy guarantee
  • OCR-dependent document workflows

Languages

Python

Deployment

self-hosted Docker (nlm-ingestor)pip install

Known Limitations

  • No OCR support — only PDFs with text layer
  • Not every PDF parses correctly despite extensive testing
  • Scanned document images not handled
  • Cloud API being decommissioned — self-hosting required

Pros

  • + 智能保留文档层次结构和布局信息,显著提升 LLM 应用的文档理解质量
  • + 完全开源且支持自部署,用户可完全控制数据处理流程和隐私
  • + 支持多种文件格式并内置 OCR,提供一站式文档处理解决方案

Cons

  • - PDF 解析准确性因文档复杂程度而异,无法保证所有 PDF 都能完美解析
  • - 官方免费和付费服务器未及时更新最新功能,建议用户自部署
  • - 相比简单的文本提取工具,学习和配置成本较高

Use Cases

  • 构建企业文档问答系统,需要准确理解复杂报告和手册的结构层次
  • 学术研究论文分析,自动提取章节、图表和参考文献等结构化信息
  • 法律文档处理,保留条款编号、层次关系等重要格式信息用于合规分析

Getting Started

安装 llmsherpa 库:pip install llmsherpa;部署后端服务:使用 Docker 运行 nlm-ingestor 镜像或使用免费 API 服务器;编写解析代码:导入 LayoutPDFReader 类,传入 PDF URL 开始解析并获取结构化内容

Compare llmsherpa