- 카테고리:
집계 함수 (일반) 문자열 및 이진 함수 (AI 함수)
AI_SUMMARIZE_AGG¶
텍스트 데이터 열을 요약합니다.
예를 들어 AI_SUMMARIZE_AGG(churn_reason)
은 churn_reason
열의 요약을 반환합니다.
AI_COMPLETE 및 SUMMARIZE (SNOWFLAKE.CORTEX) 와 달리, 이 함수는 최대 언어 모델 컨텍스트 윈도우보다 큰 데이터 세트를 지원합니다.
- 참고 항목:
구문¶
AI_SUMMARIZE_AGG( <expr> )
인자¶
필수:
expr
레스토랑 리뷰나 전화 녹취록과 같이 요약할 수 있는 텍스트를 포함하는 식입니다.
반환¶
식의 문자열 요약을 반환합니다.
사용법 노트¶
이 함수는 일반적인 목적의 요약을 제공합니다. 보다 구체적인 요약을 보려면 AI_AGG 를 사용하십시오.
예¶
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 를 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 도 참조하십시오.