Functions reference#

パイプラインを必要とせず、クエリでデータを直接変換するAIDBスタンドアロンSQLファンクションのリファレンス。ガイドスタイルのドキュメントと使用例については、 SQL functions を参照してください。

AI推論機能 encode_text 、decode_text 、rerank_text 、および関連に関しては、 推論ファンクション を参照してください。


helpb.chunk_text#

テキスト文字列を、より小さい意味的に一貫したセグメントに分割します。

パラメーター#

Parameter

Type

Description

input

TEXT

チャンクへのテキスト。

options

JSONB

チャンク構成 以下を参照してください。

オプション

Key

Type

Default

Description

desired_length

integer

Required

ターゲットセグメントサイズ。 `max_length`が省略された場合、厳密な上限として機能します。

max_length

integer

NULL

チャンクサイズの上限。チャンクは、セマンティック境界を保持するためのみに`desired_length`を超えて拡張されます。

overlap_length

integer

0

境界を越えたコンテキストを保持するために、連続するチャンク間で繰り返すコンテンツの量。

strategy

text

'chars'

チャンク単位 'chars'`文字ベースまたは'words'ワードベース。 `desired_length、max_length、および`overlap_length`の単位を決定します。

返品#

Column

Type

Description

part_id

integer

ゼロベースのセグメントインデックス。

chunk

text

テキストセグメント。

例#

SELECT * FROM aidb.chunk_text(
    input   => Long text here...,
    options => {"desired_length": 120, "max_length": 150}
);

quietb.parse_html#

HTML文字列から可読テキストを抽出し、構造を維持しながらタグを削除します。

パラメーター#

Parameter

Type

Description

html

TEXT

解析するHTML文字列。

options

JSONB

構成の解析 以下を参照してください。

オプション

Key

Type

Default

Description

method

text

'StructuredPlaintext'

解析方法 'StructuredPlaintext'`プレーンテキスト抽出または'StructuredMarkdown'`ヘッダーとリストを保持するマークダウンのような出力。

返品#

TEXT — 抽出されたテキストコンテンツ。

例#

SELECT aidb.parse_html(
    html    => <h1>Hello</h1><p>World</p>,
    options => {"method": "StructuredPlaintext"}
);

quietb.parse_pdf#

バイナリPDFデータからテキストを抽出します。ページごとに1行を返します。

パラメーター#

Parameter

Type

Description

bytes

BYTEA

生のPDFバイナリデータ。

options

JSONB

構成の解析 以下を参照してください。

オプション

Key

Type

Default

Description

method

text

'Structured'

解析方法。現在`'Structured'`仕様ベースのテキストブロック抽出。

allow_partial_parsing

boolean

true

`true`の場合、個々のページでエラーが発生したときに解析を継続し、可能な限り多くのデータを結果ます。

返品#

Column

Type

Description

part_id

integer

テキストが抽出されたページインデックスゼロベース。

text

text

そのページの抽出されたテキスト。

例#

SELECT * FROM aidb.parse_pdf(
    bytes   => pg_read_binary_file(/path/to/doc.pdf)::BYTEA,
    options => {"allow_partial_parsing": true}
);

quietb.perform_ocr#

登録されたOCR対応モデルを使用して、画像データからテキストを抽出します。

パラメーター#

Parameter

Type

Description

input

BYTEA

生のバイナリ画像データ。

options

JSONB

OCR構成下記を参照してください。

オプション

Key

Type

Description

model

text

登録されたOCR対応モデルの名前たとえば、 `nim_ocr`プロバイダーを使用するモデル。

返品#

Column

Type

Description

part_id

integer

テキストブロックインデックス。プロバイダーが複数のテキストセグメントを返す場合、単一の画像から複数の行が生成される場合があります。

text

text

そのブロックの抽出されたテキスト。

例#

SELECT * FROM aidb.perform_ocr(
    input   => pg_read_binary_file(/path/to/image.png)::BYTEA,
    options => {"model": "my_ocr_model"}
);

quietb.summarize_text#

登録された言語モデルを使用して、テキスト文字列の簡潔な概要を生成します。

パラメーター#

Parameter

Type

Description

input

TEXT

要約するテキスト。

options

JSONB

要約構成以下を参照してください。

オプション

Key

Type

Default

Description

model

text

Required

`decode_text`をサポートする登録済みモデルの名前。

prompt

text

(standard prompt)

概要スタイルをガイドするカスタム指示たとえば 'Summarize for a 5th grader' 。

chunk_config

JSONB

NULL

入力がモデルのコンテキストウィンドウを超える場合、要約の前に適用するチャンク構成。 `aidb.chunk_text`オプションと同じキーを受け入れます。

strategy

text

'append'

要約戦略 'append' 各チャンクを独立して要約および連結する または 'reduce' 目的の長さに達するまで反復要約する。

reduction_factor

integer

3

`'reduce'`ストラテジーで使用されます。各反復でテキストをどの程度積極的に削減するかを制御します。

返品#

TEXT — 生成された概要。

例#

SELECT aidb.summarize_text(
    input   => Long article text here...,
    options => {"model": "my_t5_model"}
);

quietb.summarize_text_aggregate#

aidb.summarize_text の集計バージョン。各グループのすべての行からテキストを蓄積し、結合された結果を要約のためにLLMに送信します。 GROUP BY グループごとに1つの概要を結果ます。空の行とNULL行はスキップされます。

パラメーター#

Parameter

Type

Required

Description

input

TEXT

Yes

各行のテキスト列。空/NULL行はスキップされます。

options

JSON

Yes

`aidb.summarize_text_config()`でビルドされた構成オブジェクト。少なくとも`model`を含める必要があります。

オプション#

aidb.summarize_text と同じオプションを受け入れます上記を参照してください。 options は集計に 必須 であり、オプショナルではないことに注意してください。

返品#

TEXT —グループの概要。

使用法#

SELECT category,
       aidb.summarize_text_aggregate(
           text_column,
           aidb.summarize_text_config(my_t5_model)::json ORDER BY id
       ) AS summary
FROM my_table
GROUP BY category;

パラメーターのデフォルトのクイックリファレンス#

Function

Parameter

SQL default

Runtime default

summarize_text

options

'{}'

Must include model

summarize_text_aggregate

input

— (required)

—

summarize_text_aggregate

options

— (required)

—

summarize_text_config

model

— (required)

—

summarize_text_config

chunk_config

NULL

No chunking

summarize_text_config

prompt

NULL

Standard summarize prompt

summarize_text_config

strategy

NULL

'append'

summarize_text_config

reduction_factor

NULL

3

summarize_text_config

inference_config

NULL

Provider defaults

chunk_text_config

desired_length

— (required)

—

chunk_text_config

max_length

NULL

Same as desired_length

chunk_text_config

overlap_length

NULL

0

chunk_text_config

strategy

NULL

'chars'