CREATE OR REPLACE TABLE
`gemini_demo.customer_reviews_keywords` AS (
SELECT ml_generate_text_llm_result, social_media_source, review_text, customer_id, location_id, review_datetime
FROM
ML.GENERATE_TEXT(
MODEL `gemini_demo.gemini_pro`,
(
SELECT social_media_source, customer_id, location_id, review_text, review_datetime, CONCAT(
'For each review, provide keywords from the review. Answer in JSON format with one key: keywords. Keywords should be a list.',
review_text) AS prompt
FROM `gemini_demo.customer_reviews`
),
STRUCT(
0.2 AS temperature, TRUE AS flatten_json_output)));
CREATE OR REPLACE TABLE
`gemini_demo.customer_reviews_analysis` AS (
SELECT ml_generate_text_llm_result, social_media_source, review_text, customer_id, location_id, review_datetime
FROM
ML.GENERATE_TEXT(
MODEL `gemini_demo.gemini_pro`,
(
SELECT social_media_source, customer_id, location_id, review_text, review_datetime, CONCAT(
'Classify the sentiment of the following text as positive or negative.',
review_text, "In your response don't include the sentiment explanation. Remove all extraneous information from your response, it should be a boolean response either positive or negative.") AS prompt
FROM `gemini_demo.customer_reviews`
),
STRUCT(
0.2 AS temperature, TRUE AS flatten_json_output)));
SELECT sentiment, social_media_source, COUNT(*) AS count
FROM `gemini_demo.cleaned_data_view`
WHERE sentiment IN ('positive') OR sentiment IN ('negative')
GROUP BY sentiment, social_media_source
ORDER BY sentiment, count;
点击检查我的进度以验证是否完成了以下目标:
提示 Gemini 分析顾客评价中的关键字和情绪。
任务 6:回复顾客评价
您还可以使用 Gemini Pro 来回复顾客评价。在此项任务中,您将学习如何针对 customer_reviews 表中的特定评价,使用“零样本”创建营销回复,以及使用“少样本”创建客户服务回复。
注意:请参阅 Google AI for Developers 文档中的零样本提示与少样本提示,了解更多信息。
您可以通过这些查询使用 Gemini Pro 来完成这项任务。在查询编辑器中,粘贴下方的查询并运行。
CREATE OR REPLACE TABLE
`gemini_demo.customer_reviews_marketing` AS (
SELECT ml_generate_text_llm_result, social_media_source, review_text, customer_id, location_id, review_datetime
FROM
ML.GENERATE_TEXT(
MODEL `gemini_demo.gemini_pro`,
(
SELECT social_media_source, customer_id, location_id, review_text, review_datetime, CONCAT(
'You are a marketing representative. How could we incentivise this customer with this positive review? Provide a single response, and should be simple and concise, do not include emojis. Answer in JSON format with one key: marketing. Marketing should be a string.', review_text) AS prompt
FROM `gemini_demo.customer_reviews`
WHERE customer_id = 5576
),
STRUCT(
0.2 AS temperature, TRUE AS flatten_json_output)));
此查询用于分析 customer_reviews 表中的顾客评价,尤其是来自客户 ID 5576 的评价。运行此查询时,它将使用 Gemini Pro 来根据评价文本生成营销建议,然后将结果存储到名为 customer_reviews_marketing 的新表中。此表将包含原始的评价数据以及生成的营销建议,以便您根据它们进行分析和展开行动。
这显然是一条负面评价,那么如何使用 Gemini Pro 来回复这位顾客,并将顾客体验告知这家咖啡店,以便他们采取改进措施呢?
您可以通过这些查询使用 Gemini Pro 来完成这项任务。在查询编辑器中,粘贴下方的查询并运行。
CREATE OR REPLACE TABLE
`gemini_demo.customer_reviews_cs_response` AS (
SELECT ml_generate_text_llm_result, social_media_source, review_text, customer_id, location_id, review_datetime
FROM
ML.GENERATE_TEXT(
MODEL `gemini_demo.gemini_pro`,
(
SELECT social_media_source, customer_id, location_id, review_text, review_datetime, CONCAT(
'How would you respond to this customer review? If the customer says the coffee is weak or burnt, respond stating "thank you for the review we will provide your response to the location that you did not like the coffee and it could be improved." Or if the review states the service is bad, respond to the customer stating, "the location they visited has been notified and we are taking action to improve our service at that location." From the customer reviews provide actions that the location can take to improve. The response and the actions should be simple, and to the point. Do not include any extraneous or special characters in your response. Answer in JSON format with two keys: Response, and Actions. Response should be a string. Actions should be a string.', review_text) AS prompt
FROM `gemini_demo.customer_reviews`
WHERE customer_id = 8844
),
STRUCT(
0.2 AS temperature, TRUE AS flatten_json_output)));
此查询旨在使用 Gemini Pro 分析顾客评价并生成适当的回复和行动计划,从而实现客户服务回复的自动化。这是一个有说服力的示例,说明了如何利用 Google Cloud 来提升客户服务和改善经营活动。运行此查询后,将创建 customer_reviews_cs_response 表。
您可以通过运行下方的 SQL 查询来查看该表的详细信息。
SELECT * FROM `gemini_demo.customer_reviews_cs_response`
在此项任务中,您将使用 Gemini(您创建的 Gemini Pro 和 Vision 模型)分析图片,并生成相应的关键字和摘要。
使用 Gemini Pro Vision 模型分析图片
点击 + 以创建一个新的 SQL 查询。
在查询编辑器中,粘贴下方的查询并运行。
CREATE OR REPLACE TABLE
`gemini_demo.review_images_results` AS (
SELECT
uri,
ml_generate_text_llm_result
FROM
ML.GENERATE_TEXT( MODEL `gemini_demo.gemini_pro_vision`,
TABLE `gemini_demo.review_images`,
STRUCT( 0.2 AS temperature,
'For each image, provide a summary of what is happening in the image and keywords from the summary. Answer in JSON format with two keys: summary, keywords. Summary should be a string, keywords should be a list.' AS PROMPT,
TRUE AS FLATTEN_JSON_OUTPUT)));
…可帮助您充分利用 Google Cloud 技术。我们的课程会讲解各项技能与最佳实践,可帮助您迅速上手使用并继续学习更深入的知识。我们提供从基础到高级的全方位培训,并有点播、直播和虚拟三种方式选择,让您可以按照自己的日程安排学习时间。各项认证可以帮助您核实并证明您在 Google Cloud 技术方面的技能与专业知识。
本手册的最后更新时间:2025 年 2 月 13 日
本实验的最后测试时间:2025 年 2 月 13 日
版权所有 2025 Google LLC 保留所有权利。Google 和 Google 徽标是 Google LLC 的商标。其他所有公司名和产品名可能是其各自相关公司的商标。