Pipelines models reference
==========================

EDB Postgres
AI-AIアクセラレーターパイプラインモデルのこのリファレンスドキュメントには、
:ref:`Pipelines models reference <Pipelines models reference>` で作業するためのaidb拡張機能で使用可能なファンクションとビューに関する情報が含まれています。

テーブル
--------

helpb.model_providers
^^^^^^^^^^^^^^^^^^^^^

``aidb.model_providers``
テーブルには、使用可能なモデルプロバイダーに関する情報が保存されます。

.. csv-table::
  :header: Column,Type,Description
  :widths: 12,15,25
  :align: left
  :class: longtable

  `server_name`,name,モデルサーバーの名前
  `server_description`,text,モデルサーバーの説明
  `server_options`,text\[\],モデルサーバーのオプション

helpb.models
^^^^^^^^^^^^

レジストリ内のすべてのモデルとその構成済みオプションのリストを返します。事前定義されたモデルやユーザー作成モデルを含みます。

.. csv-table::
  :header: Column,Type,Description
  :widths: 12,15,25
  :align: left
  :class: longtable

  `name`,text,モデルのユーザー定義の名前
  `provider`,text,モデルプロバイダーの名前
  `options`,jsonb,モデルプロバイダーのオプションの構成

例
^^

.. code:: sql

   SELECT * FROM aidb.models;
   __OUTPUT__
    name  |  provider  |    options
   - ------+------------+---------------
    bert  | bert_local | {"config={}"}
    clip  | clip_local | {"config={}"}
    t5    | t5_local   | {"config={}"}

ファンクション
--------------

promoteb.create_model
^^^^^^^^^^^^^^^^^^^^^

名前、プロバイダー、およびオプションの構成を保存することにより、システムに新しいモデルを作成します。

パラメーター
^^^^^^^^^^^^

.. csv-table::
  :header: Parameter,Type,Default,Description
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  `name`,text,"",モデルのユーザー定義の名前。
  `provider`,text,"",モデルプロバイダーの名前 :ref:`helpb.model_providers<helpb.model_providers>` にあります。
  `config`,jsonb,'{}'::jsonb,モデルプロバイダーのオプションの構成。 `model`、`url`、TLSオプション`tls_config`などのモデル固有のパラメーターが含まれる場合があります。
  `credentials`,jsonb,'{}'::jsonb,モデルプロバイダーのオプションの資格情報。
  `replace_credentials`,boolean,false,trueの場合、モデルプロバイダーの資格情報を置き換えます。 falseの場合、資格情報は上書きされません。

.. _例-1:

例
^^

.. code:: sql

   SELECT aidb.create_model(
                  name => my_t5::text,
                  provider => t5_local::character varying,
                  config => {"param1": "value1", "param2": "value2"}::jsonb,
                  credentials => {"token": "abcd"}::jsonb
              );

または同等のデフォルト値を使用して

.. code:: sql

   SELECT aidb.create_model(my_t5, t5_local);

または、既に作成されたモデルのプロバイダーの資格情報を更新する場合。

.. code:: sql

   SELECT aidb.create_model(
                  name => my_t5::text,
                  provider => t5_local::character varying,
                  config => {"param1": "value1", "param2": "value2"}::jsonb,
                  credentials => {"token": "abcd"}::jsonb,
                  replace_credentials => true
              );

TLS構成オプショナル
^^^^^^^^^^^^^^^^^^^

HTTPSベースのモデルエンドポイントに安全に接続するために、\ ``config``
オブジェクトに\ ``tls_config`` フィールドを含めることができます。

.. code:: json

   "tls_config": {
     "insecure_skip_verify": true,  // (optional) disables certificate validation
     "ca_path": "/etc/aidb/myCA.pem"  // (optional) path to a trusted CA certificate
   }

promoteb.get_model
^^^^^^^^^^^^^^^^^^

レジストリ内のモデルの構成を結果ます。

.. _パラメーター-1:

パラメーター
^^^^^^^^^^^^

.. csv-table::
  :header: Parameter,Type,Default,Description
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  `model_name`,text,"",モデルの名前

返品
^^^^

.. csv-table::
  :header: Column,Type,Description
  :widths: 12,15,25
  :align: left
  :class: longtable

  `name`,text,モデルのユーザー定義の名前
  `provider`,text,モデルプロバイダーの名前
  `options`,jsonb,モデルプロバイダーのオプションの構成

.. _例-2:

例
^^

.. code:: sql

   SELECT * FROM aidb.get_model(t5);
   __OUTPUT__
    name | provider |    options
   - -----+----------+---------------
    t5   | t5_local | {"config={}"}
   (1 row)

promoteb.delete_model
^^^^^^^^^^^^^^^^^^^^^

レジストリからモデルを削除します。

.. _パラメーター-2:

パラメーター
^^^^^^^^^^^^

.. csv-table::
  :header: Parameter,Type,Default,Description
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  `model_name`,text,"",モデルの名前

.. _例-3:

例
^^

.. code:: sql

   SELECT aidb.delete_model(t5);
   __OUTPUT__
        delete_model
   - --------------------------------
    (t5,t5_local,"{""config={}""}")
   (1 row)

.. _返品-1:

返品
^^^^

.. csv-table::
  :header: Column,Type,Description
  :widths: 12,15,25
  :align: left
  :class: longtable

  `delete_model`,jsonb,削除されたモデルの名前、プロバイダー、およびオプション

promoteb.list_hcp_models
^^^^^^^^^^^^^^^^^^^^^^^^

ハイブリッドマネージャーで実行されているモデルを取得します。

.. _返品-2:

返品
^^^^

