Saltar al contenido principal

InstructorEmbedding

DenseEmbedding
DashAI.back.models.RAG.embeddings.dense.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])

Defined on InstructorEmbedding

Encode a batch of texts into dense embeddings with the configured instruction.

encode(self, text: str)

Defined on InstructorEmbedding

Encode a single text into a dense embedding with the configured instruction.

load(self)

Defined on InstructorEmbedding

Load the INSTRUCTOR model.

get_credential(self, name: str)

Defined on ConfigObject

Resolve 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

Defined on ConfigObject

Generates the component related Json Schema.

Returns

dict
Dictionary representing the Json Schema of the component.

validate_and_transform(self, raw_data: dict) -> dict

Defined on ConfigObject

It 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.