您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

将认知服务资源附加到 Azure 中的技能组合认知搜索Attach a Cognitive Services resource to a skillset in Azure Cognitive Search

在 Azure 认知搜索中配置扩充管道时,可以免费扩充有限数量的文档。When configuring an enrichment pipeline in Azure Cognitive Search, you can enrich a limited number of documents free of charge. 对于更大、更频繁的工作负荷,应附加一个可计费认知服务资源。For larger and more frequent workloads, you should attach a billable Cognitive Services resource.

在本文中,你将了解如何通过为定义扩充管道的技能组合分配密钥来附加资源。In this article, you'll learn how to attach a resource by assigning a key to a skillset that defines an enrichment pipeline.

扩充期间使用的资源Resources used during enrichment

Azure 认知搜索依赖于认知服务,其中包括图像分析和光学字符识别(OCR)的计算机视觉、自然语言处理文本分析,以及文本翻译等其他根据。Azure Cognitive Search has a dependency on Cognitive Services, including Computer Vision for image analysis and optical character recognition (OCR), Text Analytics for natural language processing, and other enrichments like Text Translation. 在 Azure 认知搜索中的扩充的上下文中,这些 AI 算法在技能组合中进行包装,并在索引期间由索引器引用。In the context of enrichment in Azure Cognitive Search, these AI algorithms are wrapped inside a skill, placed in a skillset, and referenced by an indexer during indexing.

计费原理How billing works

  • Azure 认知搜索使用技能组合上提供的认知服务资源密钥来计费图像和文本扩充。Azure Cognitive Search uses the Cognitive Services resource key you provide on a skillset to bill for image and text enrichment. 计费技能的执行是认知服务即用即付价格Execution of billable skills is at the Cognitive Services pay-as-you go price.

  • 图像提取是一个 Azure 认知搜索操作,该操作会在扩充前破译文档时发生。Image extraction is an Azure Cognitive Search operation that occurs when documents are cracked prior to enrichment. 图像提取是可计费的。Image extraction is billable. 有关图像提取定价,请参阅Azure 认知搜索定价页For image extraction pricing, see the Azure Cognitive Search pricing page.

  • 在文档破解短语期间还会发生文本提取。Text extraction also occurs during the document cracking phrase. 它不是计费的。It is not billable.

  • 不应计费的技能不会调用认知服务,包括条件、整形者、文本合并和文本拆分技能。Skills that do not call Cognitive Services, including Conditional, Shaper, Text Merge, and Text Split skills, are not billable.

相同区域要求Same-region requirement

我们要求 Azure 认知搜索和 Azure 认知服务位于同一区域中。We require that Azure Cognitive Search and Azure Cognitive Services exist within the same region. 否则,将在运行时收到此消息: "Provided key is not a valid CognitiveServices type key for the region of your search service."Otherwise, you will get this message at run time: "Provided key is not a valid CognitiveServices type key for the region of your search service."

无法跨区域移动服务。There is no way to move a service across regions. 如果收到此错误,应在 Azure 认知搜索的同一区域中创建新的认知服务资源。If you get this error, you should create a new Cognitive Services resource in the same region as Azure Cognitive Search.

备注

某些内置技能基于非区域认知服务(例如,文本翻译技能)。Some built-in skills are based on non-regional Cognitive Services (for example, the Text Translation Skill). 使用非区域技能意味着请求可能在 Azure 认知搜索区域之外的其他区域中提供服务。Using a non-regional skill means that your request might be serviced in a region other than the Azure Cognitive Search region. 有关非区域性服务的详细信息,请参阅认知服务产品(按区域)页。For more information non-regional services, see the Cognitive Services product by region page.

使用免费资源Use Free resources

您可以使用有限的免费处理选项来完成 AI 扩充教程和快速入门练习。You can use a limited, free processing option to complete the AI enrichment tutorial and quickstart exercises.

每个订阅每天的免费(受限根据)资源限制为20个文档。Free (Limited enrichments) resources are restricted to 20 documents per day, per subscription.

  1. 打开 "导入数据" 向导:Open the Import data wizard:

    打开导入数据向导Open the Import data wizard

  2. 选择数据源并继续添加 AI 扩充(可选)Choose a data source and continue to Add AI enrichment (Optional). 有关此向导的分步演练,请参阅在 Azure 门户中创建索引For a step-by-step walkthrough of this wizard, see Create an index in the Azure portal.

  3. 展开 "附加认知服务",然后选择 "免费(受限根据) ":Expand Attach Cognitive Services and then select Free (Limited enrichments):

    扩展的附加认知服务部分Expanded Attach Cognitive Services section

  4. 现在,你可以继续执行后续步骤,包括添加认知技能You can now continue on to the next steps, including Add cognitive skills.

