-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support TVF * Update testdata * Do go test --update * Fix indentation * Rename to update_with_safe_ml_predict.sql * Fix doc comment * Simplify implementation
- Loading branch information
Showing
19 changed files
with
2,031 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-- https://cloud.google.com/spanner/docs/backfill-embeddings?hl=en#backfill | ||
UPDATE products | ||
SET | ||
products.desc_embed = ( | ||
SELECT embeddings.values | ||
FROM SAFE.ML.PREDICT( | ||
MODEL gecko_model, | ||
(SELECT products.description AS content) | ||
) @{remote_udf_max_rows_per_rpc=200} | ||
), | ||
products.desc_embed_model_version = 3 | ||
WHERE products.desc_embed IS NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
SELECT ChangeRecord FROM READ_SingersNameStream ( | ||
start_timestamp => "2022-05-01T09:00:00Z", | ||
end_timestamp => NULL, | ||
partition_token => NULL, | ||
heartbeat_milliseconds => 10000 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- https://cloud.google.com/spanner/docs/ml-tutorial-generative-ai?hl=en#register_a_generative_ai_model_in_a_schema | ||
SELECT content | ||
FROM ML.PREDICT( | ||
MODEL TextBison, | ||
(SELECT "Is 13 prime?" AS prompt), | ||
STRUCT(256 AS maxOutputTokens, 0.2 AS temperature, 40 as topK, 0.95 AS topP) | ||
) @{remote_udf_max_rows_per_rpc=1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
SELECT id, color, value | ||
FROM ML.PREDICT(MODEL DiamondAppraise, TABLE Diamonds) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
SELECT product_id, product_name, content | ||
FROM ML.PREDICT( | ||
MODEL TextBison, | ||
(SELECT | ||
product.id as product_id, | ||
product.name as product_name, | ||
CONCAT("Is this product safe for infants?", "\n", | ||
"Product Name: ", product.name, "\n", | ||
"Category Name: ", category.name, "\n", | ||
"Product Description:", product.description) AS prompt | ||
FROM | ||
Products AS product JOIN Categories AS category | ||
ON product.category_id = category.id), | ||
STRUCT(100 AS maxOutputTokens) | ||
) @{remote_udf_max_rows_per_rpc=1} |
Oops, something went wrong.