Skip to main content
AskMe (beta)

%Embedding.SentenceTransformers

class %Embedding.SentenceTransformers extends %Embedding.Interface

Extends the %Embedding.Interface class, using Hugging Face's SentenceTransformers package.

Method Inventory

Methods

classmethod CheckInstall(pythonPath As %String = "") [ Language = python ]
Throws an error if python package 'sentence_transformers' is not installed.
classmethod DownloadModel(modelName As %String, cacheFolder As %String, token As %String, pythonPath As %String = "") [ Language = python ]
classmethod Embedding(input As %String, configuration As %String) as %Vector
Generates embeddings locally using sentence_transformers
classmethod EmbeddingPy(modelName As %String, input As %String, cacheFolder As %String, token As %String, checkTokenCount As %Boolean, maxTokens As %Integer, pythonPath As %String = "") [ Language = python ]
Embedded python function that uses sentence_transformers to retrieve embeddings. Example modelName: sentence-transformers/all-MiniLM-L6-v2
classmethod GetMaxTokens(modelName As %String, pythonPath As %String = "", cacheFolder As %String = "") as %Integer [ Language = python ]
Helper function to retrieve a model's maximum input tokens using the sentence_transformers package
classmethod GetVectorLength(modelName As %String, pythonPath As %String = "", cacheFolder As %String = "") as %Integer [ Language = python ]
Retrieves a model's vector length using the sentence_transformers package
classmethod IsValidConfig(config As %DynamicObject, ByRef errorMsg As %String) as %Boolean
Validates %Embedding.Config's Configuration property. { "modelName" : , "hfCachePath" : , "hfToken" : , "checkTokenCount": , "maxTokens": "pythonPath": } Also checks if the python package 'sentence_transformers' is installed.

Inherited Members

Inherited Methods

FeedbackOpens in a new tab