使用付费资源Use billable resources

对于每天创建20多个根据的工作负荷,请确保附加可计费认知服务资源。For workloads that create more than 20 enrichments per day, make sure to attach a billable Cognitive Services resource. 建议始终附加可计费认知服务资源,即使您从未打算调用认知服务 API。We recommend that you always attach a billable Cognitive Services resource, even if you never intend to call Cognitive Services APIs. 附加资源会重写每日限制。Attaching a resource overrides the daily limit.

仅对调用认知服务 API 的技能收费。You're charged only for skills that call the Cognitive Services APIs. 对于自定义技能或不基于 API 的文本合并文本拆分器整形器等技能,无需付费。You're not billed for custom skills, or skills like text merger, text splitter, and shaper, which aren't API-based.

  1. 打开 "导入数据" 向导,选择数据源,然后继续添加 AI 扩充(可选)Open the Import data wizard, choose a data source, and continue to Add AI enrichment (Optional).

  2. 展开 "附加认知服务",然后选择 "创建新的认知服务资源"。Expand Attach Cognitive Services and then select Create new Cognitive Services resource. 此时将打开一个新选项卡,以便您可以创建资源:A new tab opens so that you can create the resource:

    创建认知服务资源Create a Cognitive Services resource

  3. 在 "位置" 列表中,选择 Azure 认知搜索服务所在的区域。In the Location list, select the region where your Azure Cognitive Search service is located. 出于性能方面的原因,请务必使用此区域。Make sure to use this region for performance reasons. 使用此区域还会将跨区域的出站带宽收费。Using this region also voids outbound bandwidth charges across regions.

  4. 在 "定价层" 列表中,选择 " S0 " 以获取认知服务功能的 "集中" 集合,其中包括备份认知搜索 Azure 提供的内置技能的视觉和语言功能。In the Pricing tier list, select S0 to get the all-in-one collection of Cognitive Services features, including the Vision and Language features that back the built-in skills provided by Azure Cognitive Search.

    对于 S0 层,可以在 "认知服务定价" 页上查找特定工作负荷的费率。For the S0 tier, you can find rates for specific workloads on the Cognitive Services pricing page.

    • 在 "选择产品/服务" 列表中,确保选择 "认知服务"。In the Select Offer list, make sure Cognitive Services is selected.
    • 在 "语言功能" 下,文本分析标准的费率适用于 AI 索引。Under Language features, the rates for Text Analytics Standard apply to AI indexing.
    • 远景功能下,适用计算机视觉 S1的费率。Under Vision features, the rates for Computer Vision S1 apply.
  5. 选择 "创建" 设置新的认知服务资源。Select Create to provision the new Cognitive Services resource.

  6. 返回到上一个选项卡,其中包含导入数据向导。Return to the previous tab, which contains the Import data wizard. 选择 "刷新" 以显示认知服务资源,然后选择资源:Select Refresh to show the Cognitive Services resource, and then select the resource:

    选择认知服务资源Select the Cognitive Services resource

  7. 展开 "添加认知技能" 部分,选择要对数据运行的特定认知技能。Expand the Add cognitive skills section to select the specific cognitive skills that you want to run on your data. 完成向导的剩余步骤。Complete the rest of the wizard.

将现有技能集附加到认知服务资源Attach an existing skillset to a Cognitive Services resource

如果你有现有的技能集,可将其附加到新的或不同的认知服务资源。If you have an existing skillset, you can attach it to a new or different Cognitive Services resource.

  1. 在 "服务概述" 页上,选择 "技能集On the Service overview page, select Skillsets:

    技能集选项卡Skillsets tab

  2. 选择技能组合的名称,然后选择现有的资源或创建一个新的资源。Select the name of the skillset, and then select an existing resource or create a new one. 选择“确定”以确认所做的更改。Select OK to confirm your changes.

    技能组合资源列表Skillset resource list

    请记住,免费(受限根据) 选项每天会限制你使用20个文档,你可以使用 "创建新认知服务" 资源来预配新的可计费资源。Remember that the Free (Limited enrichments) option limits you to 20 documents daily, and that you can use Create new Cognitive Services resource to provision a new billable resource. 如果创建了新资源,请选择“刷新”以刷新认知服务资源的列表,然后选择该资源。If you create a new resource, select Refresh to refresh the list of Cognitive Services resources, and then select the resource.

