Skip to content

Commit 164d8bb

Browse files
authored
Merge pull request #2633 from HeidiSteen/heidist-freshness
[azure search] Refreshed SynapseML tutorial to use latest versions
2 parents 960ccae + 22ad5f6 commit 164d8bb

File tree

6 files changed

+22
-18
lines changed

6 files changed

+22
-18
lines changed
44.9 KB
Loading
17.3 KB
Loading
27.5 KB
Loading
5.22 KB
Loading
11.7 KB
Loading

articles/search/search-synapseml-cognitive-services.md

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ms.service: azure-ai-search
1010
ms.custom:
1111
- ignite-2023
1212
ms.topic: tutorial
13-
ms.date: 04/22/2024
13+
ms.date: 01/30/2025
1414
---
1515

1616
# Tutorial: Index large data from Apache Spark using SynapseML and Azure AI Search
@@ -24,7 +24,7 @@ In this Azure AI Search tutorial, learn how to index and query large data loaded
2424
> + Write the output to a search index hosted in Azure AI Search
2525
> + Explore and query over the content you created
2626
27-
This tutorial takes a dependency on [SynapseML](https://www.microsoft.com/research/blog/synapseml-a-simple-multilingual-and-massively-parallel-machine-learning-library/), an open source library that supports massively parallel machine learning over big data. In SynapseML, search indexing and machine learning are exposed through *transformers* that perform specialized tasks. Transformers tap into a wide range of AI capabilities. In this exercise, use the **AzureSearchWriter** APIs for analysis and AI enrichment.
27+
This tutorial takes a dependency on [SynapseML](https://microsoft.github.io/SynapseML/), an open source library that supports massively parallel machine learning over big data. In SynapseML, search indexing and machine learning are exposed through *transformers* that perform specialized tasks. Transformers tap into a wide range of AI capabilities. In this exercise, use the **AzureSearchWriter** APIs for analysis and AI enrichment.
2828

2929
Although Azure AI Search has native [AI enrichment](cognitive-search-concept-intro.md), this tutorial shows you how to access AI capabilities outside of Azure AI Search. By using SynapseML instead of indexers or skills, you're not subject to data limits or other constraints associated with those objects.
3030

@@ -35,18 +35,18 @@ Although Azure AI Search has native [AI enrichment](cognitive-search-concept-int
3535

3636
You need the `synapseml` library and several Azure resources. If possible, use the same subscription and region for your Azure resources and put everything into one resource group for simple cleanup later. The following links are for portal installs. The sample data is imported from a public site.
3737

38-
+ [SynapseML package](https://microsoft.github.io/SynapseML/docs/Get%20Started/Install%20SynapseML/#python) <sup>1</sup>
39-
+ [Azure AI Search](search-create-service-portal.md) (any tier) <sup>2</sup>
40-
+ [Azure AI services](/azure/ai-services/multi-service-resource?pivots=azportal) (any tier) <sup>3</sup>
41-
+ [Azure Databricks](/azure/databricks/scenarios/quickstart-create-databricks-workspace-portal?tabs=azure-portal) (any tier) <sup>4</sup>
38+
+ [SynapseML package](https://microsoft.github.io/SynapseML/docs/Get%20Started/Install%20SynapseML/#python) <sup>1</sup>
39+
+ [Azure AI Search](search-create-service-portal.md) (any tier), with an **API Kind** of `AIServices` <sup>2</sup>
40+
+ [Azure AI multi-service account](/azure/ai-services/multi-service-resource?pivots=azportal) (any tier) <sup>3</sup>
41+
+ [Azure Databricks](/azure/databricks/scenarios/quickstart-create-databricks-workspace-portal?tabs=azure-portal) (any tier) with Apache Spark 3.3.0 runtime<sup>4</sup>
4242

4343
<sup>1</sup> This link resolves to a tutorial for loading the package.
4444

4545
<sup>2</sup> You can use the free search tier to index the sample data, but [choose a higher tier](search-sku-tier.md) if your data volumes are large. For billable tiers, provide the [search API key](search-security-api-keys.md#find-existing-keys) in the [Set up dependencies](#step-2-set-up-dependencies) step further on.
4646

47-
<sup>3</sup> This tutorial uses Azure AI Document Intelligence and Azure AI Translator. In the instructions that follow, provide a [multi-service](/azure/ai-services/multi-service-resource?pivots=azportal) key and the region. The same key works for both services.
47+
<sup>3</sup> This tutorial uses Azure AI Document Intelligence and Azure AI Translator. In the instructions that follow, provide a [multi-service account](/azure/ai-services/multi-service-resource?pivots=azportal) key and the region. The same key works for both services. **It's important that you use an Azure AI multiservice account of API kind of `AIServices` for this tutorial**. You can check the API kind in the Azure portal on the Overview section of your Azure AI multiservice account page. For more information about API kind, see [Attach an Azure AI multi-service resource in Azure AI Search](cognitive-search-attach-cognitive-services.md).
4848

49-
<sup>4</sup> In this tutorial, Azure Databricks provides the Spark computing platform. We used the [portal instructions](/azure/databricks/scenarios/quickstart-create-databricks-workspace-portal?tabs=azure-portal) to set up the workspace.
49+
<sup>4</sup> In this tutorial, Azure Databricks provides the Spark computing platform. We used the [portal instructions](/azure/databricks/scenarios/quickstart-create-databricks-workspace-portal?tabs=azure-portal) to set up the cluster and workspace.
5050

5151
> [!NOTE]
5252
> All of the above Azure resources support security features in the Microsoft Identity platform. For simplicity, this tutorial assumes key-based authentication, using endpoints and keys copied from the Azure portal pages of each service. If you implement this workflow in a production environment, or share the solution with others, remember to replace hard-coded keys with integrated security or encrypted keys.
@@ -63,6 +63,10 @@ In this section, create a cluster, install the `synapseml` library, and create a
6363

6464
1. Accept the default configuration. It takes several minutes to create the cluster.
6565

66+
1. Verify the cluster is operational and running. A green dot by the cluster name confirms its status.
67+
68+
:::image type="content" source="media/search-synapseml-cognitive-services/cluster-green-dot.png" alt-text="Screenshot of a Data Bricks compute page with a green dot by the cluster name.":::
69+
6670
1. Install the `synapseml` library after the cluster is created:
6771

6872
1. Select **Libraries** from the tabs at the top of the cluster's page.
@@ -73,7 +77,7 @@ In this section, create a cluster, install the `synapseml` library, and create a
7377

7478
1. Select **Maven**.
7579

76-
1. In Coordinates, enter `com.microsoft.azure:synapseml_2.12:1.0.4`
80+
1. In Coordinates, search for or type `com.microsoft.azure:synapseml_2.12:1.0.9`
7781

7882
1. Select **Install**.
7983

@@ -85,15 +89,15 @@ In this section, create a cluster, install the `synapseml` library, and create a
8589

8690
1. Give the notebook a name, select **Python** as the default language, and select the cluster that has the `synapseml` library.
8791

88-
1. Create seven consecutive cells. Paste code into each one.
92+
1. Create seven consecutive cells. You use these to paste in code in the following sections.
8993

9094
:::image type="content" source="media/search-synapseml-cognitive-services/create-seven-cells.png" alt-text="Screenshot of the notebook with placeholder cells." border="true":::
9195

9296
## Step 2: Set up dependencies
9397

9498
Paste the following code into the first cell of your notebook.
9599

96-
Replace the placeholders with endpoints and access keys for each resource. Provide a name for a new search index. No other modifications are required, so run the code when you're ready.
100+
Replace the placeholders with endpoints and access keys for each resource. Provide a name for a new search index that's created for you. No other modifications are required, so run the code when you're ready.
97101

98102
This code imports multiple packages and sets up access to the Azure resources used in this workflow.
99103

@@ -103,12 +107,12 @@ from pyspark.sql.functions import udf, trim, split, explode, col, monotonically_
103107
from pyspark.sql.types import StringType
104108
from synapse.ml.core.spark import FluentAPI
105109

106-
cognitive_services_key = "placeholder-cognitive-services-multi-service-key"
107-
cognitive_services_region = "placeholder-cognitive-services-region"
110+
cognitive_services_key = "placeholder-azure-ai-services-multi-service-key"
111+
cognitive_services_region = "placeholder-azure-ai-services-region"
108112

109113
search_service = "placeholder-search-service-name"
110-
search_key = "placeholder-search-service-api-key"
111-
search_index = "placeholder-search-index-name"
114+
search_key = "placeholder-search-service-admin-api-key"
115+
search_index = "placeholder-for-new-search-index-name"
112116
```
113117

114118
## Step 3: Load data into Spark
@@ -128,7 +132,7 @@ def blob_to_url(blob):
128132

129133

130134
df2 = (spark.read.format("binaryFile")
131-
.load("wasbs://ignite2021@mmlsparkdemo.blob.core.windows.net/form_subset/*")
135+
.load("wasbs://publicwasb@mmlspark.blob.core.windows.net/form_subset/*")
132136
.select("path")
133137
.limit(10)
134138
.select(udf(blob_to_url, StringType())("path").alias("url"))
@@ -141,10 +145,10 @@ display(df2)
141145

142146
Paste the following code into the third cell. No modifications are required, so run the code when you're ready.
143147

144-
This code loads the [AnalyzeInvoices transformer](https://mmlspark.blob.core.windows.net/docs/0.11.2/pyspark/synapse.ml.cognitive.form.html#module-synapse.ml.cognitive.form.AnalyzeInvoices) and passes a reference to the data frame containing the invoices. It calls the prebuilt [invoice model](/azure/ai-services/document-intelligence/concept-invoice) of Azure AI Document Intelligence to extract information from the invoices.
148+
This code loads the [AnalyzeInvoices transformer](https://mmlspark.blob.core.windows.net/docs/1.0.9/pyspark/synapse.ml.services.form.html#module-synapse.ml.services.form.AnalyzeInvoices) and passes a reference to the data frame containing the invoices. It calls the prebuilt [invoice model](/azure/ai-services/document-intelligence/concept-invoice) of Azure AI Document Intelligence to extract information from the invoices.
145149

146150
```python
147-
from synapse.ml.cognitive import AnalyzeInvoices
151+
from synapse.ml.services import AnalyzeInvoices
148152

149153
analyzed_df = (AnalyzeInvoices()
150154
.setSubscriptionKey(cognitive_services_key)

0 commit comments

Comments
 (0)