情感提取¶
备注
AI_SENTIMENT 是 ENTITY_SENTIMENT (SNOWFLAKE.CORTEX) 的更新版本。要获得最新功能,请使用 AI_SENTIMENT。
AI_SENTIMENT 函数能提供跨市场与多语言场景的尖端情感分类质量。通过 AI_SENTIMENT,您可获得整体性与细粒度的基于方面的情感分析,适用于以下用例场景:
社交媒体监控
详细的产品分析
全面的品牌认知研究
高级市场情报
员工参与度分析
客户体验旅程图
内容效果分析
客户支持优化
情感提取质量¶
AI_SENTIMENT 采用定制化的 Snowflake 大语言模型,在整体情感分析与基于方面的情感分析精度上达到行业领先水平。以下表格展示了 AI_SENTIMENT 在整体情感分析与基于方面的情感分析 (ABSA-mix) 基准测试中,相较于主流模型的表现数据。多语言基准测试涵盖英语、西班牙语、法语、德语、印地语、意大利语及葡萄牙语。
备注
部分参与基准测试的模型未在 Snowflake Cortex 平台提供。
模型
|
基于方面的情绪
准确性 (
ABSA-mix ) |
基于方面的情绪
准确性 (
ABSA-multilingual ) |
整体情绪准
准确性
|
整体情绪准
准确性(多语言)
|
---|---|---|---|---|
Cortex AI |
0.92 |
0.81 |
0.83 |
0.83 |
|
0.84 |
0.79 |
0.75 |
0.82 |
|
0.83 |
0.80 |
0.77 |
0.78 |
|
0.83 |
0.73 |
0.80 |
0.78 |
|
0.82 |
0.79 |
0.71 |
0.76 |
|
0.82 |
0.79 |
0.71 |
0.76 |
AWS |
0.62 |
0.64 |
调用 AI_SENTIMENT 函数¶
默认情况下,Cortex AI_SENTIMENT 会返回整体内容的综合情感评分。但是,AI_SENTIMENT 能够获取一系列客户意见,而不仅限于整体正面、负面和中性分类。对于这项可选的基于方面的情感分析功能,需指定要分析的内容(如客户评论或产品评价)及其需要分析情感的方向(也称为实体或类别)。AI_SENTIMENT 将返回每个实体的情感分析结果及整体情感评分。若仅需获取整体情感评分,只需指定内容而不需提供分析方向。
英语示例¶
以下示例使用 AI_SENTIMENT 来获取产品评价的情绪分类。
SELECT AI_SENTIMENT('I went to the store, bought the leggings and exact same as shorts...
they are expensive but i heard such great things. After wearing them twice i noticed a string popping out already.
And aince i believed that they were this amazing luxury brand i didnt keep the receipt 😭 ');
返回值:
{
"categories": [
{
"name": "overall",
"sentiment": "mixed"
}
]
}
以下示例使用 AI_SENTIMENT 功能获取餐厅评论中特定方面的情感分类结果。
SELECT AI_SENTIMENT('A tourist\'s delight, in low urban light,
Recommended gem, a pizza night sight. Swift arrival, a pleasure so right,
Yet, pockets felt lighter, a slight pricey bite. 💰🍕🚀',
['Cost', 'Quality' ,'Wait Time']);
返回值:
{
"categories": [
{
"name": "overall",
"sentiment": "mixed"
},
{
"name": "Cost",
"sentiment": "negative"
},
{
"name": "Quality",
"sentiment": "positive"
},
{
"name": "Wait Time",
"sentiment": "positive"
}
]
}
若指定的某些方面不适用于所提供的文本,AI_SENTIMENT 会返回“unknown”标识,如下示例中“Professionalism”与“Brand”所示。
SELECT AI_SENTIMENT('A tourist\'s delight, in low urban light,
Recommended gem, a pizza night sight. Swift arrival, a pleasure so right,
Yet, pockets felt lighter, a slight pricey bite. 💰🍕🚀',
['Cost', 'Professionalism' ,'Brand']);
返回值:
{
"categories": [
{
"name": "overall",
"sentiment": "mixed"
},
{
"name": "Brand",
"sentiment": "unknown"
},
{
"name": "Cost",
"sentiment": "negative"
},
{
"name": "Professionalism",
"sentiment": "unknown"
}
]
}
多语言示例¶
如下两个相似示例所示,AI_SENTIMENT 支持多语言情感分析,无需翻译文本即可避免语义丢失风险。您无需指定文本的语言。分析方向可采用文本原语言指定(如下例所示),亦可使用英语指定(如第二例所示)。
备注
AI_SENTIMENT 支持英语、法语、德语、印地语、意大利语、西班牙语和葡萄牙语。
文本与标签均为西班牙语的示例:
SELECT AI_SENTIMENT ('Pedí dos pares del mismo modelo en diferentes colores.
Uno tenía defectos en la costura y el cuero se veía de menor calidad.
Por 350€ el par, esto es inaceptable. El servicio al cliente tardó una
semana en responder y la solución no fue satisfactoria. Es una pena porque
cuando están bien hechos, son zapatos hermosos. Pero la inconsistencia en la
calidad es preocupante.', ['Calidad', 'Calidad de Servicio,' 'Precio', 'Tiempo de Espera']);
返回值:
{
"categories": [
{
"name": "overall",
"sentiment": "negative"
},
{
"name": "Calidad",
"sentiment": "negative"
},
{
"name": "Calidad de Servicio",
"sentiment": "negative"
},
{
"name": "Precio",
"sentiment": "negative"
},
{
"name": "Tiempo de Espera",
"sentiment": "negative"
}
]
}
文本为德语且标签为英语的示例:
SELECT AI_SENTIMENT ('Die Schuhe selbst sind wirklich schön und gut verarbeitet.
Das Leder ist weich und die Passform stimmt. Allerdings gab es erhebliche
Verzögerungen bei der Lieferung - statt der versprochenen 5 Tage hat es 3
Wochen gedauert. Der Kundenservice war freundlich, aber nicht sehr hilfreich.
Für 320€ erwarte ich besseren Service. Die Schuhe sind in Ordnung, aber das
Gesamterlebnis war mittelmäßig', ['Quality', 'Price', 'Service', 'WaitTime']);
返回值:
{
"categories": [
{
"name": "overall",
"sentiment": "mixed"
},
{
"name": "Price",
"sentiment": "neutral"
},
{
"name": "Quality",
"sentiment": "positive"
},
{
"name": "Service",
"sentiment": "neutral"
},
{
"name": "WaitTime",
"sentiment": "negative"
}
]
}
模型限制¶
Snowflake Cortex LLMs 中可用的所有大型语言模型 (AI) 都对输入和输出词元的总数有限制,这称为模型的 上下文窗口。
AI_SENTIMENT 的上下文窗口经过设置,可持续保持高精度水平。AI_SENTIMENT 针对 2048 个词元(约 1600 词)的文本输入进行了训练与优化。最多可以指定十个方面,每个方面不超过三十个字符。
函数 |
上下文窗口(词元) |
最大实体标签数量 |
---|---|---|
AI_SENTIMENT |
2,048 |
10 |