paper_firehose.core.model_manager¶
Model management utilities for Sentence-Transformers models.
Handles vendoring (downloading and caching) of transformer models locally to avoid runtime network dependencies in production environments.
Functions
|
Ensure a local model directory exists for the given spec and return the path or original spec. |
|
Heuristic check that a local Sentence-Transformers model folder is valid. |
- paper_firehose.core.model_manager.ensure_local_model(model_spec)[source]¶
Ensure a local model directory exists for the given spec and return the path or original spec.
Behavior: - If spec is the default alias ‘all-MiniLM-L6-v2’:
Use ‘models/all-MiniLM-L6-v2’. If missing or empty, download ‘sentence-transformers/all-MiniLM-L6-v2’ into that folder.
- If spec looks like a repo id (e.g., ‘sentence-transformers/x’ or ‘intfloat/e5-small’):
Vendor to ‘models/<last-segment>’ when not present or empty.
If spec is a local path and valid, return it. If it exists but appears empty, try to infer repo id from the folder name and download into it.
On any failure (e.g., no network), return the original spec and let STRanker handle it.