__call__()
MGTEEmbeddingFunction におけるこの操作は、テキスト文字列のリストを受け取り、それらを直接ベクトル埋め込みにエンコードします。
MGTEEmbeddingFunction の __call__() メソッドは、encode_documents() および encode_queries() と同じ機能を持ちます。
リクエスト構文
python
# Instance created
ef = MGTEEmbeddingFunction()
# __call__ method will be called
ef(
texts: List[str]
) -> Dict
パラメータ:
-
texts (List[str])
文字列値のリストで、各文字列はエンコードのために embedding model に渡されるテキストを表します。モデルは、リスト内の各文字列に対して embedding vector を生成します。
戻り値の型:
Dict
戻り値:
エンコードされた埋め込み(dense と sparse の両方)を含む辞書。
例外:
None
例
python
from pymilvus.model.hybrid import MGTEEmbeddingFunction
ef = MGTEEmbeddingFunction()
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.",
]
ef(docs)
# {'dense': [tensor([-4.9149e-03, 1.6553e-02, -9.5524e-03, -2.1800e-02, 1.2075e-02,
# 1.8500e-02, -3.0632e-02, 5.5909e-02, 8.7365e-02, 1.8763e-02,
# 2.1708e-03, -2.7530e-02, -1.1523e-01, 6.5810e-03, -6.4674e-02,
# 6.7966e-02, 1.3005e-01, 1.1942e-01, -1.2174e-02, -4.0426e-02,
# ...
# 2.0129e-02, -2.3657e-02, 2.2626e-02, 2.1858e-02, -1.9181e-02,
# 6.0706e-02, -2.0558e-02, -4.2050e-02], device='mps:0')], 'sparse': <Compressed Sparse Row sparse array of dtype 'float64'
# with 41 stored elements and shape (3, 250002)>}