Saltar al contenido principal

E5MistralGGUFEmbedding

Converter
DashAI.back.converters.hugging_face.text_embedding.E5MistralGGUFEmbedding

E5-Mistral-7B-Instruct embeddings from its Q5_K_M GGUF build.

Only the quantized file is downloaded. A query is prefixed with the instruction the model was trained with, while a passage is encoded as it is, which is how the original model is meant to be used.

Parameters​

device : string, default=CPU
Device llama.cpp runs on. A GPU offloads every layer.
batch_size : integer, default=32
Number of texts encoded together. Lower it if memory runs out.
normalize : boolean, default=True
Scale every vector to length one, as cosine similarity expects.
overflow_strategy : string, default=truncate
What to do with a text longer than the model accepts: cut it (truncate) or encode it in pieces and average them (aggregate).

Methods​

encode(self, texts: List[str], role: str = 'passage') -> numpy.ndarray

Defined on E5MistralGGUFEmbedding

Encode texts into dense vectors.

Parameters

texts : list of str
Texts to encode; None becomes an empty string.
role : str, optional
"passage" for indexed text, "query" for a search query, which is prefixed with :data:QUERY_PROMPT.

Returns

np.ndarray
(len(texts), model.n_embd()) float32 array.

hf_repos(cls) -> List[Any]

Defined on E5MistralGGUFEmbedding

Return the one repo entry, restricted to the quantized file.

Returns

list of tuple
[(MODEL_NAME, "model", [GGUF_PATTERN])], so the snapshot download fetches the Q5_K_M checkpoint and nothing else.

is_downloaded(cls) -> bool

Defined on E5MistralGGUFEmbedding

Return whether the Q5_K_M checkpoint is on disk.

Returns

bool
True when a file matching :data:GGUF_PATTERN exists.

load_pretrained(self, source: str) -> Any

Defined on E5MistralGGUFEmbedding

Load the quantized checkpoint with llama.cpp in embedding mode.

Parameters

source : str
Where the mixin resolved the model from. Unused: the file is read from the component's own download folder.

Returns

llama_cpp.Llama
The loaded model, ready for :meth:encode.

build_report(self, data: 'Dict[str, Any]') -> 'Dict[str, Any]'

Defined on BaseConverter

Wrap converter-specific data with the producer converter name.

close(self) -> None

Defined on TextEmbeddingConverter

Release the loaded checkpoint so the next encode reloads it.

component_dir(cls) -> pathlib.Path

Defined on DownloadableMixin

Return this component's own storage directory.

Returns

pathlib.Path
<COMPONENT_PATH>/<ClassName>.

delete(cls) -> None

Defined on DownloadableMixin

Remove the component's downloaded artifacts.

download(cls, report: Optional[Callable[[Optional[float], Optional[str]], NoneType]] = None) -> None

Defined on HFDownloadableMixin

Download all repos listed in hf_repos() into component_dir().

Parameters

report : ProgressReporter, optional
Callback invoked before each repo download with report(None, "Downloading <repo_id>"). None means no progress reporting.

fit(self, x: 'DashAIDataset', y: Optional[ForwardRef('DashAIDataset')] = None) -> 'TextEmbeddingConverter'

Defined on TextEmbeddingConverter

Check that every column holds text.

Parameters

x : DashAIDataset
The columns to embed.
y : DashAIDataset, optional
Ignored.

Returns

TextEmbeddingConverter
This converter.

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_metadata(cls) -> 'Dict[str, Any]'

Defined on BaseConverter

Get metadata for the converter, used by the DashAI frontend.

Parameters

cls : type
The converter class (injected automatically by Python for classmethods).

Returns

Dict[str, Any]
Dictionary containing display name, short description, image preview path, category, icon, color, and whether the converter is supervised.

get_output_type(self, column_name: Optional[str] = None) -> DashAI.back.types.dashai_data_type.DashAIDataType

Defined on TextEmbeddingConverter

Return the type of every embedding column.

Parameters

column_name : str, optional
Unused.

Returns

DashAIDataType
Float backed by pyarrow.float32().

get_report(self) -> 'Union[Dict[str, Any], None]'

Defined on BaseConverter

Return the converter report produced after execution, if any.

Returns

Dict[str, Any] or None
JSON-serializable report dict, or None when the converter does not produce one.

get_schema(cls) -> dict

Defined on ConfigObject

Generates the component related Json Schema.

Returns

dict
Dictionary representing the Json Schema of the component.

infer_output_columns(self, inputs: 'List[StateItem]') -> 'StructureDelta'

Defined on BaseConverter

Estimate what this converter does to its scope, without any data.

Parameters

inputs : list of ColumnItem | BlockItem
The dataset state items in this converter's scope.

Returns

StructureDelta
The scope items that survive (maybe retyped) and the new items.

pretrained(self) -> Any

Defined on PretrainedTool

Return the loaded model, loading it on first use.

Returns

Any
The value :meth:load_pretrained returned.

prompt(self, role: str) -> Optional[str]

Defined on TextEmbeddingConverter

Return the text prepended to inputs of a role.

Parameters

role : str
"passage" or "query".

Returns

str or None
The prompt, or None when the model takes the text as is.

rows_to_keep(self, x: "'DashAIDataset'") -> 'List[int]'

Defined on BaseConverter

Positions of the rows of x that survive this converter.

Parameters

x : DashAIDataset
The converter's scope columns of one split.

Returns

list of int
0-based positions of the kept rows, in order.

session_params(cls, params: 'Optional[Dict[str, Any]]') -> 'Dict[str, Any]'

Defined on BaseConverter

A session step's params, with the session defaults under them.

Parameters

params : dict or None
The params the step stores.

Returns

dict
SESSION_PARAMS updated with params: what the step gives wins.

setup_device(self, label: Optional[str]) -> None

Defined on PretrainedTool

Choose the device and forget any loaded model.

Parameters

label : str, optional
The device parameter.

transform(self, x: 'DashAIDataset', y: Optional[ForwardRef('DashAIDataset')] = None) -> 'DashAIDataset'

Defined on TextEmbeddingConverter

Replace every text column with its embedding columns.

Parameters

x : DashAIDataset
The text columns.
y : DashAIDataset, optional
Ignored.

Returns

DashAIDataset
One float32 column emb_{column}_{i} per dimension of every input column, and no input column.

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.