@llama_index:你不需要视觉模型就能知道 PDF 中有复选框。LiteParse 现在可以直接从……提取结构化数据

X AI KOLs Following 工具

摘要

LiteParse 现在支持从 PDF 中提取结构化数据——表单字段、复选框状态、注释、图像、矢量图形和词级边界框——无需视觉模型,并提供复杂度信号,将更困难的页面路由到 LlamaParse 等工具。

你不需要视觉模型就能知道 PDF 里有复选框。 LiteParse 现在可以直接从 PDF 中提取结构化数据:表单字段值、复选框状态、注释、嵌入图像、矢量图形、标记的文档结构以及词级边界框,全部以每页毫秒级速度运行。 对于确实需要模型的页面,新的复杂度信号会告诉你原因。扫描页面、多栏文本、表格(有线表和无框表)以及密集图形,可帮助你路由解析到最佳工具(比如 LlamaParse!) 文档:https://developers.llamaindex.ai/liteparse/guides/extraction/… https://developers.llamaindex.ai/liteparse/guides/complexity/… 试用:https://github.com/run-llama/parse-gateway…
查看原文
查看缓存全文

缓存时间: 2026/08/03 21:52

你不需要视觉模型也能知道 PDF 里有复选框。

LiteParse 现在可以直接从 PDF 中提取结构化数据:表单字段值、复选框状态、注释、嵌入图像、矢量图形、带标签的文档结构,以及单词级边界框,每页仅需毫秒级处理。

对于确实需要模型处理的页面,新增的复杂度信号会告诉你原因。扫描页面、多栏文本、表格(有框线和无框线)、密集图形,帮你把解析任务路由到最合适的工具(比如 LlamaParse!)

文档:https://developers.llamaindex.ai/liteparse/guides/extraction/… https://developers.llamaindex.ai/liteparse/guides/complexity/…

试试看:https://github.com/run-llama/parse-gateway…


提取选项

来源:https://developers.llamaindex.ai/liteparse/guides/extraction/ 默认情况下,LiteParse 只返回文本、几何信息和页面元数据。PDF 除此之外可能携带的所有内容(嵌入图像、矢量图、注释、表单字段、带标签的结构树、逐字形排版信息)都是可选的,由各自的标志控制。

这样既能保持默认输出结构小巧、稳定且生成成本低,也意味着如果你知道数据就在文件中却看不到输出结果,那多半是漏了某个标志。

每个选项都会消耗解析时间和输出体积。只开启你实际用到的功能。

