Skip to content

Commit 96b800d

Browse files
authored
Merge pull request #3 from Azure-Samples/techconnect-2025-lab
Updating the Lab for newer labs
2 parents d1251be + 74469a7 commit 96b800d

File tree

4 files changed

+48
-42
lines changed

4 files changed

+48
-42
lines changed

Instructions/Lab_Instructions.md

+48-21
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Login to your VM with the following credentials...
2727
1. [Compare Results of RAG responses using Vector search, Reranker or GraphRAG](#compare-results-of-rag-responses-using-vector-search-reranker-or-graphrag)
2828

2929
# Part 0 - Log into Azure
30-
Login to Azure Portal with the following credentials.
30+
Open Edge in the lab environment and login to Azure Portal with the following credentials.
3131

3232
1. Go to [Azure portal](https://portal.azure.com/) `https://portal.azure.com/`
3333
- Username: [email protected](User1).Username+++
@@ -50,6 +50,8 @@ Login to Azure Portal with the following credentials.
5050
Also pick *No storage account required* and select your subscription.
5151
![Screenshot of the Azure toolbar with the Cloud Shell icon highlighted by a red box.](./instructions276019/select_storage.png)
5252

53+
Click Apply after selecting your subscription
54+
5355
3. At the Cloud Shell prompt, enter the following to clone the GitHub repo containing exercise resources:
5456

5557
> +++git clone https://github.com/Azure-Samples/mslearn-pg-ai.git+++
@@ -228,24 +230,19 @@ The <code spellcheck="false">azure_openai</code> schema provides the ability to
228230
229231
The docs will shows the two overloads of the <code spellcheck="false">azure_openai.create_embeddings()</code> function, allowing you to review the differences between the two versions of the function and the types they return.
230232
231-
2. To provide a simplified example of using the function, run the following query, which creates a vector embedding for the <code spellcheck="false">opinion</code> field in the <code spellcheck="false">cases</code> table. The <code spellcheck="false">deployment_name</code> parameter in the function is set to <code spellcheck="false">embedding</code>, which is the name of the deployment of the <code spellcheck="false">text-embedding-3-small</code> model in your Azure OpenAI service:
233+
2. To provide a simplified example of using the function, run the following query, which creates a vector embedding for a sample query. The <code spellcheck="false">deployment_name</code> parameter in the function is set to <code spellcheck="false">embedding</code>, which is the name of the deployment of the <code spellcheck="false">text-embedding-3-small</code> model in your Azure OpenAI service:
232234
233235
```sql
234-
SELECT
235-
  id,
236-
  name,
237-
  azure_openai.create_embeddings('text-embedding-3-small', LEFT(opinion, 8000)) AS vector
238-
FROM cases
239-
LIMIT 1;
236+
SELECT azure_openai.create_embeddings('text-embedding-3-small', 'Sample text for PostgreSQL Lab') AS vector;
240237
```
241238
242239
the output looks similar to this:
243240
244241
245242
```sql-nocopy
246-
id |      name       |              vector
247-
----+-------------------------------+------------------------------------------------------------
248-
507122 | Berschauer/Phillips Construction Co. v. Seattle School District No. 1 | {0.020068742,0.00022734122,0.0018286322,-0.0064167166,...}
243+
id |   vector
244+
----+-----------------------------------------------------------
245+
| {0.020068742,0.00022734122,0.0018286322,-0.0064167166,...}
249246
```
250247
251248
@@ -437,18 +434,17 @@ We already created a sample Legal Cases RAG application so you can explore RAG a
437434

438435
1. In [RAG application](https://abeomorogbe-graphra-ca.gentledune-632d42cd.eastus2.azurecontainerapps.io/) is using the results from vector search to answer your questions. Try any query to test the limits of the application.
439436

440-
**Suggestions for queries:**
437+
**Suggested for query:**
441438
1. `Water leaking into the apartment from the floor above. What are the prominent legal precedents from cases in Washington on this problem?`
442-
2. `When the landlord is sued in court for leaking pipes, infer and give examples of the number of times there was a favorable decision for the lessee?`
443439

444440
### Review Accuracy of vector search queries:
445441

446-
For the 2 sample question, we have manually identify 10 legal cases that will produce the best answers. To explore the accuracy of vector search follow the instruction below:
442+
For the sample question, we have manually identifed 10 legal cases that will produce the best answers. To explore the accuracy of vector search follow the instruction below:
447443

448444
1. Click the graph icon in the chat bubble to see with cases were used to answer the question.
449445
![Graph screenshot](./instructions282962/RAG-app-demo-graph-icon.png)
450446

451-
2. From the Citation Graph, you will see Vector search only retrieve 40% of the most revelvant cases. The orange indicates what was retrieved to answer the questions, and green indicates what should be retrieved for the sample question.
447+
2. From the Citation Graph, you will see Vector search **only retrieve 40% of the most relevant cases**. The orange indicates what was retrieved to answer the questions, and green indicates what should be retrieved for the sample question.
452448
![Recall of Graph screenshot](./instructions282962/RAG-app-demo-recall-graph.png)
453449

454450
===
@@ -462,9 +458,21 @@ Read more about reranking in [our blog post](https://aka.ms/semantic-ranker-solu
462458

463459
![Semantic Reranker image](./instructions282962/semantic-ranking-solution-postgres-on-azure.png)
464460

465-
### Using a Reranker
466-
>[!alert] Make sure you are using **pgAdmin** for the following steps.
461+
### Understanding improved accuracy of semantic reranker:
462+
463+
Using the same example from the vector search example in the preview section. To explore the accuracy of semantic reranker follow the instruction below:
464+
465+
1. Use the [RAG application](https://abeomorogbe-graphra-ca.gentledune-632d42cd.eastus2.azurecontainerapps.io/)
467466

467+
1. Select Semantic Ranker from the top bar and try the sample query from the previous example.
468+
![select Reranker](instructions282962/selectReranker.png)
469+
470+
1. Click the graph icon in the chat bubble to see with cases were used to answer the question.
471+
472+
1. From the Citation Graph, you will see semantic reranker has a slighty improve accuracy, and **retrieves 60% of the most revelvant cases**.
473+
474+
### How to implement a reranker for queries
475+
>[!alert] Make sure you are using **pgAdmin** for the following steps.
468476

469477
1. Before we execute the reranker query to improve the relevance of your search results. We should understand the following important snippet of code for reranking.
470478
> [!alert]
@@ -502,7 +510,8 @@ Read more about reranking in [our blog post](https://aka.ms/semantic-ranker-solu
502510
```
503511

504512
1. Run the query.
505-
>[!tip] **This query is going to take around 3 secs**
513+
514+
>[!tip] This query is going to take around 3 seconds
506515

507516

508517
you will get a result like this:
@@ -522,14 +531,30 @@ you will get a result like this:
522531
558730 | Burns v. Dufresne
523532
```
524533

534+
===
535+
525536
### What is GraphRAG
526537
GraphRAG uses knowledge graphs to provide substantial improvements in question-and-answer performance when reasoning about complex information. A Knowledge Graph is a structured representation of information that captures relationships between entities in a graph format. It is used to integrate, manage, and query data from diverse sources, providing a unified view of interconnected data. [Apache Graph Extension](https://age.apache.org/age-manual/master/index.html) (AGE) is a PostgreSQL extension developed under the Apache Incubator project. AGE is designed to provide graph database functionality, enabling users to store and query graph data efficiently within PostgreSQL.
527538

528539
Read more about Graph RAG in [our blog post](https://aka.ms/graphrag-legal-solution-accelerator-pg-blog).
529540

530541
![graphrag-postgres-architecture.png](instructions282962/graphrag-postgres-architecture.png)
531542

532-
### Using a GraphRAG
543+
544+
### Understanding improved accuracy of GraphRAG:
545+
546+
Using the same example from the vector search example in the preview section. To explore the accuracy of semantic reranker follow the instruction below:
547+
548+
1. Use the [RAG application](https://abeomorogbe-graphra-ca.gentledune-632d42cd.eastus2.azurecontainerapps.io/)
549+
550+
1. Select GraphRAG from the top bar and try the sample query from the previous example.
551+
![select GraphRAG](instructions282962/selectGraphRAG.png)
552+
553+
1. Click the graph icon in the chat bubble to see with cases were used to answer the question.
554+
555+
1. From the Citation Graph, you will see semantic reranker has a slighted improve accuracy, and **retrieves 70% of the most revelvant cases**.
556+
557+
### How to implement graph queries for GraphRAG
533558
>[!alert] Make sure you are using **pgAdmin** for the following steps.
534559

535560
1. Before we execute the graph query to improve the relevance of your search results. We should understand the following important snippet of code for reranking
@@ -570,13 +595,13 @@ Read more about Graph RAG in [our blog post](https://aka.ms/graphrag-legal-solut
570595
![Open file in pgAdmin](./instructions276019/open-file.png)
571596

572597
1. Now to run the *graph query* to create the node and connections between cases in your database.
573-
>[!tip] This query is going to take around 5 secs
598+
>[!tip] This query is going to take around 5 seconds
574599

575600
1. Create new query tool on the same connection
576601

577602
![Creating new query tool](./instructions276019/new-query-tool.png)
578603

579-
1. Click Open File icon, and find the reranker_query in the Downloads folder. `/Downloads/mslearn-pg-ai/Setup/SQLScript/graph_query.sql`
604+
1. Click Open File icon, and find the graph_query in the Downloads folder. `/Downloads/mslearn-pg-ai/Setup/SQLScript/graph_query.sql`
580605

581606
![Open file in pgAdmin](./instructions276019/open-file.png)
582607

@@ -598,6 +623,8 @@ you will get a result *like* this:
598623
599624
```
600625

626+
===
627+
601628
## Compare Results of RAG responses using Vector search, Reranker or GraphRAG
602629

603630
1. In [RAG application](https://abeomorogbe-graphra-ca.gentledune-632d42cd.eastus2.azurecontainerapps.io/) select the 'Vector Seach' option in the top bar. Try the sample query
Loading
Loading

Setup/Infra/deploy.bicep

-21
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ param adminLoginPassword string
1919
@description('Unique name for the Azure OpenAI service.')
2020
param azureOpenAIServiceName string = 'oai-learn-${resourceGroup().location}-${uniqueString(resourceGroup().id)}'
2121

22-
@description('Unique name for the Azure AI Language service account.')
23-
param languageServiceName string = 'lang-learn-${resourceGroup().location}-${uniqueString(resourceGroup().id)}'
24-
2522
@description('Restore the service instead of creating a new instance. This is useful if you previously soft-delted the service and want to restore it. If you are restoring a service, set this to true. Otherwise, leave this as false.')
2623
param restore bool = false
2724

@@ -134,28 +131,10 @@ resource azureOpenAIEmbeddingDeployment 'Microsoft.CognitiveServices/accounts/de
134131
}
135132
}
136133

137-
@description('Creates an Azure AI Language service account.')
138-
resource languageService 'Microsoft.CognitiveServices/accounts@2023-05-01' = {
139-
name: languageServiceName
140-
location: location
141-
kind: 'TextAnalytics'
142-
sku: {
143-
name: 'S'
144-
}
145-
properties: {
146-
customSubDomainName: languageServiceName
147-
publicNetworkAccess: 'Enabled'
148-
restore: restore
149-
}
150-
}
151-
152134
output serverFqdn string = postgreSQLFlexibleServer.properties.fullyQualifiedDomainName
153135
output serverName string = postgreSQLFlexibleServer.name
154136
output databaseName string = casesDatabase.name
155137

156138
output azureOpenAIServiceName string = azureOpenAIService.name
157139
output azureOpenAIEndpoint string = azureOpenAIService.properties.endpoint
158140
output azureOpenAIEmbeddingDeploymentName string = azureOpenAIEmbeddingDeployment.name
159-
160-
output languageServiceName string = languageService.name
161-
output languageServiceEndpoint string = languageService.properties.endpoint

0 commit comments

Comments
 (0)