以编程方式附加认知服务Attach Cognitive Services programmatically

以编程方式定义技能集时,请将 cognitiveServices 节添加到该技能集。When you're defining the skillset programmatically, add a cognitiveServices section to the skillset. 在该部分中,包含要与技能组合关联的认知服务资源的键。In that section, include the key of the Cognitive Services resource that you want to associate with the skillset. 请记住,资源必须与 Azure 认知搜索资源位于同一区域。Remember that the resource must be in the same region as your Azure Cognitive Search resource. 另外请包含 @odata.type,并将其设置为 #Microsoft.Azure.Search.CognitiveServicesByKeyAlso include @odata.type, and set it to #Microsoft.Azure.Search.CognitiveServicesByKey.

以下示例演示了此模式。The following example shows this pattern. 请注意定义末尾的 cognitiveServices 部分。Notice the cognitiveServices section at the end of the definition.

PUT https://[servicename].search.windows.net/skillsets/[skillset name]?api-version=2019-05-06
api-key: [admin key]
Content-Type: application/json
{
    "name": "skillset name",
    "skills": 
    [
      {
        "@odata.type": "#Microsoft.Skills.Text.EntityRecognitionSkill",
        "categories": [ "Organization" ],
        "defaultLanguageCode": "en",
        "inputs": [
          {
            "name": "text", "source": "/document/content"
          }
        ],
        "outputs": [
          {
            "name": "organizations", "targetName": "organizations"
          }
        ]
      }
    ],
    "cognitiveServices": {
        "@odata.type": "#Microsoft.Azure.Search.CognitiveServicesByKey",
        "description": "mycogsvcs",
        "key": "<your key goes here>"
    }
}

示例:估算成本Example: Estimate costs

若要估计与认知搜索索引相关的成本,请首先了解平均值文档的外观,以便可以运行一些数字。To estimate the costs associated with cognitive search indexing, start with an idea of what an average document looks like so you can run some numbers. 例如,你可能会大致接近:For example, you might approximate:

  • 1000个 Pdf。1,000 PDFs.
  • 每个页面六页。Six pages each.
  • 每页一个图像(6000个图像)。One image per page (6,000 images).
  • 每页3000个字符。3,000 characters per page.

假设管道由每个 PDF、图像和文本提取的文档破解、图像的光学字符识别(OCR)和组织的实体识别组成。Assume a pipeline that consists of document cracking of each PDF, image and text extraction, optical character recognition (OCR) of images, and entity recognition of organizations.

本文中所示的价格是假设的。The prices shown in this article are hypothetical. 它们用于说明估算过程。They're used to illustrate the estimation process. 你的成本可能会降低。Your costs could be lower. 有关事务的实际价格,请参阅认知服务定价For the actual prices of transactions, see See Cognitive Services pricing.

  1. 破解包含文本和图像内容的文档时,文本提取目前是免费的。For document cracking with text and image content, text extraction is currently free. 对于6000映像,假设每个提取的1000图像均为 $1。For 6,000 images, assume $1 for every 1,000 images extracted. 对于此步骤,这是 $6.00 的代价。That's a cost of $6.00 for this step.

  2. 对于英语环境中 6000 个图像的 OCR,OCR 认知技能使用最佳算法 (DescribeText)。For OCR of 6,000 images in English, the OCR cognitive skill uses the best algorithm (DescribeText). 假设每分析 1,000 个图像的成本为 $2.50,则这一步需要支付 $15.00。Assuming a cost of $2.50 per 1,000 images to be analyzed, you would pay $15.00 for this step.

  3. 对于实体提取,每页总共有三个文本记录。For entity extraction, you'd have a total of three text records per page. 每条记录包含 1,000 个字符。Each record is 1,000 characters. 每页三个文本记录乘以6000页,等于18000个文本记录。Three text records per page multiplied by 6,000 pages equals 18,000 text records. 假设 1000 个文本记录的成本为 $2.00,则这一步的成本为 $36.00。Assuming $2.00 per 1,000 text records, this step would cost $36.00.

将其全部放在一起,你需要支付 $57.00,以将此类型的 1000 PDF 文档引入所述的技能组合。Putting it all together, you'd pay about $57.00 to ingest 1,000 PDF documents of this type with the described skillset.

后续步骤Next steps