feat(embedding): BGE-M3 HTTP provider (1024D, zero-vector guard) + full registration - #91
Open
RobertSigmundsson wants to merge 4 commits into
Conversation
added 4 commits
July 26, 2026 01:39
…ry registration F2 writer A of the Gemini-3072D -> BGE-M3-1024D migration. New BGEM3Embedding posts to a self-hosted /embed service (vast.ai via tunnel), returns 1024D L2-normalized vectors, and RAISES on empty/failed input instead of fabricating a poison zero-vector. Registered in the _create_provider factory + _VALID_PROVIDERS. Shadow only — no prod re-embed. (cherry picked from commit 4607c9a) (cherry picked from commit 4fbe4ad) (cherry picked from commit 9837606)
…2 gap → effective-config rejected it)
The BGE-M3 provider was added to engine/embedding/config.py + the factory in F2, but
unified_config.py has its OWN provider allow-list that gates the effective embedding
config — it still rejected 'bge_m3' ('falling back to disabled'), blocking reindex.
Surfaced during F4 pre-cutover verification.
(cherry picked from commit 560c424)
(cherry picked from commit 75f8e50)
(cherry picked from commit 50df9b2)
…lagged degraded The BGE-M3 HTTP provider was added to the embedding factory (b59be72) and to unified_config._VALID_PROVIDERS (5d2cef7) but NOT to capability._PROVIDER_IMPORT. As a result every smem-mcp/CLI startup logged a spurious "Embedding provider unavailable — running in degraded keyword mode. unknown embedding provider 'bge_m3'", and smem_health / stats_handler reported embeddings as unavailable — even though recall/remember embed correctly via the factory (authed BGE-M3 /embed returns 200). bge_m3 only needs httpx, shipped in the `server` extra. (cherry picked from commit 135a6ec)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
mainalready assumes a self-hosted bge-m3 endpoint in several places(
unified_config.py:124,unified_config.py:2521,engine/encoder.py:461,engine/reasoning_distiller.py:8and:410) but there is nobge_m3provider — you can only reach suchan endpoint through the OpenAI-compatible path, which does not carry BGE-M3's dimension or its
normalisation contract.
Change
Four commits, one logical addition:
BGEM3Embedding— posts to a/embedHTTP service, returns 1024-D L2-normalised vectors, andraises on empty/failed input instead of fabricating a zero vector. A fabricated zero vector is
silently catastrophic for a cosine KNN index: it poisons the neighbourhood without any error.
unified_config._VALID_PROVIDERS— without it the effective-config validatorrejected
bge_m3even though the factory could build it.degradedeven when the provider is working.
Configuration is env-driven (
SURREAL_MEMORY_EMBEDDING_BASE_URL,BGE_M3_API_KEY,SURREAL_MEMORY_EMBEDDING_DIMENSION), consistent with the other providers.Why upstream benefits
Self-hosted BGE-M3 is a common way to run this project without a paid embedding API, and the codebase
already talks about it. This makes it a first-class provider, including the two registration points that
are easy to miss (items 2 and 4 were each found only after the provider silently misbehaved).
Evidence
origin/mainimport surreal_memoryruff checkruff format --checkmypy src/ --ignore-missing-importspytest -m "not stress" -n autoRisks / notes for the reviewer
unchanged at 6535. If upstream wants a mocked-transport test before merging, say so and it will be added.
provider = "bge_m3"sees no behaviour change.semantic_discovery._create_providerfactory.a re-embed, same as any provider change. Not handled here (and not handled for the other providers either).