你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。

文档布局技能

注释

Azure AI 搜索可通过Azure门户、REST API 和Azure SDK获取。 它还支持 Foundry IQ,该知识层将企业内容转换为 Microsoft Foundry 门户中代理的可重用权限感知知识库。

文档布局技能使用 Foundry Tools 中的 Azure 文档智能中的布局模型来分析文档、检测其结构和特征,以及以 Markdown 或文本格式生成语法表示形式。 此技能支持文本和图像提取,后者包括保留文档中图像位置的位置元数据。 图像接近相关内容有利于检索扩充生成(RAG)和 多模式搜索 方案。

对于每天超过 20 个文档的事务,此技能要求将 计费Microsoft Foundry 资源附加到 技能组。 执行内置技能按现有的 Foundry 工具标准价格收费。

本文是文档布局技能的参考文档。 有关使用信息,请参阅 如何按文档布局分块和向量化。

Tip

通常将此技能用于具有结构和图像的内容,例如 PDF。 多模式教程演示了使用两种不同的数据分块策略进行图像语言化。

局限性

此技能具有以下限制:

  • 该技能不适用于需要在 Azure 文档智能布局模型中处理 5 分钟以上的大型文档。 技能超时,但费用仍适用于 Foundry 资源(如果附加到技能集以用于计费目的)。 确保文档经过优化,以保持在处理限制范围内,以避免不必要的成本。

  • 由于此技能调用 Azure 文档智能布局模型, 因此不同文件类型的不同文档类型的所有记录服务行为 都应用于其输出。 例如,Word (DOCX) 和 PDF 文件可能会产生不同的结果,因为处理图像的方式存在差异。 如果需要跨 DOCX 和 PDF 的一致图像行为,请考虑将文档转换为 PDF 或查看 多模式搜索文档 以获取替代方法。

支持的区域

文档布局技能调用 Azure 文档智能 REST API 的 v4.0 (2024-11-30)。

支持的区域因形式而异,技能如何连接到 Azure 文档智能布局模型。 目前,实现的布局模型版本不支持 世纪互联 区域。

方法 要求
导入数据 向导 在以下区域之一创建 Azure AI 搜索服务和 Azure AI 多服务帐户 :美国东部、西欧 2 或美国中北部。
编程方式,使用 Microsoft Foundry 资源密钥 进行计费 在同一区域中创建 Azure AI 搜索服务和Microsoft Foundry 资源。 该区域必须同时支持 Azure AI 搜索和 Azure 文档智能。
使用Microsoft Entra ID身份验证进行计费编程 没有相同的区域要求。 在 每个服务可用的任何区域中创建 Azure AI 搜索服务和Microsoft Foundry 资源。

支持的文件格式

此技能可识别以下文件格式:

  • .PDF
  • .JPEG
  • .JPG
  • .PNG
  • .BMP
  • .TIFF
  • .DOCX
  • .XLSX
  • .PPTX
  • .HTML

支持的语言

有关打印文本,请参阅 Azure 文档智能布局模型支持的语言。

@odata.type

Microsoft.Skills.Util.DocumentIntelligenceLayoutSkill

数据限制

  • 对于 PDF 和 TIFF,最多可以处理 2,000 页(使用免费层订阅,只处理前两页)。
  • 即使分析文档的文件大小是 500 MB(对于 Azure 文档智能付费层)和 4 MB 的 Azure 文档智能免费层(F0)层,索引也会受到搜索服务层的 索引器限制 。
  • 图像尺寸必须介于 50 x 50 像素或 10,000 像素 x 10,000 像素之间。
  • 如果 PDF 已锁定密码,请在运行索引器之前删除该锁。

技能参数

参数区分大小写。

参数名称 允许的值 说明
outputMode oneToMany 控制技能生成的输出的基数。
markdownHeaderDepth h1、、h2h3、h4、h5、 h6 (默认值) 仅当 outputFormat 设置为 markdown. 此参数描述应考虑的最深层嵌套级别。 例如,如果是markdownHeaderDepthh3,则更深入的任何部分(例如h4)将滚动到h3其中。
outputFormat markdown(默认)、text 控制技能生成的输出的格式。
extractionOptions ["images"]、 ["images", "locationMetadata"]、、 ["locationMetadata"] 标识从文档中提取的任何额外内容。 定义一个枚举数组,这些枚举对应于要包含在输出中的内容。 例如,如果 extractionOptions 为 ["images", "locationMetadata"],输出包括图像和位置元数据,这些图像和位置元数据提供与提取内容的位置相关的页面位置信息,例如页码或分区。 此参数适用于两种输出格式。
chunkingProperties 请参阅下表。 仅当 outputFormat 设置为 text. 封装如何在重新计算其他元数据时对文本内容进行分块的选项。
chunkingProperties 参数 允许的值 说明
unit characters 控制区块单元的基数。 区块长度以字符表示,而不是单词或标记。
maximumLength 介于 300 和 50000 之间的整数。 由 String.Length 度量的最大区块长度(以字符为单位)。
overlapLength 一个小于一半的 maximumLength整数。 两个文本区块之间提供的重叠长度。

技能输入

输入名称 说明
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 存储中的文件。

    allowSkillsetToReadFileData 使下载的文件数据可供技能使用。 它不会增加 Blob 索引器限制 或 数据限制中所述的文档智能限制。

  • 具有返回提供 $type、 data或 url 和的 sastokenJSON 对象定义的自定义技能。 参数 $type 必须设置为 file,并且 data 必须是文件内容的 base 64 编码字节数组。 该 url 参数必须是一个有效的 URL,可访问该位置下载文件。

技能输出

输出名称 说明
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 文档智能 来计算 locationMetadata。 有关如何定义页面和边界多边形坐标的详细信息,请参阅 Azure 文档智能布局模型 。

表示 imagePath 存储图像的相对路径。 如果在技能集中配置了知识存储文件投影,则此路径与知识存储中存储的图像的相对路径匹配。