diff --git a/Instructions/Labs/10-implement-intelligent-search.md b/Instructions/Labs/10-implement-intelligent-search.md index c000641..9ef0f06 100644 --- a/Instructions/Labs/10-implement-intelligent-search.md +++ b/Instructions/Labs/10-implement-intelligent-search.md @@ -464,7 +464,7 @@ Vector search finds reviews based on the semantic meaning of text, not just keyw SELECT @searchVector = AI_GENERATE_EMBEDDINGS(@searchText USE MODEL my_embedding_model); - SELECT + SELECT TOP (5) WITH APPROXIMATE p.Name AS ProductName, r.ReviewTitle, r.ReviewText, @@ -475,8 +475,7 @@ Vector search finds reviews based on the semantic meaning of text, not just keyw TABLE = dbo.ProductReview AS r, COLUMN = ReviewVector, SIMILAR_TO = @searchVector, - METRIC = 'cosine', - TOP_N = 5 + METRIC = 'cosine' ) AS vs INNER JOIN SalesLT.Product p ON r.ProductID = p.ProductID @@ -535,16 +534,16 @@ RRF combines ranked results from different sources by using rank positions inste ReviewID, RANK() OVER (ORDER BY distance) AS vector_rank FROM ( - SELECT + SELECT TOP (50) WITH APPROXIMATE r.ReviewID, vs.distance FROM VECTOR_SEARCH( TABLE = dbo.ProductReview AS r, COLUMN = ReviewVector, SIMILAR_TO = @searchVector, - METRIC = 'cosine', - TOP_N = 50 + METRIC = 'cosine' ) AS vs + ORDER BY vs.distance ) AS similar_reviews ), combined AS ( @@ -610,7 +609,7 @@ To understand the strengths of each approach, run the same question through all SELECT @searchVector = AI_GENERATE_EMBEDDINGS(@searchText USE MODEL my_embedding_model); - SELECT + SELECT TOP (5) WITH APPROXIMATE p.Name AS ProductName, r.ReviewTitle, r.ReviewText, @@ -620,8 +619,7 @@ To understand the strengths of each approach, run the same question through all TABLE = dbo.ProductReview AS r, COLUMN = ReviewVector, SIMILAR_TO = @searchVector, - METRIC = 'cosine', - TOP_N = 5 + METRIC = 'cosine' ) AS vs INNER JOIN SalesLT.Product p ON r.ProductID = p.ProductID @@ -653,16 +651,16 @@ To understand the strengths of each approach, run the same question through all ReviewID, RANK() OVER (ORDER BY distance) AS vector_rank FROM ( - SELECT + SELECT TOP (50) WITH APPROXIMATE r.ReviewID, vs.distance FROM VECTOR_SEARCH( TABLE = dbo.ProductReview AS r, COLUMN = ReviewVector, SIMILAR_TO = @searchVector, - METRIC = 'cosine', - TOP_N = 50 + METRIC = 'cosine' ) AS vs + ORDER BY vs.distance ) AS similar_reviews ), combined AS ( @@ -710,4 +708,4 @@ If you provisioned a new resource group for this lab, you can simply delete the You successfully completed this exercise. -In this exercise, you implemented and compared three search approaches in Azure SQL Database: full-text search using a full-text index with keyword predicates and inflectional patterns, vector search using exact and approximate nearest neighbor queries with a DiskANN index, and hybrid search combining both methods with Reciprocal Rank Fusion to merge keyword and semantic results. You compared all three approaches on the same query to understand the strengths of each. \ No newline at end of file +In this exercise, you implemented and compared three search approaches in Azure SQL Database: full-text search using a full-text index with keyword predicates and inflectional patterns, vector search using exact and approximate nearest neighbor queries with a DiskANN index, and hybrid search combining both methods with Reciprocal Rank Fusion to merge keyword and semantic results. You compared all three approaches on the same query to understand the strengths of each. diff --git a/Instructions/Labs/11-implement-rag-solutions.md b/Instructions/Labs/11-implement-rag-solutions.md index 461e1e3..9a94ca8 100644 --- a/Instructions/Labs/11-implement-rag-solutions.md +++ b/Instructions/Labs/11-implement-rag-solutions.md @@ -324,7 +324,7 @@ In this section, you practice the **retrieval** step of RAG. Instead of using a SELECT @questionVector = AI_GENERATE_EMBEDDINGS(@userQuestion USE MODEL my_embedding_model); -- Find the top 5 most relevant reviews using ANN vector search - SELECT + SELECT TOP (5) WITH APPROXIMATE p.Name AS ProductName, p.ListPrice, pc.Name AS Category, @@ -336,13 +336,13 @@ In this section, you practice the **retrieval** step of RAG. Instead of using a TABLE = dbo.ProductReview AS r, COLUMN = ReviewVector, SIMILAR_TO = @questionVector, - METRIC = 'cosine', - TOP_N = 5 + METRIC = 'cosine' ) AS vs INNER JOIN SalesLT.Product p ON r.ProductID = p.ProductID INNER JOIN SalesLT.ProductCategory pc ON p.ProductCategoryID = pc.ProductCategoryID + ORDER BY vs.distance FOR JSON PATH; GO ``` @@ -368,7 +368,7 @@ Now you combine retrieved data with a system message and user question to build -- Step 2: Retrieve relevant reviews using ANN vector search SET @context = ( - SELECT + SELECT TOP (5) WITH APPROXIMATE p.Name AS ProductName, p.ListPrice, pc.Name AS Category, @@ -379,13 +379,13 @@ Now you combine retrieved data with a system message and user question to build TABLE = dbo.ProductReview AS r, COLUMN = ReviewVector, SIMILAR_TO = @questionVector, - METRIC = 'cosine', - TOP_N = 5 + METRIC = 'cosine' ) AS vs INNER JOIN SalesLT.Product p ON r.ProductID = p.ProductID INNER JOIN SalesLT.ProductCategory pc ON p.ProductCategoryID = pc.ProductCategoryID + ORDER BY vs.distance FOR JSON PATH ); @@ -401,7 +401,7 @@ Now you combine retrieved data with a system message and user question to build 'content': 'Product reviews: ' + ISNULL(@context, '[]') + CHAR(10) + CHAR(10) + 'Customer question: ' + @userQuestion ) ), - 'max_tokens': CAST(500 AS INT), + 'max_completion_tokens': CAST(500 AS INT), 'temperature': 0.5 ); @@ -433,7 +433,7 @@ This step is the "G" in RAG, the generation step. You send the augmented prompt -- Step 2: Retrieve relevant reviews using ANN vector search SET @context = ( - SELECT + SELECT TOP (5) WITH APPROXIMATE p.Name AS ProductName, p.ListPrice, pc.Name AS Category, @@ -444,13 +444,13 @@ This step is the "G" in RAG, the generation step. You send the augmented prompt TABLE = dbo.ProductReview AS r, COLUMN = ReviewVector, SIMILAR_TO = @questionVector, - METRIC = 'cosine', - TOP_N = 5 + METRIC = 'cosine' ) AS vs INNER JOIN SalesLT.Product p ON r.ProductID = p.ProductID INNER JOIN SalesLT.ProductCategory pc ON p.ProductCategoryID = pc.ProductCategoryID + ORDER BY vs.distance FOR JSON PATH ); @@ -466,7 +466,7 @@ This step is the "G" in RAG, the generation step. You send the augmented prompt 'content': 'Product reviews: ' + ISNULL(@context, '[]') + CHAR(10) + CHAR(10) + 'Customer question: ' + @userQuestion ) ), - 'max_tokens': CAST(500 AS INT), + 'max_completion_tokens': CAST(500 AS INT), 'temperature': 0.5 ); @@ -523,7 +523,7 @@ Now put it all together in a reusable stored procedure that your application can -- Step 2: Retrieve relevant reviews using ANN vector search SET @context = ( - SELECT + SELECT TOP (5) WITH APPROXIMATE p.Name AS ProductName, p.ListPrice, pc.Name AS Category, @@ -534,13 +534,13 @@ Now put it all together in a reusable stored procedure that your application can TABLE = dbo.ProductReview AS r, COLUMN = ReviewVector, SIMILAR_TO = @questionVector, - METRIC = 'cosine', - TOP_N = 5 + METRIC = 'cosine' ) AS vs INNER JOIN SalesLT.Product p ON r.ProductID = p.ProductID INNER JOIN SalesLT.ProductCategory pc ON p.ProductCategoryID = pc.ProductCategoryID + ORDER BY vs.distance FOR JSON PATH ); @@ -568,7 +568,7 @@ Now put it all together in a reusable stored procedure that your application can 'content': 'Product reviews: ' + @context + CHAR(10) + CHAR(10) + 'Customer question: ' + @Question ) ), - 'max_tokens': CAST(500 AS INT), + 'max_completion_tokens': CAST(500 AS INT), 'temperature': 0.5 );