テキストからSQLへのデータビルダー

テキストから SQL データビルダは、データベース操作を記述する自然言語文と、そのデータベース操作を実行する等価な SQL ステートメント含む合成 SQL データを生成します。

注: 現在、自然言語による声明は英語で書かれなければならない。

シードデータ形式

プレーンテキストのサンプルステートメント含む入力YAMLファイルを作成します。 このファイルに以下の情報を追加します。

  • リレーショナル・データベースに格納されたデータに対して実行する操作
  • 各操作を実行するSQLクエリ
  • データがどのように構成され、保存されるかを定義するデータベーススキーマ

YAMLファイルには以下の構造を使用します:

task_description: <Description of this task>
seed_examples:
   - utterance: <input question 1>
     query: <sample SQL 1>
   - utterance: <input question 2>
     query: <sample SQL 2>
database:
   schema: "<Data Definition Language (DDL) statement of one or more tables. Separate each DDL by a semi-colon>"

サンプルシードデータ

text to SQL データ・ビルダー用のサンプル・シード・データをダウンロードするには、 watsonx -ai-samples を参照のこと。

JSONファイルのリクエストボディの例

以下のリクエストボディは、text to SQLデータビルダーを使用する非構造化合成データ生成ジョブ設定を持っています。 トークンを生成するための高度な設定が追加されています。

{
    "project_id": "<ID of the project to create the job in>",
    "name": "<Name of the job that you want to create>",
    "description": "<Description for the job>",
    "configuration": {
        "pipeline": "nl2sql",
        "num_outputs_to_generate": <A value between 1 to 1000>,
        "overwrite_output_file": false,
        "generator": {
            "model_id": "<LLM. For example ibm/granite-3-8b. For models deployed on demand, this is the deployment_id>",
            "temperature": 0.5,
            "max_new_tokens": 1024,
            "min_new_tokens": 100,
            "decoding_method": "sample",
            "top_p": 0.9,
            "top_k": 50
        },
        "validators": [            
            {
                "type": "rouge_scorer",
                "threshold": 0.9
            }
        ],
        "seed_data_reference": {
            "type": "container",
            "location": {
                "path": "<YAML file name in project assets. For example qna_know_seed.yaml>"
            }
        },
        "results_reference": {
            "type": "container",
            "location": {
                "path": "<File name for the generated data output. For example sdg-output-know.jsonl>"
            }
        }
    },
    "job": {
        "schedule": "0 0 1 * *",
        "schedule_info": {
            "repeat": true,
            "startOn": 1547578689512,
            "endOn": 1547578689512
        }
    }
}