.. csv-table::
  :header: Column,Type,Description
  :widths: 12,15,25
  :align: left
  :class: longtable

  `name`,text,HCPで実行されているモデルインスタンスの名前
  `url`,text,HCPで実行されているモデルのAPI URL
  `model`,text,HCPで実行されているモデルの名前

.. _例-4:

例
^^

.. code:: sql

   SELECT * FROM  aidb.get_hcp_models();
                    name                  |                                       url                                        |               model                
   - --------------------------------------+----------------------------------------------------------------------------------+------------------------------------
    llama-3-1-8b-instruct-1xgpu-g6        | http://llama-3-1-8b-instruct-1xgpu-g6-predictor.default.svc.cluster.local        | meta/llama-3.1-8b-instruct
    llama-3-2-nv-embedqa-1b-v2            | http://llama-3-2-nv-embedqa-1b-v2-predictor.default.svc.cluster.local            | nvidia/llama-3.2-nv-embedqa-1b-v2
    meta-nim-llama3-70b-instruct-8xgpu-g5 | http://meta-nim-llama3-70b-instruct-8xgpu-g5-predictor.default.svc.cluster.local | meta/llama3-70b-instruct
   (3 rows)

promoteb.create_hcp_model
^^^^^^^^^^^^^^^^^^^^^^^^^

HCPで実行中のインスタンスを参照することにより、システムに新しいモデルを作成します

.. _パラメーター-3:

パラメーター
^^^^^^^^^^^^

.. csv-table::
  :header: Parameter,Type,Default,Description
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  `name`,text,"",モデルのユーザー定義名
  `hcp_model_name`,text,"",HCPで実行されているモデルインスタンスの名前

promoteb.sync_hcp_models
^^^^^^^^^^^^^^^^^^^^^^^^

HCPでモデルを作成し、\ ``is_hcp_model=true`` を設定します。
HCPで見つからない場合、その設定を持つモデルを削除します。

.. _返品-3:

返品
^^^^

.. csv-table::
  :header: Column,Type,Description
  :widths: 12,15,25
  :align: left
  :class: longtable

  `status`,text,同期ステータス。 `deleted`、`unchanged`、`created`、または`skipped`のいずれか。
  `model`,text,同期HCPモデルの名前。

helpb.encode_text
^^^^^^^^^^^^^^^^^

モデルを使用してテキストをエンコードし、指定されたテキスト入力のベクトル表現を生成します。

.. _パラメーター-4:

パラメーター
^^^^^^^^^^^^

.. csv-table::
  :header: Parameter,Type,Default,Description
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  `model_name`,text,"",エンコードするモデルの名前
  `text`,text,"",エンコードするテキスト

helpb.encode_text_batch
^^^^^^^^^^^^^^^^^^^^^^^

モデルを使用してテキストのバッチをエンコードし、指定されたテキスト入力のベクトル表現を生成します。

.. _パラメーター-5:

パラメーター
^^^^^^^^^^^^

.. csv-table::
  :header: Parameter,Type,Default,Description
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  `model_name`,text,"",エンコードするモデルの名前
  `text`,text\[\],"",エンコードするテキストの配列

promoteb.decode_text
^^^^^^^^^^^^^^^^^^^^

モデルを使用してテキストをデコードし、指定されたテキスト入力のベクトル表現を生成します。

.. _パラメーター-6:

パラメーター
^^^^^^^^^^^^

.. csv-table::
  :header: Parameter,Type,Default,Description
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  `model_name`,text,"",デコードするモデルの名前
  `text`,text,"",デコードするテキスト

.. _返品-4:

返品
^^^^

.. csv-table::
  :header: Column,Type,Description
  :widths: 12,15,25
  :align: left
  :class: longtable

  `decode_text`,text,デコードされたテキスト

promoteb.decode_text_batch
^^^^^^^^^^^^^^^^^^^^^^^^^^

モデルを使用してテキストのバッチをデコードし、指定されたテキスト入力の表現を生成します。

.. _パラメーター-7:

パラメーター
^^^^^^^^^^^^

.. csv-table::
  :header: Parameter,Type,Default,Description
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  `model_name`,text,"",デコードするモデルの名前
  `text`,text\[\],"",デコードするテキストの配列

.. _返品-5:

返品
^^^^

.. csv-table::
  :header: Column,Type,Description
  :widths: 12,15,25
  :align: left
  :class: longtable

  `decode_text`,text,デコードされたテキスト

promoteb.encode_image
^^^^^^^^^^^^^^^^^^^^^

モデルを使用して画像をエンコードし、指定された画像入力のベクトル表現を生成します。

.. _パラメーター-8:

パラメーター
^^^^^^^^^^^^

.. csv-table::
  :header: Parameter,Type,Default,Description
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  `model_name`,text,"",エンコードするモデルの名前
  `image`,bytea,"",エンコードする画像

.. _返品-6:

返品
^^^^

.. csv-table::
  :header: Column,Type,Description
  :widths: 12,15,25
  :align: left
  :class: longtable

  `encode_image`,bytea,エンコードされた画像

helpb.rerank_text
^^^^^^^^^^^^^^^^^

モデルを使用してテキストを再ランク付けし、指定されたテキスト入力のベクトル表現を生成します。

.. _パラメーター-9:

パラメーター
^^^^^^^^^^^^

.. csv-table::
  :header: Parameter,Type,Default,Description
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  `model_name`,text,"",リランキングするモデルの名前
  `query`,text,"",入力がランク付けされるクエリ
  `input`,text\[\],\[\],ランク付けの入力

.. _返品-7:

返品
^^^^

.. csv-table::
  :header: Column,Type,Description
  :widths: 12,15,25
  :align: left
  :class: longtable

  `text`,text,"""input""からのテキスト"
  `logit_score`,double precision,このテキストのスコア/ランク
  `id`,int,テキストが入力配列に持っていたインデックス
