1
0

More than 1 year has passed since last update.

DatabricksのAI Functionsを使ってみる

Posted at

こちらの機能を試してみます。

こちらのブログで詳細が説明されています。

要はSQLから大規模言語モデル(LLM)を呼び出せる機能です。素敵ですね。

準備

ここでは、Open AI APIを使いますので、Open AIのAPIキーを取得します。

このAPIキーをDatabricksシークレットに登録します。

また、この機能はパブリックプレビューです。パブリックプレビューに参加するには、AI Functions Public Preview enrollment formを提出してください。

AI Functionの作成

以下のSQLを実行して関数を作成します。以下の例では、シークレットスコープdemo-token-takaaki.yayoi、シークレットキーopenai_api_keyにOpen AI APIのキーが格納されているものとします。

SQL
CREATE OR REPLACE FUNCTION quickstart_catalog_taka.default.PROMPT_HANDLER(prompt STRING)
RETURNS STRING
RETURN AI_GENERATE_TEXT(prompt,
  "openai/gpt-3.5-turbo",
  "apiKey", SECRET("demo-token-takaaki.yayoi", "openai_api_key"),
  "temperature", CAST(0.0 AS DOUBLE)
);

AI Functionの実行

SQL
SELECT quickstart_catalog_taka.default.PROMPT_HANDLER("What is Databricks?")
Databricks is a cloud-based data processing and analytics platform that provides a unified workspace for data engineers, data scientists, and business analysts to collaborate and work on big data projects. It is built on top of Apache Spark, an open-source big data processing engine, and provides a range of tools and services for data ingestion, processing, analysis, and visualization. Databricks also offers machine learning capabilities, including automated machine learning, deep learning, and natural language processing, to help organizations build and deploy AI models at scale.

動きました!

Databricksクイックスタートガイド

Databricksクイックスタートガイド

Databricks無料トライアル

Databricks無料トライアル

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0