Back to the room

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

Code Observatory / module

embeddings

codeintel.embeddings

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

Contains (15)
SymbolFileResolved by
_normalizeembeddings.pysame file
_padembeddings.pysame file
_PrefixMixinembeddings.pysame file
_read_profileembeddings.pysame file
_use_prefixesembeddings.pysame file
EdgeFirstEmbedderembeddings.pysame file
Embedderembeddings.pysame file
EmbeddingUnavailableembeddings.pysame file
get_embedderembeddings.pysame file
HashEmbedderembeddings.pysame file
HttpEmbedderembeddings.pysame file
OnnxEmbedderembeddings.pysame file
reset_embedder_cacheembeddings.pysame file
resolve_backendembeddings.pysame file
SentenceTransformerEmbedderembeddings.pysame file
Imports (1)
SymbolFileResolved by
texttext.pythrough an import
Imported by (8)
SymbolFileResolved by
contextcontext.pythrough an import
describedescribe.pythrough an import
edge_serveredge_server.pythrough an import
indexerindexer.pythrough an import
jobsjobs.pythrough an import
retrievalretrieval.pythrough an import
routerrouter.pythrough an import
native_servernative_server.pythrough an import
codeintel.embeddingsbackend/app/codeintel/embeddings.py, lines 1–40Open source
"""Embedding backends.Every chunk embedding is stored together with the ``model_id`` of theembedder that produced it. Dense retrieval only compares a query vector withchunk vectors of the same ``model_id`` — vectors from different models livein unrelated spaces and comparing them returns confident nonsense.Backends (``EMBEDDING_BACKEND``):``hash``    Deterministic feature-hashing of identifier-split tokens into 768 dims.    No dependencies, no network, CPU-only. **It is a lexical model, not a    semantic one** — it exists so the whole pipeline (indexing, pgvector,    fusion) can be exercised offline and in CI. Its retrieval quality is    reported separately in the benchmarks and must not be presented as    neural dense retrieval.``sentence-transformers``    Local model, default ``nomic-ai/nomic-embed-text-v1`` (the production    model). Needs ``requirements-edge.txt`` (torch). Uses CUDA when present.``http``    POSTs to an embedding server (the edge worker's ``/embed`` endpoint,    reached over Tailscale in production). Optional bearer token.``onnx``    A sentence-transformers model exported to ONNX (``model.onnx`` +    ``tokenizer.json`` in ``EMBEDDING_ONNX_DIR``), run with onnxruntime on    CPU. Mean pooling + L2 normalisation.``none``    No embeddings: keyword retrieval only; dense/hybrid report unavailable.Models with fewer than 768 dimensions are zero-padded to the column width.Zero padding leaves dot products and norms unchanged, so cosine similarityis exactly preserved."""from __future__ import annotationsimport hashlibimport jsonimport loggingimport math

Shows the first 40 of 521 lines. The rest is on GitHub at this commit.

What the index recorded

Signature
module backend.app.codeintel.embeddings
File
backend/app/codeintel/embeddings.py
Lines
1–521
Parser
python-ast
Git blob
df7f8202f23ca6ad2c57aca5f09b435eb6486d79
Call sites
2 named, 0 resolved, 2 left unlinked
Outside this subset
17 more edges reach code outside the graph shown here

Read it on GitHub at this commit