InstructorEmbedding
Dense embeddings using INSTRUCTOR instruction-tuned models.
Wraps :class:_InstructorEmbedding and exposes it as a DashAI component
with a configurable schema (:class:InstructorEmbeddingSchema).
Prepends a user-defined instruction string to every input text.
Parameters
- model_name : string, default=
hkunlp/instructor-base - INSTRUCTOR model for instruction-tuned embedding generation.
- instruction : string, default=
Represent the document for retrieval: - Instruction text that guides the embedding model.
- device : string, default=
cpu - Device to run the model on.
Methods
batch_encode(self, texts: List[str])
InstructorEmbeddingEncode a batch of texts into dense embeddings with the configured instruction.
encode(self, text: str)
InstructorEmbeddingEncode a single text into a dense embedding with the configured instruction.
load(self)
InstructorEmbeddingLoad the INSTRUCTOR model.
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.