Categorias:

Funções de agregação (geral) Funções de cadeia de caracteres e binários (funções de AI)

AI_SUMMARIZE_AGG

Resume uma coluna de dados de texto.

Por exemplo, AI_SUMMARIZE_AGG(churn_reason) retornará um resumo da coluna churn_reason.

Ao contrário de AI_COMPLETE e SUMMARIZE (SNOWFLAKE.CORTEX), essa função suporta conjuntos de dados maiores do que a janela máxima de contexto do modelo de linguagem.

Consulte também:

AI_AGG

Sintaxe

AI_SUMMARIZE_AGG( <expr> ) 
Copy

Argumentos

Obrigatório:

expr

Essa é uma expressão que contém texto para resumo, como avaliações de restaurantes ou transcrições telefônicas.

Retornos

Retorna um resumo da cadeia de caracteres da expressão.

Notas de uso

Essa função fornece um resumo de propósito geral. Para obter um resumo mais específico, use AI_AGG.

Exemplos

AI_SUMMARIZE_AGG pode ser usado como uma função escalar simples em constantes de cadeia de caracteres.

SELECT AI_SUMMARIZE_AGG('The restaurant was excellent. I especially enjoyed the pizza and ice cream. My grandma didnt like it though.'); 
Copy
The restaurant received mixed reviews from our group. While I thoroughly enjoyed the pizza and ice cream, my grandma did not have a positive experience. 

AI_SUMMARIZE_AGG pode ser usado em uma coluna de dados.

WITH reviews AS ( SELECT 'The restaurant was excellent.' AS review UNION ALL SELECT 'Excellent! I loved the pizza!' UNION ALL SELECT 'It was great, but the service was meh.' UNION ALL SELECT 'Mediocre food and mediocre service' ) SELECT AI_SUMMARIZE_AGG(review) FROM reviews; 
Copy
The restaurant received mixed reviews. Some customers had a great experience, enjoying the pizza and finding the restaurant excellent. However, others had a more neutral experience, describing the food and service as mediocre, with one customer specifically mentioning that the service was subpar. 

AI_SUMMARIZE_AGG também pode ser usado em combinação com GROUP BY.

WITH reviews AS ( SELECT 1 AS product_id, 'The restaurant was excellent.' AS review UNION ALL SELECT 1, 'Excellent! I loved the pizza!' UNION ALL SELECT 1, 'It was great, but the service was meh.' UNION ALL SELECT 1, 'Mediocre food and mediocre service' UNION ALL SELECT 2, 'Terrible quality ingredients, I should have eaten at home.' UNION ALL SELECT 2, 'Bad restaurant, I would avoid this place.' ) SELECT product_id, AI_SUMMARIZE_AGG(review) AS summarized_review FROM reviews GROUP BY 1; 
Copy
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | PRODUCT_ID | SUMMARIZED_REVIEW | |------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | 1 | The restaurant received mixed reviews. Some customers had a great experience, enjoying the pizza and finding the restaurant excellent. However, others had a more neutral experience, describing the food and service as mediocre, with one customer specifically mentioning that the service was subpar. | +------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | 2 | The reviewer had a poor experience at the restaurant, citing the use of low-quality ingredients and expressing regret over not eating at home instead. They strongly advise against visiting this establishment. | +------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 

Consulte também AI_AGG.