select id, description, LLM_RESPONSE from (
SELECT id, user_text, description, category, sub_category, uri,
ML_PREDICT_ROW(
'projects/abis-345004/locations/us-central1/publishers/google/models/text-bison',
json_build_object(
'instances', json_build_array(
json_build_object(
'prompt', 'Read this user search text: ' || user_text || ' Compare it against the product record: ' || content || ' Return a response with 3 values: 1) MATCH: if the 2 products are at least 85% matching or not: YES or NO 2) PERCENTAGE: percentage of match, make sure that this percentage is accurate 3) DIFFERENCE: A clear short easy description of the difference between the 2 products. Remember if the user search text says that some attribute should not be there, and the product record has it, it should be a NO match.'
)
),
'parameters', json_build_object(
'maxOutputTokens', 1024,
'topK', 40,
'topP', 0.8,
'temperature', 0.2
)
)
) -> 'predictions' -> 0 -> 'content' AS LLM_RESPONSE
FROM (
SELECT 'I want womens footwear, black color, with heels and strictly no leather.' user_text, id, category, sub_category, uri, content, pdt_desc as description FROM apparels
ORDER BY embedding <=> embedding('textembedding-gecko@003', 'I want womens footwear, black color, with heels and strictly no leather.')::vector LIMIT 25) as xyz
) as X
where cast(LLM_RESPONSE as VARCHAR(500)) like '%MATCH:%YES%' limit 10;
For The URL: projects/abis-345004/locations/us-central1/publishers/google/models/text-bison we need to mention the reader to replace abis-345004 with their project id.
In this query:
For The URL:
projects/abis-345004/locations/us-central1/publishers/google/models/text-bison
we need to mention the reader to replaceabis-345004
with their project id.