AI_SUMMARIZE_AGG

AI_SUMMARIZE_AGG

텍스트 데이터 컬럼을 요약해요.

예를 들어, AI_SUMMARIZE_AGG(churn_reason)은 churn_reason 컬럼의 요약을 반환해요.

AI_COMPLETE 및 AI_SUMMARIZE와 달리, 이 함수는 최대 언어 모델 컨텍스트 창보다 큰 데이터셋을 지원해요.

출처: Snowflake AI_SUMMARIZE_AGG 함수 문서

본문

참고 항목: AI_AGG

구문 (Syntax)

AI_SUMMARIZE_AGG(  )

인자 (Arguments)

필수:

  • expr — 요약할 텍스트를 포함하는 표현식이에요. 예: 레스토랑 리뷰 또는 전화 기록.

반환 값 (Returns)

표현식의 문자열 요약을 반환해요.

사용 노트 (Usage Notes)

이 함수는 일반적인 목적의 요약을 제공해요. 더 구체적인 요약이 필요하면 AI_AGG를 사용해요.

예제 (Examples)

AI_SUMMARIZE_AGG는 문자열 상수에 대한 간단한 스칼라 함수로 사용할 수 있어요.

SELECT AI_SUMMARIZE_AGG('The restaurant was excellent. I especially enjoyed the pizza and ice cream. My grandma didnt like it though.');
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는 데이터 컬럼에 사용할 수 있어요.

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;
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는 CONCAT 또는 || 연산자를 사용하여 여러 데이터 컬럼에 사용할 수 있어요.

WITH reviews AS (
            SELECT 'The restaurant was excellent.' AS review, 'Pizza' AS menu_item
  UNION ALL SELECT 'Excellent! I loved the pizza!', 'Pizza'
  UNION ALL SELECT 'It was great, but the service was meh.', 'Burger'
  UNION ALL SELECT 'Mediocre food and mediocre service', 'Pancakes'
)
SELECT AI_SUMMARIZE_AGG('Menu Item: ' || menu_item || '\nReview: ' || review)
  FROM reviews;
The restaurant received positive reviews for its pizza, with one reviewer describing it as "excellent" and another stating they "loved" it. In contrast, the burger received a mixed review, with the food being "great" but the service being "meh." The pancakes were rated as "mediocre" in terms of both food and service. Overall, the restaurant's performance varied depending on the menu item, with pizza being a highlight.

AI_SUMMARIZE_AGG는 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;
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 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.                                                                                          |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

AI_AGG도 참고하세요.

법적 고지는 Snowflake AI and ML 문서를 참고해요.

더 알아보기