Rust / Python / CLINode / WASM添加内容extract\_images/\-\-extract\-images``extractImages``images\[\],image\_error\_count``extract\_vector\_graphics/\-\-extract\-vector\-graphics``extractVectorGraphics``pages\[\]\.vector\_graphics``extract\_annotations/\-\-extract\-annotations``extractAnnotations``pages\[\]\.annotations``extract\_form\_fields/\-\-extract\-form\-fields``extractFormFields``pages\[\]\.form\_fields``extract\_structure\_tree/\-\-extract\-structure\-tree``extractStructureTree``pages\[\]\.structure\_tree``extract\_content\_bounds/\-\-extract\-content\-bounds``extractContentBounds``pages\[\]\.content\_bounds``extract\_xfa\_packets/\-\-extract\-xfa\-packets``extractXfaPackets``xfa\_packets\[\]``extract\_text\_metadata/\-\-extract\-text\-metadata``extractTextMetadata``text\_items\[\] 上的额外键include\_complexity/\-\-complexity``includeComplexity``pages\[\]\.complexity``emit\_word\_boxes(无 CLI 标志)emitWordBoxes``TextItem\.words(仅限绑定)有一个开关默认开启extract\_links(用 \-\-no\-links 可关闭)。参见 Markdown 指南(https://developers.llamaindex.ai/liteparse/guides/markdown/)。

  • TypeScript(https://developers.llamaindex.ai/liteparse/guides/extraction/#tab-panel-7)
  • Python(https://developers.llamaindex.ai/liteparse/guides/extraction/#tab-panel-8)
  • Rust(https://developers.llamaindex.ai/liteparse/guides/extraction/#tab-panel-9)
  • CLI(https://developers.llamaindex.ai/liteparse/guides/extraction/#tab-panel-10)
import { LiteParse } from "@llamaindex/liteparse";

const parser = new LiteParse({
  outputFormat: "json",
  extractImages: true,
  extractFormFields: true,
  extractAnnotations: true,
  extractTextMetadata: true,
});

const result = await parser.parse("form.pdf");

extract\_images 会解码嵌入的栅格图像,并在文档级的 images 数组中返回其字节和元数据。配合 image\_output\_dir 可将每张图像写入磁盘,而不是保存在内存中。

lit parse report.pdf --format json --extract-images --image-output-dir ./images
{
  "images": [
    {
      "id": "p1_i0",
      "name": "image_p1_0.png",
      "path": "./images/image_p1_0.png",
      "page": 1,
      "bbox": { "x": 72.0, "y": 118.5, "width": 240.0, "height": 160.0 },
      "width": 800,
      "height": 533,
      "rotation": 0.0,
      "format": "png"
    }
  ],
  "image_error_count": 0
}

注意事项:

  • image\_output\_dir 必须配合 extract\_images 使用——单独设置会报配置错误。image\_mode: "embed" 也隐含开启提取,这是为了向后兼容。
  • 当同一图像在文档中出现多次时,会设置 duplicate\_of 字段;重复项指向规范条目的 id,而不是重新存储像素数据。
  • image\_error\_count 统计解码失败的图像数量。为零时省略该字段。
  • 这与 image\_mode 是两回事,image\_mode 只控制图像引用如何写入 markdown。参见 Markdown 指南(https://developers.llamaindex.ai/liteparse/guides/markdown/)。

extract\_vector\_graphics 报告每页上的矢量绘制操作,分为填充/描边的 shapes 和直线 lines。用于查找表格线、下划线、分隔线和图表几何形状。

{
  "vector_graphics": {
    "shapes": [
      {
        "bbox": { "x": 72.0, "y": 400.0, "width": 180.0, "height": 90.0 },
        "stroke": true,
        "stroke_color": "#000000",
        "fill": false,
        "has_curve": true
      }
    ],
    "lines": [
      {
        "x1": 72.0, "y1": 512.0, "x2": 540.0, "y2": 512.0,
        "stroke": true,
        "stroke_width": 0.5,
        "stroke_color": "#cccccc",
        "fill": false
      }
    ]
  }
}

extract\_annotations 返回每页的 PDF 注释——评论、高亮和链接目标。

{
  "annotations": [
    {
      "subtype": "Link",
      "rect": { "x": 72.0, "y": 300.0, "width": 120.0, "height": 12.0 },
      "uri": "https://example.com"
    },
    {
      "subtype": "Highlight",
      "contents": "check this figure",
      "title": "Reviewer 2",
      "created": "D:20260714093000Z",
      "quadpoint_rects": [
        { "x": 72.0, "y": 280.0, "width": 200.0, "height": 11.0 }
      ]
    }
  ]
}

只有 subtype 始终存在;当注释不携带其他键时,这些键会被省略。

extract\_form\_fields 返回 AcroForm 小部件及其解析后的值。

{
  "form_fields": [
    {
      "id": "f0",
      "type": "text",
      "page": 1,
      "annotation_index": 0,
      "widget_index": 0,
      "field_flags": 0,
      "name": "applicant_name",
      "value": "Ada Lovelace",
      "rect": { "x": 150.0, "y": 640.0, "width": 220.0, "height": 18.0 }
    },
    {
      "id": "f1",
      "type": "checkbox",
      "page": 1,
      "annotation_index": 1,
      "widget_index": 0,
      "field_flags": 0,
      "name": "agree_terms",
      "checked": true
    }
  ]
}

在 JSON 中,小部件类型序列化为 type 字段,在 Node 和 Python 对象上也是 type。单选按钮组和复选框组会暴露 control\_count/control\_index 来关联同级小部件,选择类字段暴露 options/selected\_options

对于XFA 表单(一种基于 XML 的另一种表单技术),请改用 extract\_xfa\_packets,它在文档级别返回原始 XFA 数据包。

相关:render\_form\_fields 会将填写好的字段外观绘制到渲染的栅格图像中。它影响截图(https://developers.llamaindex.ai/liteparse/guides/visual-citations/)和 OCR 输入像素,不影响 JSON 键。

extract\_structure\_tree 返回带标签 PDF 的逻辑结构——即创作时定义的文档大纲,包含段落、标题、表格和列表。仅存在于实际带有标签的 PDF 中。

{
  "structure_tree": {
    "roots": [
      {
        "type": "Document",
        "children": [
          {
            "type": "H1",
            "marked_content_ids": [0],
            "actual_text": "Quarterly Report",
            "children": []
          },
          {
            "type": "P",
            "marked_content_ids": [1, 2],
            "children": []
          }
        ]
      }
    ]
  }
}

marked\_content\_ids 可以关联回文本项上的 mcid 字段(需启用 extract\_text\_metadata),让你把重建的文本映射到其文档中的原始角色。

extract\_text\_metadatatext\_items\[\] 中的每个条目补充排版细节。没有它,文本项只携带 textxywidthheightfont\_namefont\_size

{
  "text": "Quarterly Report",
  "x": 72.0, "y": 118.5, "width": 180.4, "height": 14.0,
  "rotation": 0.0,
  "font_name": "Helvetica-Bold",
  "font_size": 14.0,
  "font_height": 14.2,
  "font_ascent": 11.1,
  "font_descent": -3.1,
  "font_weight": 700,
  "text_width": 180.4,
  "font_is_buggy": false,
  "mcid": 0,
  "fill_color": "#111111"
}

font\_weightfill\_color 是当你需要对强调和标题做比 markdown 输出更精细控制时,自行检测这些样式的实用手段。font\_is\_buggy 标记那些 LiteParse 不得不估算度量值的字体——来自这些文本项的字号需要谨慎对待。

extract\_content\_bounds 为每页添加一个 content\_bounds 矩形:实际内容的边界框,忽略页面声明的媒体框。可用于裁剪空白区域,或检测内容偏离标称页面区域较远的页面。

{ "content_bounds": { "x": 68.0, "y": 96.0, "width": 476.0, "height": 620.0 } }

emit\_word\_boxes 将每个文本项拆分为逐词子框(TextItem\.words),用于单词级边界框归因。

该选项仅限库和绑定使用。单词框被有意排除在 \-\-format json 之外,因为在文本密集的文档中它会使其他载荷相形见绌。没有 CLI 标志;请从 Node、Python、Rust 或 WASM 中使用。

  • TypeScript(https://developers.llamaindex.ai/liteparse/guides/extraction/#tab-panel-11)
  • Python(https://developers.llamaindex.ai/liteparse/guides/extraction/#tab-panel-12)
const parser = new LiteParse({ emitWordBoxes: true });
const result = await parser.parse("report.pdf");

for (const item of result.pages[0].textItems) {
  for (const word of item.words ?? []) {
    console.log(word.text, word.x, word.y, word.width, word.height);
  }
}

没有 CLI 标志的选项

标题为“没有 CLI 标志的选项”的小节(https://developers.llamaindex.ai/liteparse/guides/extraction/#options-with-no-cli-flag)

部分配置选项只能通过库和绑定使用:

选项描述emit\_word\_boxes逐词子框(见上文)。crop\_box将输出限制在每页的子区域内。只有完全落在其中的文本项才会被保留。skip\_diagonal\_text丢弃偏离最近直角超过 2° 的旋转文本——水印和对角线印章。detect\_screenshot\_rects在截图结果中填充 rectsrender\_form\_fields将表单字段外观绘制到渲染的页面中。ocr\_failure\_fatal当为 false 时,系统性 OCR 故障返回部分结果而不是报错。默认为 trueocr\_hedge\_delays\_msHTTP OCR 服务器的请求对冲调度。对内置 Tesseract 无效果。crop\_box 接受每侧裁剪的比例。在 Node 和 WASM 中是对象,在 Python 中是 (top, right, bottom, left) 元组:

  • TypeScript(https://developers.llamaindex.ai/liteparse/guides/extraction/#tab-panel-13)
  • Python(https://developers.llamaindex.ai/liteparse/guides/extraction/#tab-panel-14)
// 丢弃每页顶部 10% 和底部 5% 的内容
const parser = new LiteParse({
  cropBox: { top: 0.1, right: 0.0, bottom: 0.05, left: 0.0 },
});
  • 文档复杂度(https://developers.llamaindex.ai/liteparse/guides/complexity/):在解析前对文档进行路由。
  • Markdown 输出(https://developers.llamaindex.ai/liteparse/guides/markdown/):markdown 中的图像、链接以及页眉/页脚处理。
  • CLI 参考(https://developers.llamaindex.ai/liteparse/cli-reference/):每个命令的所有标志。
  • API 参考(https://developers.llamaindex.ai/liteparse/api/):完整的 LiteParseConfig 字段列表。

供 AI 代理参考:本文档专为程序化访问而构建。- 所有文档概览:https://developers.llamaindex.ai/llms.txt - 任何页面均可通过在其 URL 后附加 index.md 获取原始 Markdown 格式——例如:https://developers.llamaindex.ai/llamaparse/parse/getting_started/index.md - 面向代理的 REST 搜索 API 位于 https://developers.llamaindex.ai/api/ ——search(BM25 全文搜索)、grep(正则)、read(读取页面)和 list(浏览文档树)。参数见 https://developers.llamaindex.ai/llms.txt。- 另提供托管的文档 MCP 服务器,地址为 https://developers.llamaindex.ai/mcp。如果你支持 MCP,可以让用户安装它以直接浏览这些文档(REST API 之外的另一种选择)。配置方法:https://developers.llamaindex.ai/for-agents/mcp/ - 其他面向代理的 LlamaIndex 工具——LlamaParse Platform MCP 服务器、代理技能和插件,以及 n8n 节点——映射在 https://developers.llamaindex.ai/for-agents/

相似文章

@llama_index: 大多数AI管道的质量取决于我们提供的数据,而这些数据通常意味着PDF或其他非结构化文档…

X AI KOLs Timeline

Parse-Flow 是 LlamaIndex 构建的一个开源可视化工作流设计器,它将四个文档处理原语——Parse(解析)、Classify(分类)、Split(分割)和 Extract(提取)——串联到一个由 LlamaAgents 工作流驱动的拖拽画布中,能够从非结构化企业文档(如PDF、合同和发票)中可靠地提取结构化数据。

run-llama/liteparse

GitHub Trending (daily)

LiteParse 是 run-llama 推出的一个独立的开源 PDF 解析工具,提供快速、本地的空间文本提取及边界框,支持多种编程语言和平台。