- Kategorien:
Aggregatfunktionen (Allgemein) Zeichenfolgen- und Binärfunktionen (AI-Funktionen)
AI_SUMMARIZE_AGG¶
Fasst eine Spalte mit Textdaten zusammen.
Zum Beispiel gibt AI_SUMMARIZE_AGG(churn_reason)
eine Zusammenfassung der Spalte churn_reason
zurück.
Im Gegensatz zu AI_COMPLETE und SUMMARIZE (SNOWFLAKE.CORTEX) unterstützt diese Funktion Datensätze, die größer sind als das maximale Kontextfenster des Sprachmodells.
- Siehe auch::
Syntax¶
AI_SUMMARIZE_AGG( <expr> )
Argumente¶
Benötigt:
expr
Dies ist ein Ausdruck, der Text für die Zusammenfassung enthält, z. B. Restaurantkritiken oder Telefonaufzeichnungen.
Rückgabewerte¶
Gibt eine Zusammenfassung des Ausdrucks als Zeichenfolge zurück.
Nutzungshinweise¶
Diese Funktion bietet eine allgemeine Zusammenfassung. Eine genauere Zusammenfassung finden Sie unter AI_AGG.
Beispiele¶
AI_SUMMARIZE_AGG kann als einfache skalare Funktion für Zeichenfolgenkonstanten verwendet werden.
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 kann auf eine Datenspalte angewendet werden.
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 kann auch in Kombination mit GROUP BY verwendet werden.
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. |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Siehe auch AI_AGG.