SentenceTransformerEmbedding
Dense embeddings using Sentence Transformer models.
Wraps :class:_SentenceTransformerEmbedding and exposes it as a
DashAI component with a configurable schema
(:class:SentenceTransformerEmbeddingSchema).
Supports mean / last-token pooling, L2 normalisation, and overflow strategies (truncate / aggregate).
Parameters
- model_name : string, default=
sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 - Sentence Transformer model for embedding generation.
- overflow_strategy : string, default=
truncate - Strategy for chunks exceeding model max sequence length.
- normalize : boolean, default=
True - Whether to L2-normalize the output embeddings.
- device : string, default=
cpu - Device to run the model on.
Methods
batch_encode(self, texts: List[str])
SentenceTransformerEmbeddingEncode a batch of texts into dense embeddings.
encode(self, text: str)
SentenceTransformerEmbeddingEncode a single text into a dense embedding.
load(self)
SentenceTransformerEmbeddingLoad the Sentence Transformer model and tokenizer.
get_credential(self, name: str)
ConfigObjectResolve a registered credential component by name.
Parameters
- name : str
- Credential component class name (e.g. "HuggingFaceCredential").
Returns
- BaseCredential
- An instance of the requested credential component.
get_schema(cls) -> dict
ConfigObjectGenerates the component related Json Schema.
Returns
- dict
- Dictionary representing the Json Schema of the component.
validate_and_transform(self, raw_data: dict) -> dict
ConfigObjectIt takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.
Parameters
- raw_data : dict
- A dictionary with the data provided by the user to initialize the model.
Returns
- dict
- A validated dictionary with the necessary objects.