aeat.application.corpus_search._model_loader module

Shared model2vec loader for the semantic-search stack.

Both the build-time precompute (_embed_build) and the runtime query embedder (_query_embed) load the same potion-multilingual-128M static model behind the capability-gated aeat-cli[search] extra. This module is the one place that lazily imports model2vec and refuses with an install hint when it is absent, so neither consumer duplicates the gate and the degraded lexical-only mode never depends on the semantic stack at import time.

SEARCH_EXTRA_HINT

Install hint surfaced on every semantic-stack refusal.

load_static_model(model_id, *, revision, cache_dir=None)[source]

Load a model2vec StaticModel, refusing if the search extra is absent.

Parameters:
  • model_id (str) – The model2vec model to load.

  • revision (str) – The pinned model revision, passed through when the installed from_pretrained accepts it.

  • cache_dir (Path | None) – Optional app-controlled cache directory for the download.

Return type:

Any

Returns:

The loaded StaticModel (typed Any — model2vec ships no stubs).

Raises:

CorpusSearchDependencyError – If model2vec is not installed.

model_dimensions(model)[source]

Return the embedding dimensionality of a loaded StaticModel.

Return type:

int

Parameters:

model (Any)