You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: Instructions/Lab_Instructions.md
+48-21
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ Login to your VM with the following credentials...
27
27
1.[Compare Results of RAG responses using Vector search, Reranker or GraphRAG](#compare-results-of-rag-responses-using-vector-search-reranker-or-graphrag)
28
28
29
29
# 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.
31
31
32
32
1. Go to [Azure portal](https://portal.azure.com/)`https://portal.azure.com/`
@@ -228,24 +230,19 @@ The <code spellcheck="false">azure_openai</code> schema provides the ability to
228
230
229
231
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.
230
232
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:
232
234
233
235
```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;
@@ -437,18 +434,17 @@ We already created a sample Legal Cases RAG application so you can explore RAG a
437
434
438
435
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.
439
436
440
-
**Suggestions for queries:**
437
+
**Suggested for query:**
441
438
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?`
443
439
444
440
### Review Accuracy of vector search queries:
445
441
446
-
For the 2sample question, we have manually identify10 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 identifed10 legal cases that will produce the best answers. To explore the accuracy of vector search follow the instruction below:
447
443
448
444
1. Click the graph icon in the chat bubble to see with cases were used to answer the question.
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.
452
448

453
449
454
450
===
@@ -462,9 +458,21 @@ Read more about reranking in [our blog post](https://aka.ms/semantic-ranker-solu
>[!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/)
467
466
467
+
1. Select Semantic Ranker from the top bar and try the sample query from the previous example.
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.
468
476
469
477
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.
470
478
> [!alert]
@@ -502,7 +510,8 @@ Read more about reranking in [our blog post](https://aka.ms/semantic-ranker-solu
502
510
```
503
511
504
512
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
506
515
507
516
508
517
you will get a result like this:
@@ -522,14 +531,30 @@ you will get a result like this:
522
531
558730 | Burns v. Dufresne
523
532
```
524
533
534
+
===
535
+
525
536
### What is GraphRAG
526
537
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.
527
538
528
539
Read more about Graph RAG in [our blog post](https://aka.ms/graphrag-legal-solution-accelerator-pg-blog).
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.
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
533
558
>[!alert] Make sure you are using **pgAdmin** for the following steps.
534
559
535
560
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
570
595

571
596
572
597
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 5secs
598
+
>[!tip] This query is going to take around 5seconds
574
599
575
600
1. Create new query tool on the same connection
576
601
577
602

578
603
579
-
1. Click Open File icon, and find the reranker_queryin the Downloads folder. `/Downloads/mslearn-pg-ai/Setup/SQLScript/graph_query.sql`
604
+
1. Click Open File icon, and find the graph_queryin the Downloads folder. `/Downloads/mslearn-pg-ai/Setup/SQLScript/graph_query.sql`
580
605
581
606

582
607
@@ -598,6 +623,8 @@ you will get a result *like* this:
598
623
599
624
```
600
625
626
+
===
627
+
601
628
## Compare Results of RAG responses using Vector search, Reranker or GraphRAG
602
629
603
630
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
@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.')
0 commit comments