Back to the room

Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works

Code Observatory / method

_load

codeintel.embeddings.SentenceTransformerEmbedder._load

PINNED SOURCE Source and edges from the index at this commit. An execution appears only where one was recorded.

PHAROS at 975a38dMIT license

Around this symbol

Search all symbols

Loading

Calls (1)
SymbolFileResolved by
EmbeddingUnavailableembeddings.pysame file
Inside (1)
SymbolFileResolved by
SentenceTransformerEmbedderembeddings.pysame file
codeintel.embeddings.SentenceTransformerEmbedder._loadbackend/app/codeintel/embeddings.py, lines 177–209Open source
    def _load(self):        if self._model is not None:            return self._model        with self._lock:            if self._model is None:                try:                    from sentence_transformers import SentenceTransformer                except ImportError as exc:                    raise EmbeddingUnavailable(                        "sentence-transformers is not installed "                        "(pip install -r requirements-edge.txt)"                    ) from exc                device = self._device                if device is None:                    try:                        import torch                        device = "cuda" if torch.cuda.is_available() else "cpu"                    except ImportError:                        device = "cpu"                logger.info("Loading embedding model %s on %s", self.model_name, device)                try:                    self._model = SentenceTransformer(                        self.model_name,                        device=device,                        trust_remote_code=True,                        # Avoids a native crash seen with pytorch_model.bin on                        # Windows + Python 3.13 (see project history).                        model_kwargs={"use_safetensors": True},                    )                except Exception as exc:                    raise EmbeddingUnavailable(f"failed to load {self.model_name}: {exc}") from exc        return self._model

What the index recorded

Signature
def _load(self):
File
backend/app/codeintel/embeddings.py
Lines
177–209
Parser
python-ast
Git blob
df7f8202f23ca6ad2c57aca5f09b435eb6486d79
Call sites
4 named, 1 resolved, 3 left unlinked

Read it on GitHub at this commit