你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
文档布局技能分析文档以检测结构和特征,并使用 Markdown 或文本格式生成文档的语法表示形式。 可以使用它提取文本和图像,其中图像提取包括保留文档中图像位置的位置元数据。 图像接近相关内容有利于检索扩充生成(RAG)工作负载和 多模式搜索 方案。
本文是文档布局技能的参考文档。 有关使用信息,请参阅 如何按文档布局分块和向量化。
此技能使用 Azure AI 文档智能中提供的文档智能布局模型。
对于每天超过 20 个文档的事务,此技能绑定到 可计费的 Azure AI 多服务资源 。 执行内置技能按现有的 Azure AI 服务标准价格收费。
Limitations
此技能具有以下限制:
该技能不适用于在 AI 文档智能布局模型中需要 5 分钟以上的处理的大型文档。 技能超时,但如果 AI Services 多服务资源附加到技能集,则费用仍适用于计费目的。 确保文档经过优化,以保持在处理限制范围内,以避免不必要的成本。
由于此技能调用 Azure AI 文档智能布局模型, 因此适用于不同文件类型的不同文档类型的所有记录服务行为 都应用于其输出。 例如,Word (DOCX) 和 PDF 文件可能会产生不同的结果,因为处理图像的方式存在差异。 如果需要跨 DOCX 和 PDF 的一致图像行为,请考虑将文档转换为 PDF 或查看 多模式搜索文档 以获取替代方法。
支持的区域
文档布局技能调用 文档智能 2024-11-30 API。
支持的区域因形式而异,技能如何连接到文档智能布局模型。
| Approach | Requirement |
|---|---|
| 导入数据(新建) 向导 | 在以下区域之一创建 Azure AI 多服务资源,以获取门户体验: 美国东部、 西欧、 美国中北部。 |
| 编程方式,使用 Microsoft Entra ID 身份验证(预览版) 进行计费 | 根据 产品可用性(按区域)在支持服务的某个区域中创建 Azure AI 搜索。 按区域表在产品可用性中列出的任何区域中创建 Azure AI 多服务资源。 |
| 编程方式,使用 多服务资源 API 密钥 进行计费 | 在同一区域中创建 Azure AI 搜索服务和 AI 多服务资源。 这意味着所选区域必须同时支持 Azure AI 搜索和 Azure 文档智能服务。 |
支持的文件格式
此技能可识别以下文件格式。
- .JPEG
- .JPG
- .PNG
- .BMP
- .TIFF
- .DOCX
- .XLSX
- .PPTX
- .HTML
支持的语言
有关打印文本,请参阅 Azure AI 文档智能布局模型支持的语言。
@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 已锁定密码,请在运行索引器之前删除该锁。
技能参数
参数区分大小写。 REST API 的特定预览版本中引入了多个参数。 建议使用正式版(2025-09-01)或最新预览版(2025-08-01-preview),以完全访问所有参数。
| 参数名称 | 允许的值 | Description |
|---|---|---|
outputMode |
oneToMany |
控制技能生成的输出的基数。 |
markdownHeaderDepth |
h1、、h2h3、h4、h5、h6(default) |
仅当将 outputFormat 设置为 markdown 时才适用。 此参数描述应考虑的最深层嵌套级别。 例如,如果 markdownHeaderDepth 是 h3,则任何更深的部分(例如 h4)将滚动到 h3其中。 |
outputFormat |
markdown(default)、text |
New. 控制技能生成的输出的格式。 |
extractionOptions |
["images"]、["images", "locationMetadata"]、["locationMetadata"] |
New. 标识从文档中提取的任何额外内容。 定义一个枚举数组,这些枚举对应于要包含在输出中的内容。 例如,如果为,extractionOptions["images", "locationMetadata"]则输出包括图像和位置元数据,这些图像和位置元数据提供与内容提取位置相关的页面位置信息,例如页码或分区。 此参数适用于两种输出格式。 |
chunkingProperties |
请参阅下文。 |
New. 仅当将 outputFormat 设置为 text 时才适用。 封装如何在重新计算其他元数据时对文本内容进行分块的选项。 |
| ChunkingProperties 参数 | Version | 允许的值 | Description |
|---|---|---|---|
unit |
Characters。 当前唯一允许的值。 区块长度以字符表示,而不是单词或标记 |
New. 控制 chunk unit 的基数。 | |
maximumLength |
300-50000 之间的任意整数 | New. 由 String.Length 度量的最大区块长度(以字符为单位)。 | |
overlapLength |
Integer. 该值需要小于其中一半 maximumLength |
New. 在两个文本块之间提供的重叠长度。 |
技能输入
| 输入名称 | 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和的sastokenJSON 对象定义的自定义技能。 参数$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。
文本输出模式和图像和元数据提取示例
此示例演示如何输出固定大小的区块中的文本内容,以及如何从文档中提取图像以及位置元数据。
文本输出模式和图像和元数据提取的示例定义
{
"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": []
},
{
"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": []
}
],
"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}]]"
}
}
]
}
请注意, “sections” 上面的示例输出显示为空白。 若要填充它们,需要添加一个配置有 outputFormat 设置的其他技能,以确保 markdown正确填充这些分区。
该技能使用 Azure AI 文档智能 来计算 locationMetadata。 有关如何定义页面和边界多边形坐标的详细信息,请参阅 文档智能布局模型 。
表示 imagePath 存储图像的相对路径。 如果在技能集中配置了知识存储文件投影,则此路径与知识存储中存储的图像的相对路径匹配。