注释
此功能目前处于公开预览状态。 此预览版在提供时未附带服务级别协议,建议不要用于生产工作负载。 某些功能可能不受支持或者受限。 有关详细信息,请参阅适用于 Azure 预览版的补充使用条款。
文档布局技能分析文档以提取感兴趣的区域及其相互关系,以使用 Markdown 或 Text 格式生成文档的语法表示形式。 可以使用它提取文本和图像。 图像提取包括保留文档中图像位置的位置元数据。 图像接近相关内容更适用于检索扩充生成(RAG)工作负载和 多模式搜索。
本文是文档布局技能的参考文档。 有关使用信息,请参阅 结构感知分块和向量化。
通常将此技能用于具有结构和图像的 PDF 等内容。 以下教程演示了几种方案:
支持的区域
文档布局技能调用 文档智能公共预览版 2024-07-31-preview。
支持的区域因形式而异:
使用 AI 服务密钥通过 REST API 将多服务资源附加到技能集 时,Azure AI 搜索服务和 AI 多服务资源必须位于同一区域。 只能在 中国东部、中国北部、 中国北部、 中国北部、 中国北部 2 的 Azure 区域执行此作。 但是,如果使用托管标识通过无密钥连接计费,Azure AI 搜索服务必须位于以下区域之一:中国东部、中国北部、中国北部、中国北部 2。 另一方面,可以通过 Azure AI 多服务资源在提供此服务的任何区域中使用 AI 文档智能。 请参阅 产品可用性(按区域)。
在 Azure 门户中的 “导入和矢量化数据向导 ”中,可以在数据源连接步骤中启用文档布局检测。 门户中的文档布局检测在以下 Azure 区域中可用:中国东部、中国北部、中国北部。 在这三个区域中之一创建 Azure AI 多服务资源,以获取门户体验。
支持的文件格式
此技能可识别以下文件格式。
- PDF。
- .JPEG
- .JPG
- .PNG
- .BMP
- .TIFF
- .DOCX
- .XLSX
- .PPTX
- HTML。
支持的参数
有几个参数是特定于版本的。 技能参数表记下了引入参数的 API 版本,以便了解是否需要版本升级。 若要在 2025-05-01-preview REST API 中使用特定于版本的功能(例如图像和位置元数据提取),可以使用 Azure 门户或面向 REST API 版本,或检查 Azure SDK 更改日志,以查看它是否支持该功能。
Azure 门户支持大多数预览功能,并可用于创建或更新技能组。 若要更新文档布局技能,请编辑技能集 JSON 定义以添加新预览参数。
@odata.type
Microsoft.Skills.Util.DocumentIntelligenceLayoutSkill
数据限制
- 对于 PDF 和 TIFF,最多可处理 2,000 页(对于免费层订阅,仅处理前两页)。
- 即使分析文档的文件大小是 500 MB(对于 Azure AI 文档智能付费层)层,对于 Azure AI 文档智能免费层(F0)层为 4 MB,索引编制仍受搜索服务层的索引器限制的约束。
- 图像尺寸必须介于 50 x 50 像素或 10,000 像素 x 10,000 像素之间。
- 如果 PDF 已锁定密码,请在运行索引器之前删除该锁。
支持的语言
有关打印文本,请参阅 Azure AI 文档智能布局模型支持的语言。
局限性
在公共预览版期间,此技能具有以下限制:
- 该技能不适用于在 AI 文档智能布局模型中需要 5 分钟以上的处理的大型文档。 技能超时,但如果 AI Services 多服务资源附加到技能集,则费用仍适用于计费目的。 确保文档经过优化,以保持在处理限制范围内,以避免不必要的成本。
技能参数
参数区分大小写。
参数名称 | 允许的值 | DESCRIPTION |
---|---|---|
outputMode |
oneToMany |
控制技能生成的输出的基数。 |
markdownHeaderDepth |
h1 、h2 、h3 、h4 、h5 、h6(default) |
此参数描述应考虑的最深层嵌套级别。 例如,如果 markdownHeaderDepth 指示为“h3”,则任何大于 h3(即 #### 和更深)的 markdown 节都被视为需要添加到其父级所处级别的“内容”。 |
技能输入
输入名称 | DESCRIPTION |
---|---|
file_data |
应从其中提取内容的文件。 |
“file_data”必须是按如下所示定义的对象:
{
"$type": "file",
"data": "BASE64 encoded string of the file"
}
或者,可将其定义为:
{
"$type": "file",
"url": "URL to download file",
"sasToken": "OPTIONAL: SAS token for authentication if the URL provided is for a file in blob storage"
}
可以通过以下方法之一生成文件引用对象:
将
allowSkillsetToReadFileData
索引器定义上的参数设置为 true。 此设置创建一个路径,该路径/document/file_data
表示从 Blob 数据源下载的原始文件数据。 此参数仅适用于 Azure Blob 存储中的文件。具有返回提供
$type
、data
或url
和的sastoken
JSON 对象定义的自定义技能。 参数$type
必须设置为file
,并且data
必须是文件内容的 base 64 编码字节数组。 该url
参数必须是一个有效的 URL,可访问该位置下载文件。
技能输出
输出名称 | DESCRIPTION |
---|---|
markdown_document |
仅当将 outputFormat 设置为 markdown 时才适用。 “节”对象的集合,这些对象表示 Markdown 文档中每个单独的节。 |
text_sections |
仅当将 outputFormat 设置为 text 时才适用。 文本区块对象的集合,该对象表示页面边界内的文本(考虑配置了更多分块), 包括 任何节标题本身。 文本区块对象包括 locationMetadata (如果适用)。 |
normalized_images |
仅当设置为outputFormat 和text 包括extractionOptions 时images 适用。 从文档中提取的图像集合,包括 locationMetadata (如果适用)。 |
Markdown 输出模式的示例定义
{
"skills": [
{
"description": "Analyze a document",
"@odata.type": "#Microsoft.Skills.Util.DocumentIntelligenceLayoutSkill",
"context": "/document",
"outputMode": "oneToMany",
"markdownHeaderDepth": "h3",
"inputs": [
{
"name": "file_data",
"source": "/document/file_data"
}
],
"outputs": [
{
"name": "markdown_document",
"targetName": "markdown_document"
}
]
}
]
}
Markdown 输出模式的示例输出
{
"markdown_document": [
{
"content": "Hi this is Jim \r\nHi this is Joe",
"sections": {
"h1": "Foo",
"h2": "Bar",
"h3": ""
},
"ordinal_position": 0
},
{
"content": "Hi this is Lance",
"sections": {
"h1": "Foo",
"h2": "Bar",
"h3": "Boo"
},
"ordinal_position": 1,
}
]
}
控制“节”字典中的键数的值 markdownHeaderDepth
。 在示例技能定义中,由于 markdownHeaderDepth
“h3”为“h3”,“节”字典中有三个键:h1、h2、h3。
文本输出模式和图像和元数据提取示例
此示例演示如何使用 2025-05-01-preview 中引入的新参数输出固定大小的区块中的文本内容,以及文档的位置元数据。
文本输出模式和图像和元数据提取的示例定义
{
"skills": [
{
"description": "Analyze a document",
"@odata.type": "#Microsoft.Skills.Util.DocumentIntelligenceLayoutSkill",
"context": "/document",
"outputMode": "oneToMany",
"outputFormat": "text",
"extractionOptions": ["images", "locationMetadata"],
"chunkingProperties": {
"unit": "characters",
"maximumLength": 2000,
"overlapLength": 200
},
"inputs": [
{
"name": "file_data",
"source": "/document/file_data"
}
],
"outputs": [
{
"name": "text_sections",
"targetName": "text_sections"
},
{
"name": "normalized_images",
"targetName": "normalized_images"
}
]
}
]
}
文本输出模式和图像和元数据提取的示例输出
{
"text_sections": [
{
"id": "1_7e6ef1f0-d2c0-479c-b11c-5d3c0fc88f56",
"content": "the effects of analyzers using Analyze Text (REST). For more information about analyzers, see Analyzers for text processing.During indexing, an indexer only checks field names and types. There's no validation step that ensures incoming content is correct for the corresponding search field in the index.Create an indexerWhen you're ready to create an indexer on a remote search service, you need a search client. A search client can be the Azure portal, a REST client, or code that instantiates an indexer client. We recommend the Azure portal or REST APIs for early development and proof-of-concept testing.Azure portal1. Sign in to the Azure portal 2, then find your search service.2. On the search service Overview page, choose from two options:· Import data wizard: The wizard is unique in that it creates all of the required elements. Other approaches require a predefined data source and index.All services > Azure Al services | Al Search >demo-search-svc Search serviceSearchAdd indexImport dataImport and vectorize dataOverviewActivity logEssentialsAccess control (IAM)Get startedPropertiesUsageMonitoring· Add indexer: A visual editor for specifying an indexer definition.",
"locationMetadata": {
"pageNumber": 1,
"ordinalPosition": 0,
"boundingPolygons": "[[{\"x\":1.5548,\"y\":0.4036},{\"x\":6.9691,\"y\":0.4033},{\"x\":6.9691,\"y\":0.8577},{\"x\":1.5548,\"y\":0.8581}],[{\"x\":1.181,\"y\":1.0627},{\"x\":7.1393,\"y\":1.0626},{\"x\":7.1393,\"y\":1.7363},{\"x\":1.181,\"y\":1.7365}],[{\"x\":1.1923,\"y\":2.1466},{\"x\":3.4585,\"y\":2.1496},{\"x\":3.4582,\"y\":2.4251},{\"x\":1.1919,\"y\":2.4221}],[{\"x\":1.1813,\"y\":2.6518},{\"x\":7.2464,\"y\":2.6375},{\"x\":7.2486,\"y\":3.5913},{\"x\":1.1835,\"y\":3.6056}],[{\"x\":1.3349,\"y\":3.9489},{\"x\":2.1237,\"y\":3.9508},{\"x\":2.1233,\"y\":4.1128},{\"x\":1.3346,\"y\":4.111}],[{\"x\":1.5705,\"y\":4.5322},{\"x\":5.801,\"y\":4.5326},{\"x\":5.801,\"y\":4.7311},{\"x\":1.5704,\"y\":4.7307}]]"
},
"sections": ["sectionHeading"]
},
{
"id": "2_25134f52-04c3-415a-ab3d-80729bd58e67",
"content": "All services > Azure Al services | Al Search >demo-search-svc | Indexers Search serviceSearch0«Add indexerRefreshDelete:selected: TagsFilter by name ...:selected: Diagnose and solve problemsSearch managementStatusNameIndexesIndexers*Data sourcesRun the indexerBy default, an indexer runs immediately when you create it on the search service. You can override this behavior by setting disabled to true in the indexer definition. Indexer execution is the moment of truth where you find out if there are problems with connections, field mappings, or skillset construction.There are several ways to run an indexer:· Run on indexer creation or update (default).. Run on demand when there are no changes to the definition, or precede with reset for full indexing. For more information, see Run or reset indexers.· Schedule indexer processing to invoke execution at regular intervals.Scheduled execution is usually implemented when you have a need for incremental indexing so that you can pick up the latest changes. As such, scheduling has a dependency on change detection.Indexers are one of the few subsystems that make overt outbound calls to other Azure resources. In terms of Azure roles, indexers don't have separate identities; a connection from the search engine to another Azure resource is made using the system or user- assigned managed identity of a search service. If the indexer connects to an Azure resource on a virtual network, you should create a shared private link for that connection. For more information about secure connections, see Security in Azure Al Search.Check results",
"locationMetadata": {
"pageNumber": 2,
"ordinalPosition": 1,
"boundingPolygons": "[[{\"x\":2.2041,\"y\":0.4109},{\"x\":4.3967,\"y\":0.4131},{\"x\":4.3966,\"y\":0.5505},{\"x\":2.204,\"y\":0.5482}],[{\"x\":2.5042,\"y\":0.6422},{\"x\":4.8539,\"y\":0.6506},{\"x\":4.8527,\"y\":0.993},{\"x\":2.5029,\"y\":0.9845}],[{\"x\":2.3705,\"y\":1.1496},{\"x\":2.6859,\"y\":1.15},{\"x\":2.6858,\"y\":1.2612},{\"x\":2.3704,\"y\":1.2608}],[{\"x\":3.7418,\"y\":1.1709},{\"x\":3.8082,\"y\":1.171},{\"x\":3.8081,\"y\":1.2508},{\"x\":3.7417,\"y\":1.2507}],[{\"x\":3.9692,\"y\":1.1445},{\"x\":4.0541,\"y\":1.1445},{\"x\":4.0542,\"y\":1.2621},{\"x\":3.9692,\"y\":1.2622}],[{\"x\":4.5326,\"y\":1.2263},{\"x\":5.1065,\"y\":1.229},{\"x\":5.106,\"y\":1.346},{\"x\":4.5321,\"y\":1.3433}],[{\"x\":5.5508,\"y\":1.2267},{\"x\":5.8992,\"y\":1.2268},{\"x\":5.8991,\"y\":1.3408},{\"x\":5.5508,\"y\":1.3408}]]"
},
"sections": ["sectionHeading", "title"]
}
],
"normalized_images": [
{
"id": "1_550e8400-e29b-41d4-a716-446655440000",
"data": "SGVsbG8sIFdvcmxkIQ==",
"imagePath": "aHR0cHM6Ly9henNyb2xsaW5nLmJsb2IuY29yZS53aW5kb3dzLm5ldC9tdWx0aW1vZGFsaXR5L0NyZWF0ZUluZGV4ZXJwNnA3LnBkZg2/normalized_images_0.jpg",
"locationMetadata": {
"pageNumber": 1,
"ordinalPosition": 0,
"boundingPolygons": "[[{\"x\":2.0834,\"y\":6.2245},{\"x\":7.1818,\"y\":6.2244},{\"x\":7.1816,\"y\":7.9375},{\"x\":2.0831,\"y\":7.9377}]]"
}
},
{
"id": "2_123e4567-e89b-12d3-a456-426614174000",
"data": "U29tZSBtb3JlIGV4YW1wbGUgdGV4dA==",
"imagePath": "aHR0cHM6Ly9henNyb2xsaW5nLmJsb2IuY29yZS53aW5kb3dzLm5ldC9tdWx0aW1vZGFsaXR5L0NyZWF0ZUluZGV4ZXJwNnA3LnBkZg2/normalized_images_1.jpg",
"locationMetadata": {
"pageNumber": 2,
"ordinalPosition": 1,
"boundingPolygons": "[[{\"x\":2.0784,\"y\":0.3734},{\"x\":7.1837,\"y\":0.3729},{\"x\":7.183,\"y\":2.8611},{\"x\":2.0775,\"y\":2.8615}]]"
}
}
]
}
该技能使用 Azure AI 文档智能 来计算 locationMetadata。 有关如何定义页面和边界多边形坐标的详细信息,请参阅 文档智能布局模型 。
表示 imagePath
存储图像的相对路径。 如果在技能集中配置了知识存储文件投影,则此路径与知识存储中存储的图像的相对路径匹配。