调用文本理解模型,对文本进行情感分类、主题分类或信息抽取。
重要
当前仅支持华北2(北京)区域的PolarDB PostgreSQL标准版集群调用内置模型。
语法
text AI_Text_Classification(text content);
text AI_Text_Classification(text content, text model_id);
参数
参数名称 | 描述 |
content | 需要分类的文本。 |
model_id | 指定model_id,如不指定则默认调用内置模型 |
返回值
返回分类或抽取的结果。
描述
本函数可直接使用,无需创建模型,默认调用内置模型
_dashscope/text-classfication/opennlu-v1
执行主题、情感分类或信息抽取等任务。可通过指定model_id参数,调用其他已存在的文本理解模型。
内置模型
_dashscope/text-classfication/opennlu-v1
详细介绍请参考文本理解。
准备工作
当前内置模型主要集成了阿里云大模型服务平台百炼中提供的自然语言处理模型。
设置模型的Token信息:请使用AI_SetModelToken函数绑定您阿里云大模型服务平台百炼的API Key。
修改模型调用地址:请使用AI_AlterModel函数修改内置模型的调用地址,将原有地址替换为阿里云大模型服务平台百炼的私网连接(PrivateLink),即将
https://dashscope.aliyuncs.com
更改为http://vpc-cn-beijing.dashscope.aliyuncs.com
。例如:SELECT polar_ai.AI_AlterModel('_dashscope/text-classfication/opennlu-v1', model_url=>'http://vpc-cn-beijing.dashscope.aliyuncs.com/api/v1/services/nlp/nlu/understanding');
示例
不指定model_id参数。
SELECT polar_ai.ai_text_classification('老师今天表扬我了');
返回结果如下:
--- 积极
指定model_id参数,此处model_id指定为内置模型
_dashscope/text-classfication/opennlu-v1
。SELECT polar_ai.ai_text_classification('这家饭店的菜真难吃', '_dashscope/text-classfication/opennlu-v1');
返回结果如下:
--- 消极
该文章对您有帮助吗?