Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions Instructions/Labs/10-implement-intelligent-search.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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.
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.
30 changes: 15 additions & 15 deletions Instructions/Labs/11-implement-rag-solutions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
```
Expand All @@ -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,
Expand All @@ -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
);

Expand All @@ -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
);

Expand Down Expand Up @@ -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,
Expand All @@ -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
);

Expand All @@ -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
);

Expand Down Expand Up @@ -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,
Expand All @@ -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
);

Expand Down Expand Up @@ -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
);

Expand Down