如何在自己的 PDF 上评测文档提取准确率
原题How to Benchmark Document Extraction Accuracy on Your Own PDFs
推荐理由文档提取评测教程覆盖生产 PDF 分层采样、字段标准化及正确、错误、缺失、臆造四类结果。团队可建立自己的 AI 文档处理基准,并用配对检验比较工具,替代供应商平均准确率。
读前速览
本文全面介绍如何构建基准测试框架,使用自己的 PDF 测量文档提取准确率,内容涵盖测试集构建、答案标注、字段规范化、错误分类、配对显著性检验、表格评分、一致性检查、不确定性验证和审计追溯。
在自己的文档上评测准确率,而不是依赖供应商公布的数据
供应商公布的准确率数据基于其选定的数据集,但你的文档在扫描质量、供应商发票版式、手写字段和边缘情况方面各不相同,这些因素决定了工具在你的实际工作流中的表现。
采用四种结果分类(正确、错误、缺失、臆造),识别关键失效模式
缺失值会在下游流程中明显报错,而看似合理的臆造值却可能通过验证并污染你的记录系统,因此尤其需要密切追踪「臆造」这一类别。
对配对文档进行工具比较时,使用 McNemar 精确检验获得统计上有效的结果
由于所有工具都处理同一批文档,单凭目测比较置信区间是否重叠,远不如 McNemar 检验可靠。该检验会统计工具结果不一致的字段,并判断差异是否超出随机因素所能解释的范围。
展开合并单元格后,在单元格层面使用精确率和召回率评估表格
如果单元格错位,表格即使包含正确的值,结构仍可能错误。将行列跨度展开为完整网格,便能逐个单元格进行比较,同时发现被遗漏或多出的单元格。
确保每个提取值都能指向文档中的源位置,以验证可追溯性
审计验证要求每个值都能追溯到文档中的确切位置;不过,位置正确并不代表值也正确。可追溯性让错误能够被核查,而不是被准确率指标掩盖。
完整摘要
本文介绍团队如何使用自己的生产文档评测文档提取准确率,而不是依赖供应商公布的数据。文章提出一个由 9 个步骤组成的流程:(1) 按文档类型、质量、版式和长度分层,从生产文档中构建测试集;(2) 以 JSON 格式创建答案标注,并明确记录空字段的 null 值;(3) 按字段类型(文本、ID、金额、日期)规范化值,以处理格式差异;(4) 使用四种结果分类(正确、错误、缺失、臆造)评估字段,以区分遗漏与幻觉;(5) 使用配对结果进行 McNemar 精确检验,比较不同工具;(6) 在单元格层面使用精确率和召回率指标评估表格;(7) 多次运行同一批文档,测试一致性;(8) 验证置信度信号是否与错误相关;(9) 检查提取的值能否在源文档中定位,以验证可追溯性。文章强调,应根据错误成本为每个字段设定准确率目标,并在报告中分别呈现各项指标,确保决策透明。
目录 · 15 节
评估文档提取方案的团队通常会先问:目前最准确的 API 是哪些?每家供应商都会给出一个公开发布的准确率数字,而这些数字无一例外都来自供应商自行选定的数据集。你的文档有自己的扫描质量、供应商各异的发票版式、手写字段和边缘情况,因此,只有在你自己的文件上测得的准确率,才能预测某款工具在你的处理流程中的表现。Teams evaluating document extraction usually start by asking which APIs are the most accurate available today. Every vendor answers with a published accuracy number, and every one of those numbers comes from a dataset the vendor picked. Your documents have your scan quality, your vendors' invoice layouts, your handwritten fields, and your edge cases, so the accuracy figure that predicts how a tool behaves in your pipeline is the one you measure on your own files.
本指南将介绍我们会如何构建一套基准测试框架,用于比较不同供应商的文档提取准确率。内容涵盖测试集、标准答案、类型化规范化、字段与表格评分、配对显著性检验、一致性、不确定性信号以及审计可追溯性。代码采用纯 Python 编写,不依赖任何供应商,因此你可以将其用于任何工具的输出,包括 LandingAI 的 Agentic Document Extraction (ADE)。This guide walks through the benchmark harness we would build to compare document extraction accuracy across vendors. It covers the test set, the answer key, typed normalization, field and table scoring, paired significance testing, consistency, uncertainty signals, and audit traceability. The code is plain Python with no vendor dependency, so you can point it at the output of any tool, including LandingAI's Agentic Document Extraction (ADE).
你实际测量的内容 What you are actually measuring
一个有用的信息提取基准应衡量四个不同方面,把它们合并成一个准确率数字会掩盖最关键的失败。从一开始就应将它们分开:A useful extraction benchmark measures four separate things, and folding them into one accuracy number hides the failures that matter most. Keep them apart from the start:
- 字段准确率:规范化后每个提取值是否与答案键匹配Field accuracy: whether each extracted value matches the answer key after normalization
- 表格保真度:每个单元格是否都位于正确的行和列中,且没有添加或遗漏任何内容。Table fidelity: whether every cell lands in the right row and column, with nothing added or dropped
- 一致性:同一文档在重复运行时是否会产生相同的输出。Consistency: whether the same document produces the same output across repeated runs
- 可追溯性:每个值是否都能追溯到其在文档中的来源位置Traceability: whether each value points back to the place in the document it came from
前三项告诉你输出是否正确。第四项则告诉你审阅者或审计人员能否核验它,这是另一种属性,值得在结果中单独列出一栏。The first three tell you whether the output is correct. The fourth tells you whether a reviewer or an auditor can verify it, which is a different property and deserves its own column in your results.
步骤 1:根据生产环境文档构建测试集 Step 1: Build a test set from production documents
测试集应来自你的流水线实际会接收的文档,并涵盖你在生产环境中观察到的各种差异。直接从接收入口提取文件,然后按照会影响信息提取难度的维度进行分类:The test set should come from the documents your pipeline will actually receive, sampled across the variation you see in production. Pull files directly from your intake, then sort them by the dimensions that change extraction difficulty:
- 文档类型:发票、对账单、表格、合同以及范围内的其他任何文件Document type: invoices, statements, forms, contracts, and anything else in scope
- 源文件质量:原生数字 PDF、清晰扫描件、传真件和手机拍摄的照片Source quality: born digital PDFs, clean scans, faxes, and phone photos
- 版式:单栏、多栏、密集表格,以及印刷内容与手写内容混排的页面Layout: single column, multi column, dense tables, and pages that mix print with handwriting
- 长度:单页文件,以及表格跨页的长文档Length: single page files alongside long documents where tables cross page breaks
记录每份文档所属的分层,以及该层在生产数据量中所占的比例,因为报告后续会用到这些占比。确保疑难案例得到充分体现,因为如果基准测试主要由干净文件构成,各工具的排名就会非常接近,提供不了多少有用信息。Record each document's stratum and how much of your production volume that stratum represents, since the report uses those shares later. Make sure the hard cases are well represented, because a benchmark built mostly on clean files will rank every tool close together and tell you little.
步骤 2:编写答案键,包括空字段。 Step 2: Write the answer key, including the empty fields
每份文档都对应一个答案键 JSON 文件,用于记录架构中每个字段的正确值;它必须同样仔细地记录字段的缺失与存在。如果某个字段在页面上确实没有值,就写 null。正是这一选择,才能让你的测试框架捕捉到工具凭空编造值的情况。The answer key is a JSON file per document that records the correct value for every field in your schema, and it has to record absence as carefully as presence. When a field genuinely has no value on the page, write null. That single choice is what lets your harness catch a tool that invents values.
{
"doc_id": "inv_0042",
"invoice_number": "INV-20931",
"invoice_date": "2026-03-14",
"total_amount": "18450.00",
"po_number": null,
"vendor_name": "Acme Industrial Supply"
}
在参考答案旁边,为每个字段声明类型。类型决定测试框架在第 3 步中如何比较值:Next to the answer key, declare a type for every field. The type decides how the harness compares values in Step 3:
FIELD_KINDS = {
"invoice_number": "id",
"invoice_date": "date",
"total_amount": "amount",
"po_number": "id",
"vendor_name": "text",
}
答案键本身也存在错误率。让两个人独立标注同一子集,逐字段比较他们的答案键,并在评估任何工具之前解决所有分歧。标注者经常意见不一致的字段,通常说明其在模式定义中存在歧义;明确并收紧这些字段的定义,能提升整个基准测试的质量。The answer key has its own error rate. Have two people label the same subset independently, compare their keys field by field, and resolve every disagreement before scoring any tool. Fields where labelers disagree often are usually ambiguous in the schema, and tightening their definitions improves the whole benchmark.
在运行任何工具之前先冻结 schema,并对所有要比较的工具使用相同的 schema。如果需要一个起点,Build Schema 可以根据样本文档或字段的文字描述起草提取 schema,并保留版本历史记录;当评估过程中 schema 发生变化时,这会很有帮助。Freeze the schema before you run any tool, and use the same schema for every tool you compare. If you need a starting point, Build Schema drafts an extraction schema from sample documents or a written description of the fields, and it keeps a version history, which helps when the schema changes partway through an evaluation.
步骤 3:按字段类型规范化值 Step 3: Normalize values by field type
规范化会去除不影响含义的格式差异,因此测试框架比较的是值而非字符串。一个负责猜测所有值类型的函数,造成的错误比消除的错误还多:它会把采购订单号 0042 转成数字 42,还会把 1.234,56 这样的欧洲金额读成 1.23456。为每个字段声明类型可以避免这两种问题。Normalization removes formatting differences that carry no meaning, so the harness compares values instead of strings. One function that guesses the type of every value causes more errors than it removes: it turns PO number 0042 into the number 42, and it reads a European amount like 1.234,56 as 1.23456. Declaring the type per field avoids both.
import re
from datetime import datetime
from decimal import Decimal, InvalidOperation
def parse_amount(text, decimal_comma=False):
negative = text.startswith("(") and text.endswith(")")
cleaned = re.sub(r"[^\d,.\-]", "", text)
if decimal_comma:
cleaned = cleaned.replace(".", "").replace(",", ".")
else:
cleaned = cleaned.replace(",", "")
try:
amount = Decimal(cleaned)
except InvalidOperation:
return text
return -amount if negative else amount
def normalize(value, kind="text", date_formats=("%Y-%m-%d",), decimal_comma=False):
if value is None:
return None
text = " ".join(str(value).split())
if text == "":
return None
if kind == "text":
return text.casefold()
if kind == "id":
return text.replace(" ", "").upper()
if kind == "amount":
return parse_amount(text, decimal_comma)
if kind == "date":
for fmt in date_formats:
try:
return datetime.strptime(text, fmt).date().isoformat()
except ValueError:
continue
return text
raise ValueError(f"unknown field kind: {kind}")
这段代码中的一些选择是经过刻意设计的。金额使用 Decimal,因此 $18,450.00、USD 18450 和 18450 会被视为相等,不会出现浮点数带来的意外;括号表示的会计负数也会保留其符号。ID 会保留前导零,并忽略空格。A few choices in this code are deliberate. Amounts use Decimal, so $18,450.00, USD 18450, and 18450 compare as equal without floating point surprises, and accounting negatives in parentheses keep their sign. IDs keep leading zeros and ignore spacing.
id 分支会将值转换为大写,因此如果大小写对标识符有意义,请移除 .upper()。根据文档的区域设置,为每份文档设置 decimal_comma。对于日期,只列出文档实际使用的格式,因为 03/04/2026 在 %m/%d/%Y 下会解析为 3 月 4 日,在 %d/%m/%Y 下则会解析为 4 月 3 日;这个选择应由答案键决定,而不应交给解析器猜测。The id branch uppercases values, so drop .upper() if case carries meaning in your identifiers. Set decimal_comma per document based on its locale. For dates, list only the formats your documents use, since 03/04/2026 parses as March 4 under %m/%d/%Y and April 3 under %d/%m/%Y, and that choice belongs in the answer key rather than in a parser's guess.
步骤 4:使用错误分类体系对字段评分 Step 4: Score fields with an error taxonomy
每项字段比较都应归入四种结果之一,因为“错误”涵盖了后果截然不同的失败情况。这套分类法将漏掉一个值与凭空编造一个值区分开来:Each field comparison should land in one of four outcomes, since "wrong" covers failures with very different consequences. The taxonomy separates a missed value from an invented one:
from collections import Counter
def score_field(expected, predicted, kind="text", **opts):
e = normalize(expected, kind, **opts)
p = normalize(predicted, kind, **opts)
if e is None and p is None:
return "correct"
if e is None:
return "invented" # value returned for a field the page leaves empty
if p is None:
return "missing"
return "correct" if e == p else "wrong"
def score_document(answer_key, output, field_kinds):
return {field: score_field(answer_key.get(field), output.get(field), kind)
for field, kind in field_kinds.items()}
def summarize(scored_docs):
per_field = {}
for doc in scored_docs:
for field, outcome in doc.items():
per_field.setdefault(field, Counter())[outcome] += 1
return per_field
仔细核查编造的数量。缺失值通常会在下游显现出明显错误,而看似合理的编造值却能通过验证,进入你的权威记录系统。Watch the invented count closely. A missing value usually fails loudly downstream, while an invented value that looks plausible passes validation and lands in your system of record.
按字段报告每项准确率及其置信区间,因为各字段的样本量不同。Wilson 评分区间适用于小样本:Report every per field accuracy with a confidence interval, because the sample size behind each field varies. The Wilson score interval handles small samples well:
from math import sqrt
def wilson_interval(successes, n, z=1.96):
if n == 0:
return (0.0, 1.0)
p = successes / n
denom = 1 + z**2 / n
center = (p + z**2 / (2 * n)) / denom
margin = z * sqrt(p * (1 - p) / n + z**2 / (4 * n**2)) / denom
return (center - margin, center + margin)
在 40 次中答对 38 次时,95% 置信区间大约为 83.5% 至 98.6%。在 400 次中答对 380 次时,区间则缩窄至大约 92.4% 至 96.7%。这个区间告诉你对某一领域中的某个工具测量得有多精确,也回答了一个不同于“一个工具是否胜过另一个工具”的问题。With 38 correct out of 40, the 95 percent interval runs from roughly 83.5 to 98.6 percent. With 380 out of 400, it narrows to roughly 92.4 to 96.7 percent. The interval tells you how precisely you have measured one tool on one field, and it answers a different question from whether one tool beats another.
步骤 5:使用配对检验比较工具 Step 5: Compare tools with a paired test
每种工具都基于相同的文档运行,因此恰当的比较应关注工具结论不一致的情况。McNemar 精确检验会分别统计一方答对、另一方答错的字段数,并检验这种差异是否大于随机情况下的预期:Every tool runs on the same documents, so the right comparison looks at the cases where the tools disagree. McNemar's exact test counts the fields one tool got right and the other got wrong, in each direction, and checks whether that split is larger than chance would produce:
from math import comb
def mcnemar_exact(a_correct, b_correct):
"""Paired outcomes per (document, field): True when that tool was correct."""
only_a = sum(1 for a, b in zip(a_correct, b_correct) if a and not b)
only_b = sum(1 for a, b in zip(a_correct, b_correct) if b and not a)
n = only_a + only_b
if n == 0:
return only_a, only_b, 1.0
k = min(only_a, only_b)
p = 2 * sum(comb(n, i) for i in range(k + 1)) / 2**n
return only_a, only_b, min(1.0, p)
如果工具 A 在工具 B 出错的 10 个字段上判断正确,而工具 B 在工具 A 出错的 2 个字段上判断正确,那么双侧 p 值约为 0.039。用肉眼比较两个相互重叠的置信区间是一种较弱的检验方法,而且可能会漏掉在同一批文档上评估的工具之间真实存在的差异。If tool A is right on 10 fields where tool B is wrong, and B is right on 2 where A is wrong, the two sided p value is about 0.039. Comparing two overlapping confidence intervals by eye is a weaker test, and it can miss a real difference between tools evaluated on the same documents.
步骤 6:在单元格级别对表格进行评分 Step 6: Score tables at the cell level
表格需要单独评分,因为即使表格包含所有正确值,只要这些值位于错误的单元格中,表格仍然是错的。首先处理合并单元格:将每个行跨度和列跨度展开为完整网格,并在其覆盖的每个位置重复合并后的值;答案键和工具输出都要如此处理。Tables need their own score, because a table can contain every correct value and still be wrong if the values sit in the wrong cells. Merged cells come first: expand every row span and column span into a full grid, repeating the merged value in each position it covers, for both the answer key and the tool's output.
def expand_spans(cells):
"""cells: dicts with row, col, text, and optional rowspan and colspan"""
if not cells:
return []
n_rows = max(c["row"] + c.get("rowspan", 1) for c in cells)
n_cols = max(c["col"] + c.get("colspan", 1) for c in cells)
grid = [[None] * n_cols for _ in range(n_rows)]
for c in cells:
for r in range(c["row"], c["row"] + c.get("rowspan", 1)):
for k in range(c["col"], c["col"] + c.get("colspan", 1)):
grid[r][k] = c["text"]
return grid
然后逐格比较网格,并对两个方向分别评分。召回率能发现遗漏的单元格,精确率则能发现工具额外添加的单元格:Then compare the grids cell by cell and score both directions. Recall catches dropped cells, and precision catches cells the tool added:
def table_cell_scores(expected_rows, predicted_rows, column_kinds=()):
def cells(rows):
out = {}
for i, row in enumerate(rows):
for j, value in enumerate(row):
kind = column_kinds[j] if j < len(column_kinds) else "text"
out[(i, j)] = normalize(value, kind)
return out
expected, predicted = cells(expected_rows), cells(predicted_rows)
matched = sum(1 for pos, v in expected.items()
if pos in predicted and predicted[pos] == v)
precision = matched / len(predicted) if predicted else float(not expected)
recall = matched / len(expected) if expected else 1.0
return precision, recall
这两个分数有意设置得很严格。如果工具漏掉多页表格中的一行,之后的每一行都会错位,召回率便会大幅下降。如果工具添加了页面上不存在的行,精确率便会下降。对于有公开定义的结构指标 TEDS(基于树编辑距离的相似度),它由《基于图像的表格识别:数据、模型与评估》一文提出,旨在捕捉表格识别中的单元格错位和 OCR 错误。Both scores are strict on purpose. If a tool drops one row of a multi page table, every row after it shifts and recall falls sharply. If a tool appends rows that are absent from the page, precision falls. For a structural metric with a published definition, TEDS, the tree edit distance based similarity introduced in Image based table recognition: data, model, and evaluation, was designed to capture cell misalignment and OCR errors in table recognition.
步骤 7:每份文档都要运行多次 Step 7: Run every document more than once
一致性很容易被忽略,却要到生产环境中才发现问题,而且代价高昂。使用每个工具对每份文档运行三到五次,并统计每次都返回相同规范化值的字段数量:Consistency is easy to skip and expensive to discover in production. Run each document three to five times through each tool and measure how many fields return the same normalized value every time:
def consistency(runs, field_kinds):
stable = 0
for field, kind in field_kinds.items():
values = [normalize(run.get(field), kind) for run in runs]
if all(v == values[0] for v in values):
stable += 1
return stable / len(field_kinds) if field_kinds else 1.0
比较归一化后的值在这里也很重要,因为某个工具一次运行返回 1,200.00,下一次返回 1200,实际上两次得到的是同一个值。某个工具五次运行中有四次结果正确,在单次基准测试中看起来表现不错,但在生产规模下仍会持续产生少量错误。Comparing normalized values matters here too, since a tool that returns 1,200.00 on one run and 1200 on the next has produced the same value twice. A tool that is right on four runs out of five will look strong in a single pass benchmark and still produce a steady trickle of errors at production volume.
步骤 8:检查不确定性信号是否有意义 Step 8: Check whether the uncertainty signal means anything
如果工具返回置信度信号,请先测试低分是否确实与错误相对应,再据此构建审核路由。将每个字段的置信度与步骤 4 中的结果配对,并计算各分档的错误率:If a tool returns a confidence signal, test whether low scores actually line up with errors before you build review routing on top of it. Pair each field's confidence with its outcome from Step 4 and compute the error rate per bucket:
def error_rate_by_confidence(rows, edges=(0.0, 0.5, 0.8, 0.95, 1.01)):
"""rows: (confidence, outcome) pairs"""
report = {}
for low, high in zip(edges, edges[1:]):
outcomes = [o for c, o in rows if low <= c < high]
if outcomes:
errors = sum(o != "correct" for o in outcomes)
report[f"[{low}, {high})"] = (len(outcomes), errors / len(outcomes))
return report
一个有用的信号是:置信度越高,错误率越低。应将这些分数视为用于分诊排序的依据,而非正确概率;LandingAI 在其第一代解析输出中也是这样描述置信度分数的。A useful signal shows error rates that fall as confidence rises. Treat the scores as a ranking for triage rather than a probability of correctness, which is also how LandingAI describes the confidence scores in its first generation parse output.
不同工具返回的信号处于不同层级,因此在分桶之前,应先将其对齐到字段。在 ADE 第二代中,DPT-3 Pro 解析模型不返回置信度分数;而目前处于预览阶段的 DPT-3 Verity 模型会为每个词返回一个置信度值。要根据逐词置信度值计算字段级分数,请找出字段源范围所覆盖的词,并取其中最低的置信度。Signals arrive at different levels across tools, so align them to fields before bucketing. In ADE's second generation, the DPT-3 Pro parsing model returns no confidence scores, and the DPT-3 Verity model, currently in Preview, returns a confidence value per word. To get a field level score from per word values, find the words that a field's source ranges cover and take the lowest confidence among them.
步骤 9:验证提取的数据可追溯,以便审计 Step 9: Verify that extracted data is traceable for audits
要验证提取的数据能否经受审计,意味着要检查每个值是否都能追溯到其确切来源。对于每个提取字段,记录工具是否返回了来源位置(例如页码和边界框,或在解析文本中的偏移量),以及该位置是否确实包含该值。手动抽查一部分数据,因为指向错误区域的位置会误导审核人员。Verifying that extracted data will hold up in an audit means checking that every value can be traced to the exact place it came from. For each extracted field, record whether the tool returns a source location, such as a page and a bounding box or an offset into the parsed text, and whether that location actually contains the value. Spot check a sample by hand, since a location that points at the wrong region misleads the reviewer.
按字段将其评为通过或失败,并将这一结果放在准确性旁边,而不是归入准确性。一个值的位置可能有效,但值本身仍可能错误,例如取自上一行的数字;因此,可追溯性让错误能够得到核查,也将准确性的判断留给其他步骤。Score it as pass or fail per field and keep it next to accuracy rather than inside it. A value with a valid location can still be the wrong value, such as a number taken from the row above, so traceability makes errors checkable and leaves accuracy to the other steps.
为受监管文档提取设定准确率目标 Setting an accuracy target for regulated document extraction
受监管工作流所需的准确率取决于每个字段出错所造成的成本,因此各字段的要求并不相同。KYC 文件中的错误账号和附函中的错误页数,后果截然不同;用一个统一的目标值会掩盖这种差异。The accuracy rate a regulated workflow needs comes from the cost of an error on each field, so it differs from field to field. A wrong account number in a KYC file and a wrong page count in a cover letter carry very different consequences, and one blended target hides that difference.
与合规团队一起为每个字段设定目标,然后按照步骤 4 中的间隔,将基准值维持在该目标水平:Set the target per field with your compliance team, then hold the benchmark to it with the interval from Step 4:
- 准确率:当其 Wilson 区间的下限达到或高于目标值时,该字段即满足目标,而非依据点估计值。Accuracy: a field meets its target when the lower bound of its Wilson interval sits at or above the target, rather than the point estimate
- 虚构值:针对影响决策的字段,单独设定虚构率上限,并将其与该比率区间的上界进行比较。Invented values: set a separate ceiling for the invented rate on the fields that drive decisions, and compare it against the upper bound of that rate's interval
- 审核覆盖范围:确定哪些字段无论评分如何都必须交由人工审核,例如标识符、金额和签名;并根据各工具提供的来源位置,衡量审核人员处理每个字段所需的时间。Review coverage: decide which fields always go to a person regardless of score, such as identifiers, amounts, and signatures, and measure the time a reviewer needs per field using each tool's source locations
报告结果 Reporting the results
报告应将每个维度分别列出,以便决策者清楚地看到其中的权衡:The report should keep every dimension separate, so the tradeoffs stay visible to whoever makes the decision:
| Metric | How it is computed | What it tells you |
|---|---|---|
| Field accuracy | Correct outcomes divided by documents containing the field, with a Wilson interval | Which fields each tool handles reliably |
| Paired difference | McNemar's exact test on fields where the tools disagree | Whether one tool is reliably better on a field |
| Invented rate | Invented outcomes divided by fields the key marks empty | How often a tool fills gaps with plausible values |
| Table precision and recall | Cells matched by position after expanding merged cells | Whether table structure survives extraction |
| Consistency | Fields returning the same normalized value across runs | How much variance to expect at volume |
| Traceability | Fields with a source location that contains the value | How quickly reviewers and auditors can verify output |
按文档类型和来源质量拆分各项指标。报告单一总体数值时,应根据各分层在生产量中的占比进行加权,因为测试集有意对困难案例进行了过度抽样,简单平均会错误反映生产环境中的实际情况。Break each metric down by document type and source quality. When you report a single overall number, weight each stratum by its share of production volume, since the test set deliberately oversamples hard cases and a plain average misstates what production will see.
运行基准测试前要向供应商提出的问题 Questions to ask vendors before you run the benchmark
这套评估框架还为 CTO 提供了一份具体的问题清单,用于评估面向受监管环境部署的供应商,因为每个步骤都依赖于供应商的输出能够提供相应支持:The harness also gives a CTO a concrete list of questions for vendors evaluated for regulated deployments, because each step depends on something the vendor's output has to support:
- 缺失:当页面上的字段没有值时,API 会返回什么?Schema 是否可以将字段标记为可空?Absence: what does the API return when a field has no value on the page, and can the schema mark fields as nullable
- 来源位置:每个提取出的值是否都附带页码、边界框或在解析文本中的偏移量?系统计算或重新格式化的值又如何处理?Source locations: does every extracted value come with a page, a bounding box, or an offset into the parsed text, and what happens to values the system computes or reformats
- 表格:输出中如何表示合并单元格以及跨页延续的表格?Tables: how are merged cells and tables that continue across pages represented in the output
- 不确定性:是否存在置信度信号、它适用于哪个层级,以及哪些模型或特征会返回该信号Uncertainty: is there a confidence signal, at what level does it apply, and which models or features return it
- 稳定性:如何锁定模型版本,确保供应商发布更新后,基准测试结果仍然有效Stability: how are model versions pinned, so a benchmark result stays valid after the vendor ships an update
- 数据处理:基准测试在生产文档上运行时,适用哪些数据保留和部署选项Data handling: which retention and deployment options apply when the benchmark runs on production documents
ADE 在这个测试框架中的定位 Where ADE fits in this harness
ADE 对应上述多个步骤。Build Schema 涵盖步骤 2:根据示例文档生成提取架构并保留版本历史记录,从而确保每个工具都基于同一份已冻结的定义运行。在解析方面,ADE 默认以 HTML 格式返回表格,以保留合并单元格;每个表格单元格块还会附带其网格位置和跨行、跨列的数量,这些信息对应于步骤 6 中 expand_spans 所需的输入。ADE maps onto several of the steps above. Build Schema covers Step 2, generating the extraction schema from sample documents and keeping a version history, so every tool runs against the same frozen definition. On the parse side, ADE returns tables as HTML by default so merged cells survive, and each table cell block carries its grid position and span counts, which map onto the inputs expand_spans expects in Step 6.
对于第 9 步,ADE 的 Extract 元数据会为每个返回值附上其在解析后的 Markdown 中对应的字符偏移量。如果 Extract 推导出某个值,而不是逐字提取,例如计算得出的总数或文档级摘要,那么这些偏移量将返回为 null。For Step 9, ADE's Extract metadata pairs every returned value with character offsets into the parsed Markdown. When Extract derives a value instead of lifting it verbatim, for example a computed total or a document level summary, those offsets come back as null.
将已填充但偏移量为 null 的字段视为没有逐字来源的值,并送交审核;然后,在将你自行重新格式化的字段(例如转换为标准格式的日期)作为不利案例计入该工具的评估之前,先检查它们的表现。Treat a populated field with null offsets as a value with no verbatim source and send it to review, then check how your own reformatted fields, such as dates converted to a standard format, behave before you count them against the tool.
对于页面级检查,Ground API 会将提取元数据与解析结果合并,并返回每个字段对应的区块、页面和边界框。为提升速度,也可以跳过定位阶段来运行提取;但基准测试时应保持该阶段启用,因为跳过后每个值的范围都会返回为 null。For page level checks, the Ground API joins the extraction metadata with the parse output and returns the blocks, pages, and bounding boxes behind each field. Extraction can also run with the grounding stage skipped for speed, so keep it enabled for benchmark runs, since skipping it returns null ranges for every value.
若想了解如何发布可供他人复现的基准测试,LandingAI 的 DocVQA 基准测试说明是一个很好的范例。For a reference on how to publish a benchmark that others can reproduce, LandingAI's DocVQA benchmark write up is a useful model.
DocVQA 是一个问答基准,而不是字段提取基准;该博文报告称,在其验证集上准确率达到 99.16%,答案根据解析后的输出生成,且未使用页面图像。值得借鉴的是其方法:评估代码已在 GitHub 上公开,博文还列出了全部 45 个错误案例,并为每个案例进行了分类,读者可以据此自行判断这些失败之处。DocVQA is a question answering benchmark rather than a field extraction one, and the post reports 99.16 percent accuracy on its validation split, with answers generated from parsed output and no access to the page images. The part worth copying is the method: the evaluation code is public on GitHub, and the post includes a gallery of all 45 errors with a classification for each, so readers can judge the failures themselves.
如果你需要将这一流程用于采购决策,而非工程测试框架,那么用于测试提取准确率的供应商对比评估指南涵盖的内容与评分卡相同,而且无需编写代码。If you need a version of this process for a procurement decision rather than an engineering harness, the vendor bake off guide for testing extraction accuracy covers the same ground as a scorecard, with no code required.
常见问题 FAQ
目前有哪些最准确的文档提取 API?What are the most accurate document extraction APIs available today?
答案取决于你的文档,因为已公布的准确率数据来自各供应商自行选取的数据集。使用你自己的生产文件构建基准测试来评估候选工具,分别对字段、表格、一致性和可追溯性进行评分,并通过配对测试比较各工具。The answer depends on your documents, since published accuracy figures come from datasets each vendor selected. Run the candidates through a benchmark built from your own production files, score fields, tables, consistency, and traceability separately, and compare tools with a paired test.
如何比较领先供应商的文档智能准确性?How do you compare document intelligence accuracy across leading vendors?
让每个供应商都使用同一套测试集、同一份固定的 schema 和答案键进行测试,按字段类型对值进行规范化,并针对工具结果不一致的案例,逐字段使用 McNemar 精确检验进行比较。Run every vendor on the same test set with the same frozen schema and answer key, normalize values by field type, and compare tools field by field with McNemar's exact test on the cases where they disagree.
受监管文档提取需要达到多高的准确率?What accuracy rate do you need for regulated document extraction?
根据字段出错的代价,为每个字段设定目标,并要求该字段置信区间的下界达到该目标。对于会影响决策的字段,另行设定虚构值的上限。Set the target per field based on the cost of an error on that field, then require the lower bound of the field's confidence interval to meet it. Add a separate ceiling for invented values on fields that drive decisions.
如何验证提取的数据符合审计要求?How do you verify extracted data is audit compliant?
检查每个提取出的值是否都附带来源位置,例如页面坐标或文本偏移量,并确认该位置确实包含该值。将此项与准确性一起按字段评分,因为即使某个值可追溯,也仍可能是错误的。Check that every extracted value comes with a source location, like page coordinates or a text offset, and that the location actually contains the value. Score this per field alongside accuracy, since a value can be traceable and still wrong.
CTO 在评估面向受监管行业的文档 AI 供应商时,应该提出哪些问题?What questions should a CTO ask when evaluating document AI vendors for regulated industries?
询问 API 如何表示缺失值、每个值是否都带有来源位置、合并表格和跨页表格会以何种形式返回、有哪些置信度信号及其对应的层级、如何固定模型版本,以及适用哪些数据保留和部署选项。Ask how the API represents missing values, whether every value carries a source location, how merged and multi page tables come back, what confidence signal exists and at what level, how model versions are pinned, and which data retention and deployment options apply.
为什么除了召回率,还要评估评分表的精确率?Why score table precision as well as recall?
仅看召回率无法反映工具额外添加的单元格。一个工具如果返回所有真实行,再加上页面中不存在的三行,召回率仍然会满分,而精确率才能揭示这一点。Recall alone ignores cells the tool added. A tool that returns every real row plus three rows absent from the page would score perfectly on recall, and precision is what exposes it.