PostgresML是PostgreSQL的机器学习扩展,能让你使用SQL查询对文本和表格数据进行训练和推理。有了PostgresML,你可以将机器学习模型无缝集成到PostgreSQL数据库中,并利用尖端算法的强大功能高效处理数据。
- 执行自然语言处理任务,如情感分析、提问和回答、翻译、总结和文本生成
- 从 HuggingFace 模型 Hub 访问数千种最先进的语言模型,如 GPT-2、GPT-J 和 GPT-Neo
- 针对不同任务,在自己的文本数据上微调大型语言模型
- 将现有的 PostgreSQL 数据库用作向量数据库,从存储在数据库中的文本生成 embedding
针对文本数据操作:
翻译
SQL 查询
SELECT pgml.transform(
'translation_en_to_fr',
inputs => ARRAY[
'Welcome to the future!',
'Where have you been all this time?'
]
) AS french;
结果
french
------------------------------------------------------------
[
{"translation_text": "Bienvenue à l'avenir!"},
{"translation_text": "Où êtes-vous allé tout ce temps?"}
]
情感分析 SQL 查询
SELECT pgml.transform(
task => 'text-classification',
inputs => ARRAY[
'I love how amazingly simple ML has become!',
'I hate doing mundane and thankless tasks. ☹️'
]
) AS positivity;
结果
positivity
------------------------------------------------------
[
{"label": "POSITIVE", "score": 0.9995759129524232},
{"label": "NEGATIVE", "score": 0.9903519749641418}
]
针对表格数据操作:
训练分类模型
训练
SELECT * FROM pgml.train(
'Handwritten Digit Image Classifier',
algorithm => 'xgboost',
'classification',
'pgml.digits',
'target'
);
推理
SELECT pgml.predict(
'My Classification Project',
ARRAY[0.1, 2.0, 5.0]
) AS prediction;
评论