メインコンテンツまでスキップ

__call__()

VoyageEmbeddingFunction におけるこの操作は、テキスト文字列のリストを受け取り、それらを直接ベクトル埋め込みにエンコードします。

VoyageEmbeddingFunction の __call__() メソッドは、encode_documents() および encode_queries() と同じ機能を持ちます。

リクエスト構文

python
# Instance created

voyage_ef = VoyageEmbeddingFunction()

# __call__ method will be called
voyage_ef(
texts: List[str]
) -> List[np.array]

パラメーター:

  • texts (List[str])

    文字列値のリストです。各文字列は、エンコードのために埋め込みモデルに渡されるテキストを表します。モデルは、リスト内の各文字列に対して埋め込みベクトルを生成します。

戻り値の型:

List[np.array]

戻り値:

各要素が NumPy 配列であるリスト。

例外:

  • ImportError

    Voyage モジュールがインストールされていない場合に、この例外が発生します。

python
from pymilvus.model.dense import VoyageEmbeddingFunction

voyage_ef = VoyageEmbeddingFunction(
model_name="voyage-lite-02-instruct", # Defaults to `voyage-2`
api_key='YOUR_API_KEY' # Replace with your own Voyage API key
)

docs = [
"Artificial intelligence was founded as an academic discipline in 1956.",
"Alan Turing was the first person to conduct substantial research in AI.",
"Born in Maida Vale, London, Turing was raised in southern England.",
]

voyage_ef(docs)

# [array([ 0.02582654, -0.00907086, -0.04604037, ..., -0.01227521,
# 0.04420955, -0.00038829]),
# array([ 0.03844212, -0.01597065, -0.03728884, ..., -0.02118733,
# 0.03349845, 0.0065346 ]),
# array([ 0.05143557, -0.01096631, -0.02690451, ..., -0.02416254,
# 0.07658645, 0.03064499])]
Ctrl I