Skip to content

fix(ce): reconcile embedder vector dimensionality (HashingEmbedder 256 vs index default 1536) #909

Description

@nndn

Context

The bundled OSS HashingEmbedder emits 256 dims (adapters/outbound/intelligence/local_embedder.py:38_DEFAULT_DIMENSIONS = 256), but every vector-index creator defaults to 1536 (OpenAI text-embedding-3-small) via getattr(self._embedder, "dimensions", 1536):

  • adapters/outbound/graph/neo4j_writer.py:80
  • adapters/outbound/graph/falkordb_writer.py:233 (plus _ensure_indexes_sync(..., embedding_dim: int = 1536) at :238)
  • adapters/outbound/graph/cypher.py:759ensure_canonical_indexes(driver, *, embedding_dim: int = 1536) (comment at :770 cites text-embedding-3-small)

This is consistent when an embedder is wired (the getattr reads .dimensions == 256). The hazard is the fallback path: the writers/backends accept embedder=None:

  • adapters/outbound/graph/neo4j_writer.py:42
  • adapters/outbound/graph/falkordb_writer.py:194
  • adapters/outbound/graph/backends/embedded_backend.py:44

If ensure_indexes runs with no embedder it creates a 1536-dim index, while embedding writes (once an embedder is wired) emit 256-dim vectors — the index width mismatches the stored data and semantic reads silently degrade to lexical fallback. Swapping in sentence-transformers (the embeddings extra in pyproject.toml) introduces a third width (384/768/…), compounding the drift.

Acceptance criteria

  • Index creation and embedding writes share one source-of-truth dimension on both Neo4j and FalkorDB.
  • The 1536 magic default is removed — derive the width from the configured embedder, or fail closed when no embedder is wired (rather than guessing 1536).
  • A test asserts the created index dimension == the embedder's .dimensions across the embedded / FalkorDB / sentence-transformers paths.

Provenance

Carry-forward from the cg-05 backends PR (folds the original PR-12 embedding-claim-query + PR-13 FalkorDB backend). Deferred deliberately; tracked here rather than blocking the PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions