Models reference#
AIDBのすべてのモデル関連のファンクションとビューのリファレンス。ガイドスタイルのドキュメントについては、 Integrating models を参照してください。
カタログビュー#
helpb.model_providers#
システムに登録されている使用可能なモデルプロバイダーをすべてリストします。
Column |
Type |
Description |
|---|---|---|
server_name |
name |
モデルプロバイダーの名前 |
server_description |
text |
プロバイダーの説明 |
server_options |
text[] |
使用可能な構成オプション |
helpb.models#
ビルトインおよびユーザー作成モデルを含む、レジストリ内のすべてのモデルをリストします。
Column |
Type |
Description |
|---|---|---|
name |
text |
モデルのユーザー定義の名前 |
provider |
text |
モデルプロバイダー名 |
options |
jsonb |
モデルの設定済みオプション |
例#
SELECT * FROM aidb.models;
__OUTPUT__
name | provider | options
- -------+------------+---------------
bert | bert_local | {"config={}"}
clip | clip_local | {"config={}"}
t5 | t5_local | {"config={}"}
(3 rows)
モデル管理機能#
promoteb.create_model#
新しいモデルをAIDBモデルレジストリに登録します。
パラメーター#
Parameter |
Type |
Default |
Description |
|---|---|---|---|
name |
TEXT |
Required |
モデルの一意の名前。 |
provider |
TEXT |
Required |
プロバイダー名 `aidb.model_providers`を参照してください。 |
config |
JSONB |
'{}' |
プロバイダー固有の構成。 モデル構成ヘルパー でビルドします。 |
credentials |
JSONB |
'{}' |
プロバイダーの資格情報たとえば {"api_key": "..."} 。 |
replace_credentials |
BOOLEAN |
false |
`true`の場合、モデルを再作成せずに保存されている資格情報を更新します。 |
TLS構成#
HTTPSモデルエンドポイントに接続するには、config
内にtls_config フィールドを含めます。
"tls_config": {
"insecure_skip_verify": true,
"ca_path": "/etc/aidb/myCA.pem"
}
例#
- - Minimal registration
SELECT aidb.create_model(my_t5, t5_local);
- - With config and credentials
SELECT aidb.create_model(
name => my_t5,
provider => t5_local,
config => {"param1": "value1"}::JSONB,
credentials => {"token": "abcd"}::JSONB
);
- - Rotate credentials without re-creating
SELECT aidb.create_model(
name => my_openai,
provider => openai_embeddings,
config => aidb.embeddings_config(model => text-embedding-3-small),
credentials => {"api_key": "<new-key>"}::JSONB,
replace_credentials => true
);
promoteb.get_model#
登録されたモデルの構成を返します。
パラメーター#
Parameter |
Type |
Description |
|---|---|---|
model_name |
TEXT |
取得するモデルの名前。 |
返品#
Column |
Type |
Description |
|---|---|---|
name |
text |
モデル名 |
provider |
text |
プロバイダー名 |
options |
jsonb |
設定されたオプション |
例#
SELECT * FROM aidb.get_model(t5);
__OUTPUT__
name | provider | options
- -----+----------+---------------
t5 | t5_local | {"config={}"}
(1 row)
promoteb.delete_model#
レジストリからモデルを削除します。次に実行されるまで、それを参照するパイプラインまたはナレッジベースには影響しません。
パラメーター#
Parameter |
Type |
Description |
|---|---|---|
model_name |
TEXT |
削除するモデルの名前。 |
返品#
JSONBとしての削除されたモデルの名前、プロバイダー、およびオプション。
例#
SELECT aidb.delete_model(t5);
__OUTPUT__
delete_model
- --------------------------------
(t5,t5_local,"{""config={}""}")
(1 row)
HCPモデルファンクション#
これらの機能は、EDB Hybrid ManagerHCPで実行されているモデルを管理します。
promoteb.list_hcp_models#
ハイブリッドマネージャーで現在実行されているモデルをリストします。
返品#
Column |
Type |
Description |
|---|---|---|
name |
text |
HCPでのモデルインスタンス名 |
url |
text |
APIエンドポイントURL |
model |
text |
モデル識別子 |
例#
SELECT * FROM aidb.list_hcp_models();
__OUTPUT__
name | url | model
- ------------------------------+------------------------------------------------------+------------------------------
llama-3-1-8b-instruct-1xgpu | http://llama-3-1-8b-predictor.default.svc.local | meta/llama-3.1-8b-instruct
(1 row)
promoteb.create_hcp_model#
実行中のインスタンス名を参照することにより、HCPホストモデルを登録します。
パラメーター#
Parameter |
Type |
Description |
|---|---|---|
name |
TEXT |
AIDB内のモデルのユーザー定義の名前。 |
hcp_model_name |
TEXT |
HCPで実行されているモデルインスタンスの名前。 |
promoteb.sync_hcp_models#
AIDBモデルレジストリを、現在HCPで実行されているモデルと同期します。新しいHCPモデルのエントリを作成し、そこで実行されなくなったモデルのエントリを削除します。
返品#
Column |
Type |
Description |
|---|---|---|
status |
text |
created、deleted、unchanged、または`skipped` |
model |
text |
同期モデルの名前 |
推論ファンクション#
helpb.encode_text#
指定されたモデルを使用して、単一のテキスト文字列をベクトルにエンコードします。
パラメーター#
Parameter |
Type |
Description |
|---|---|---|
model_name |
TEXT |
登録されているモデルの名前。 |
text |
TEXT |
エンコードするテキスト。 |
返品#
VECTOR —入力テキストの埋め込み。
例#
SELECT aidb.encode_text(bert_local, The quick brown fox);
helpb.encode_text_batch#
1回の呼び出しでテキスト文字列の配列をベクトルにエンコードします。
パラメーター#
Parameter |
Type |
Description |
|---|---|---|
model_name |
TEXT |
登録されているモデルの名前。 |
text |
TEXT[] |
エンコードする文字列の配列。 |
返品#
TABLE(id INT, value VECTOR) — 入力ごとに1行、 id
を介して入力順序を保存します。
promoteb.encode_image#
マルチモーダルモデルCLIPなどを使用して、バイナリイメージをベクトルにエンコードします。
パラメーター#
Parameter |
Type |
Description |
|---|---|---|
model_name |
TEXT |
登録されているモデルの名前。 |
image |
BYTEA |
Raw画像バイト。 |
返品#
VECTOR —入力画像の埋め込み。
例#
SELECT aidb.encode_image(clip_local, pg_read_binary_file(/tmp/photo.jpg)::BYTEA);
helpb.encode_image_batch#
1回の呼び出しでバイナリイメージの配列をベクトルにエンコードします。
パラメーター#
Parameter |
Type |
Description |
|---|---|---|
model_name |
TEXT |
登録されているモデルの名前。 |
images |
BYTEA[] |
生の画像バイトの配列。 |
返品#
TABLE(id INT, value VECTOR) —入力画像ごとに1行、 id
を介して入力順序を保存します。
promoteb.decode_text#
指定されたモデルを使用して、プロンプトからテキスト応答を生成します。
パラメーター#
Parameter |
Type |
Default |
Description |
|---|---|---|---|
model_name |
TEXT |
Required |
登録されているモデルの名前。 |
text |
TEXT |
Required |
テキストプロンプトまたは入力。 |
inference_config |
JSON |
NULL |
実行時推論設定。 :ref:``aidb.inference_config()` <#aidbinference_config>` を使用します。 |
返品#
TEXT — 生成されたレスポンス
例#
- - Basic usage
SELECT aidb.decode_text(t5_local, translate to French: Hello, world.);
- - With inference configuration
SELECT aidb.decode_text(
my_llama,
Explain quantum computing in one sentence.,
aidb.inference_config(
system_prompt => Be concise and factual.,
temperature => 0.7,
max_tokens => 100
)::json
);
promoteb.decode_text_batch#
1回の呼び出しで一連のプロンプトに対するテキスト応答を生成します。
パラメーター#
Parameter |
Type |
Default |
Description |
|---|---|---|---|
model_name |
TEXT |
Required |
登録されているモデルの名前。 |
input |
TEXT[] |
Required |
テキストプロンプトの配列。 |
inference_config |
JSON |
NULL |
実行時推論設定。 :ref:``aidb.inference_config()` <#aidbinference_config>` を使用します。 |
返品#
TABLE(id INT, value TEXT) — 入力プロンプトごとに1行。
例#
SELECT * FROM aidb.decode_text_batch(t5_local, ARRAY[
translate to German: hello,
translate to German: goodbye
]);
helpb.rerank_text#
リランキングモデルを使用して、クエリに対してテキスト入力セットをスコアリングおよびランク付けします。
パラメーター#
Parameter |
Type |
Default |
Description |
|---|---|---|---|
model_name |
TEXT |
Required |
登録されたリランキングモデルの名前。 |
query |
TEXT |
Required |
入力をランク付けするクエリー。 |
input |
TEXT[] |
[] |
ランク付けの候補テキストの配列。 |
返品#
Column |
Type |
Description |
|---|---|---|
text |
text |
候補テキスト |
logit_score |
double precision |
関連性スコア高いほど関連性が高い |
id |
int |
入力配列内のテキストの元のインデックス |
例#
SELECT * FROM aidb.rerank_text(
my_reranker,
How do I configure AIDB?,
ARRAY[
AIDB requires shared_preload_libraries.,
Postgres supports JSON natively.,
Run CREATE EXTENSION aidb CASCADE to install.
]
) ORDER BY logit_score DESC;
推論構成ヘルパー#
helpb.inference_config#
ランタイム推論設定のJSONB構成オブジェクトをビルドします。結果json
へのキャストをaidb.decode_text() 、aidb.decode_text_batch()
に渡すか、 aidb.summarize_text_config() で使用します。
すべてのパラメーターはオプショナル - 必要ないものは省略します。
パラメーター#
Parameter |
Type |
Default |
Description |
|---|---|---|---|
system_prompt |
TEXT |
NULL |
要求の前に追加されるシステムプロンプト。 T5モデルではサポートされていません。 |
temperature |
DOUBLE PRECISION |
NULL |
サンプリング温度。 `0.0`は決定的です。値が高いほど多様性が増します。 |
max_tokens |
INTEGER |
NULL |
生成する最大トークン。 |
top_p |
DOUBLE PRECISION |
NULL |
nucleusサンプリングしきい値。 |
seed |
BIGINT |
NULL |
再現可能な出力のランダムシード。 |
repeat_penalty |
REAL |
NULL |
トークンを繰り返す場合のペナルティ。 1.0 =ペナルティなし。 NIMまたはOpenAIではサポートされていません。 |
repeat_last_n |
INTEGER |
NULL |
`repeat_penalty`と考えられる最近のトークンの数。 NIMまたはOpenAIではサポートされていません。 |
thinking |
BOOLEAN |
NULL |
<think>`タグの処理を制御します。 `true/`NULL`はタグを保持します。 `false`はそれらを削除します。 |
extra_args |
JSONB |
NULL |
APIに直接渡される追加のプロバイダー固有の引数。 |
返品#
JSONB — 推論ファンクションに渡す前に::json にキャストします。
例#
- - With temperature and token limit
SELECT aidb.decode_text(
my_llama,
What is machine learning?,
aidb.inference_config(temperature => 0.5, max_tokens => 150)::json
);
- - Full configuration
SELECT aidb.decode_text(
my_llama,
Explain relativity.,
aidb.inference_config(
system_prompt => You are a physics professor. Be precise.,
temperature => 0.3,
max_tokens => 200,
top_p => 0.9,
seed => 42,
repeat_penalty => 1.1
)::json
);
- - Hide reasoning tags from a thinking model
SELECT aidb.decode_text(
my_reasoning_model,
Solve: 2x + 5 = 15,
aidb.inference_config(thinking => false)::json
);
モデル構成ヘルパー#
これらのファンクションは、 aidb.create_model() のconfig
パラメーターのJSONB
構成オブジェクトを結果ます。各ヘルパーは、特定のモデルプロバイダーに対応します。
promoteb.embeddings_config#
openai_embeddings およびOpenAI互換の埋め込みエンドポイントの場合。
Parameter |
Type |
Default |
Description |
|---|---|---|---|
model |
TEXT |
Required |
モデル識別子。 |
api_key |
TEXT |
NULL |
APIキー。 |
url |
TEXT |
NULL |
エンドポイントURLのオーバーライド。 |
basic_auth |
TEXT |
NULL |
基本認証 user:password |
max_concurrent_requests |
INTEGER |
NULL |
最大同時要求。 |
max_batch_size |
INTEGER |
NULL |
バッチごとの最大入力数。 |
input_type |
TEXT |
NULL |
入力タイプのヒントプロバイダー固有。 |
input_type_query |
TEXT |
NULL |
クエリ入力タイプのヒントプロバイダー固有。 |
tls_config |
JSONB |
NULL |
TLS構成。 |
is_hcp_model |
BOOLEAN |
NULL |
true モデルがHCPで実行される場合。 |
SELECT aidb.create_model(
my_embedder,
openai_embeddings,
config => aidb.embeddings_config(
model => text-embedding-3-small,
api_key => sk-...,
url => https://api.openai.com/v1
)
);
promoteb.completions_config#
openai_completions
およびOpenAI互換のコンプリートエンドポイントの場合。
Parameter |
Type |
Default |
Description |
|---|---|---|---|
model |
TEXT |
Required |
モデル識別子。 |
api_key |
TEXT |
NULL |
APIキー。 |
url |
TEXT |
NULL |
エンドポイントURLのオーバーライド。 |
basic_auth |
TEXT |
NULL |
基本認証 user:password |
system_prompt |
TEXT |
NULL |
デフォルトのシステムプロンプト。 |
temperature |
DOUBLE PRECISION |
NULL |
サンプリング温度。 |
top_p |
DOUBLE PRECISION |
NULL |
nucleusサンプリングしきい値。 |
seed |
BIGINT |
NULL |
ランダムシード。 |
thinking |
BOOLEAN |
NULL |
`<think>`タグの処理。 |
max_tokens |
JSONB |
NULL |
最大トークン構成 `aidb.max_tokens_config()`を使用します。 |
max_concurrent_requests |
INTEGER |
NULL |
最大同時要求。 |
extra_args |
JSONB |
NULL |
追加のプロバイダー固有の引数。 |
is_hcp_model |
BOOLEAN |
NULL |
true モデルがHCPで実行される場合。 |
SELECT aidb.create_model(
my_llm,
openai_completions,
config => aidb.completions_config(
model => gpt-4o,
api_key => sk-...,
temperature => 0.2
)
);
promoteb.max_tokens_config#
aidb.completions_config() で使用するmax_tokens
オブジェクトをビルドします。
Parameter |
Type |
Default |
Description |
|---|---|---|---|
size |
INTEGER |
Required |
生成する最大トークン。 |
format |
TEXT |
NULL |
形式 'default'、'legacy'、または`'both'` |
SELECT aidb.completions_config(
model => gpt-4o,
max_tokens => aidb.max_tokens_config(size => 1024, format => default)
);
promoteb.bert_config#
bert_local プロバイダーの場合。
Parameter |
Type |
Default |
Description |
|---|---|---|---|
model |
TEXT |
Required |
HuggingFaceモデル識別子。 |
revision |
TEXT |
NULL |
モデルのリビジョンまたはブランチ。 |
cache_dir |
TEXT |
NULL |
ローカルキャッシュディレクトリ。 |
SELECT aidb.create_model(my_bert, bert_local,
config => aidb.bert_config(sentence-transformers/all-MiniLM-L6-v2));
promoteb.clip_config#
clip_local プロバイダーの場合。
Parameter |
Type |
Default |
Description |
|---|---|---|---|
model |
TEXT |
Required |
HuggingFaceモデル識別子。 |
revision |
TEXT |
NULL |
モデルのリビジョンまたはブランチ。 |
cache_dir |
TEXT |
NULL |
ローカルキャッシュディレクトリ。 |
image_size |
INTEGER |
NULL |
ピクセル単位の入力画像サイズ。 |
SELECT aidb.create_model(my_clip, clip_local,
config => aidb.clip_config(openai/clip-vit-base-patch32));
promoteb.llama_config#
llama_local プロバイダーの場合。
Parameter |
Type |
Default |
Description |
|---|---|---|---|
model |
TEXT |
Required |
モデル識別子またはHuggingFaceパス。 |
revision |
TEXT |
NULL |
モデルリビジョン。 |
cache_dir |
TEXT |
NULL |
ローカルキャッシュディレクトリ。 |
model_path |
TEXT |
NULL |
モデルの重みへの明示的なローカルパス `model`をオーバーライドします。 |
system_prompt |
TEXT |
NULL |
デフォルトのシステムプロンプト。 |
temperature |
DOUBLE PRECISION |
NULL |
サンプリング温度。 |
top_p |
DOUBLE PRECISION |
NULL |
nucleusサンプリングしきい値。 |
seed |
BIGINT |
NULL |
ランダムシード。 |
sample_len |
INTEGER |
NULL |
生成する最大トークン。 |
repeat_penalty |
REAL |
NULL |
リピートペナルティ。 |
repeat_last_n |
INTEGER |
NULL |
反復ペナルティの対象とされるトークン。 |
use_flash_attention |
BOOLEAN |
NULL |
フラッシュアテンションを有効にします。 |
use_kv_cache |
BOOLEAN |
NULL |
KVキャッシュを有効にします。 |
SELECT aidb.create_model(my_llama, llama_local,
config => aidb.llama_config(
meta-llama/Llama-3.2-3B-Instruct,
temperature => 0.5
)
);
promoteb.t5_config#
t5_local プロバイダーの場合。
Parameter |
Type |
Default |
Description |
|---|---|---|---|
model |
TEXT |
Required |
モデル識別子またはHuggingFaceパス。 |
revision |
TEXT |
NULL |
モデルリビジョン。 |
model_path |
TEXT |
NULL |
モデルの重みへの明示的なローカルパス。 |
cache_dir |
TEXT |
NULL |
ローカルキャッシュディレクトリ。 |
temperature |
DOUBLE PRECISION |
NULL |
サンプリング温度。 |
top_p |
DOUBLE PRECISION |
NULL |
nucleusサンプリングしきい値。 |
seed |
BIGINT |
NULL |
ランダムシード。 |
max_tokens |
INTEGER |
NULL |
生成する最大トークン。 |
repeat_penalty |
REAL |
NULL |
リピートペナルティ。 |
repeat_last_n |
INTEGER |
NULL |
反復ペナルティの対象とされるトークン。 |
SELECT aidb.create_model(my_t5, t5_local,
config => aidb.t5_config(google/flan-t5-base));
promoteb.gemini_config#
gemini プロバイダーの場合。
Parameter |
Type |
Default |
Description |
|---|---|---|---|
api_key |
TEXT |
Required |
Google APIキー。 |
model |
TEXT |
NULL |
Geminiモデル識別子たとえば gemini-2.0-flash 。 |
url |
TEXT |
NULL |
APIエンドポイントのオーバーライド。 |
max_concurrent_requests |
INTEGER |
NULL |
最大同時要求。 |
thinking_budget |
INTEGER |
NULL |
拡張思考トークンの予算Gemini 2.xのみ。 |
SELECT aidb.create_model(my_gemini, gemini,
config => aidb.gemini_config(AIza..., model => gemini-2.0-flash));
promoteb.nim_clip_config#
nim_clip プロバイダーNVIDIA NIMマルチモーダル埋め込みの場合。
Parameter |
Type |
Default |
Description |
|---|---|---|---|
api_key |
TEXT |
NULL |
NIM APIキー。 |
model |
TEXT |
NULL |
NIM CLIPモデル識別子。 |
url |
TEXT |
NULL |
NIMエンドポイントURLのオーバーライド。 |
basic_auth |
TEXT |
NULL |
基本的な認証資格情報。 |
is_hcp_model |
BOOLEAN |
NULL |
true モデルがHCPで実行される場合。 |
SELECT aidb.create_model(my_nim_clip, nim_clip,
config => aidb.nim_clip_config(api_key => nvapi-..., model => nvidia/nvclip));
promoteb.nim_ocr_config#
nim_ocr プロバイダーNVIDIA NIM OCRの場合。
Parameter |
Type |
Default |
Description |
|---|---|---|---|
api_key |
TEXT |
NULL |
NIM APIキー。 |
model |
TEXT |
NULL |
NIM OCRモデル識別子。 |
url |
TEXT |
NULL |
NIMエンドポイントURLのオーバーライド。 |
basic_auth |
TEXT |
NULL |
基本的な認証資格情報。 |
is_hcp_model |
BOOLEAN |
NULL |
true モデルがHCPで実行される場合。 |
SELECT aidb.create_model(my_nim_ocr, nim_ocr,
config => aidb.nim_ocr_config(api_key => nvapi-...));
promoteb.nim_reranking_config#
nim_reranking プロバイダーの場合。
Parameter |
Type |
Default |
Description |
|---|---|---|---|
api_key |
TEXT |
NULL |
NIM APIキー。 |
model |
TEXT |
NULL |
NIMリランキングモデル識別子。 |
url |
TEXT |
NULL |
NIMエンドポイントURLのオーバーライド。 |
basic_auth |
TEXT |
NULL |
基本的な認証資格情報。 |
is_hcp_model |
BOOLEAN |
NULL |
true モデルがHCPで実行される場合。 |
SELECT aidb.create_model(my_reranker, nim_reranking,
config => aidb.nim_reranking_config(
api_key => nvapi-...,
model => nvidia/nv-rerankqa-mistral-4b-v3
)
);
promoteb.openrouter_chat_config#
openrouter_chat プロバイダーの場合。
Parameter |
Type |
Default |
Description |
|---|---|---|---|
model |
TEXT |
Required |
OpenRouterモデル識別子。 |
api_key |
TEXT |
NULL |
OpenRouter APIキー。 |
url |
TEXT |
NULL |
APIエンドポイントのオーバーライド。 |
max_concurrent_requests |
INTEGER |
NULL |
最大同時要求。 |
max_tokens |
JSONB |
NULL |
最大トークン構成 `aidb.max_tokens_config()`を使用します。 |
SELECT aidb.create_model(my_or_chat, openrouter_chat,
config => aidb.openrouter_chat_config(
anthropic/claude-3-5-haiku,
api_key => sk-or-...
)
);
promoteb.openrouter_embeddings_config#
openrouter_embeddings プロバイダーの場合。
Parameter |
Type |
Default |
Description |
|---|---|---|---|
model |
TEXT |
Required |
OpenRouterエンベディングモデル識別子。 |
api_key |
TEXT |
NULL |
OpenRouter APIキー。 |
url |
TEXT |
NULL |
APIエンドポイントのオーバーライド。 |
max_concurrent_requests |
INTEGER |
NULL |
最大同時要求。 |
max_batch_size |
INTEGER |
NULL |
バッチごとの最大入力数。 |
SELECT aidb.create_model(my_or_embedder, openrouter_embeddings,
config => aidb.openrouter_embeddings_config(
mistral/mistral-embed,
api_key => sk-or-...
)
);