%Embedding.SentenceTransformers
class %Embedding.SentenceTransformers extends %Embedding.Interface
Extends the %Embedding.Interface class, using Hugging Face's SentenceTransformers package.Method Inventory
- CheckInstall()
- DownloadModel()
- Embedding()
- EmbeddingPy()
- GetMaxTokens()
- GetVectorLength()
- IsValidConfig()
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 ]
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.
Note that this function also caches the embedding models it loads, taking up an additional amount of memory, equivalent to the models' footprint, used by the IRIS process.
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
- %AddToSaveSet()
- %ClassIsLatestVersion()
- %ClassName()
- %ConstructClone()
- %DispatchClassMethod()
- %DispatchGetModified()
- %DispatchGetProperty()
- %DispatchMethod()
- %DispatchSetModified()
- %DispatchSetMultidimProperty()
- %DispatchSetProperty()
- %Extends()
- %GetParameter()
- %IsA()
- %IsModified()
- %New()
- %NormalizeObject()
- %ObjectModified()
- %OriginalNamespace()
- %PackageName()
- %RemoveFromSaveSet()
- %SerializeObject()
- %SetModified()
- %ValidateObject()