OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Bug]: input: "multimodal" is silently ignored for provider=openai — image parts stripped client-side despite generic docs

Open blakejia opened this issue 3 months ago • 1 comments

Problem Statement

The configuration docs list input: "text" | "multimodal" as a generic dense-embedding parameter, with no indication that it is provider-restricted. However, on current main (verified at b8c89099) it is only wired for the volcengine provider. When provider: "openai" is configured with input: "multimodal":

  1. The config key is silently ignored — the factory never forwards it to OpenAIDenseEmbedder.
  2. OpenAIDenseEmbedder inherits supports_multimodal = False, so prepare_embedding_input() strips image parts before any HTTP call — multimodal requests silently degrade to text-only.
  3. Image search is refused with "Image search requires a multimodal embedding model" (hierarchical_retriever.py).

Users get no error or warning; the misconfiguration is undetectable from the client side.

Evidence (main @ b8c89099)

# Fact Location
1 cfg.input is forwarded only in the five volcengine factory entries; the ("openai", "dense") entry passes no input/input_type openviking_cli/utils/config/embedding_config.py (volcengine entries vs. the ("openai", "dense") entry in _create_embedder's factory_registry)
2 OpenAIDenseEmbedder has no supports_multimodal override and zero image/multimodal handling; its input_type ctor param is used only for the query_param/document_param extra-body mechanism openviking/models/embedder/openai_embedders.py
3 EmbedderBase.supports_multimodal defaults to False; non-multimodal embedders get text extracted via extract_text_from_content in prepare_embedding_input openviking/models/embedder/base.py:200-205, :171-194
4 Image search guard: "Image search requires a multimodal embedding model" openviking/retrieve/hierarchical_retriever.py:151
5 History: the only non-volcengine multimodal embedder attempt (Gemini Embedding 2, #607) was reverted (#703) git log

Steps to Reproduce

  1. Configure dense embedding with a custom OpenAI-compatible backend that accepts multimodal content parts:
    {
      "embedding": {
        "dense": {
          "provider": "openai",
          "api_base": "http://<openai-compatible-server>/v1",
          "api_key": "EMPTY",
          "model": "<multimodal-embedding-model>",
          "dimension": 1024,
          "input": "multimodal"
        }
      }
    }
    
  2. Submit a multimodal embedding / image search.
  3. Observe: the outbound HTTP request body contains text-only input (image parts already removed by prepare_embedding_input), and image search is rejected.

Expected Behavior

Either:

  • (a) Docs fix: state explicitly that input: "multimodal" currently applies to the volcengine provider only; or
  • (b) Implementation fix: forward input to the ("openai", "dense") factory entry and add a supports_multimodal override on OpenAIDenseEmbedder honoring it (the wire format — input: [{"type":"text",...},{"type":"image_url","image_url":{"url":...}}] content parts — is already the shape build_multimodal_embedding_input() produces, so the only changes needed are the config passthrough and the capability flag).

Option (b) would let OpenAI-compatible multimodal embedding backends (local llama.cpp/MMAudio-style servers, third-party gateways) work out of the box.

Related Gap (same config path)

For provider: "openai" with a custom api_base, _should_send_dimensions() returns False (it returns True only for non-openai providers with api_base, and for azure), so the configured dimension is never sent to the backend — the backend cannot honor MRL truncation, and OpenAIDenseEmbedder._truncate_vector() truncates client-side without re-normalization (cosine ranking is unaffected, but dot-product/cosine-with-normalized-insert vector stores see inconsistent norms). The docstring above the method states the opposite intent ("only custom OpenAI-compatible backends and Azure send explicit dimensions"), which suggests this is unintentional.

Environment

  • OpenViking main @ b8c89099
  • Related: #566 (Gemini Embedding 2 — reverted), #372 (multimodal resource parsing)

blakejia avatar Aug 27 '26 17:08 blakejia

Correction to the "Related Gap" section (from live traffic evidence):

While load-testing against a deployed OpenViking build (reindex workload, ~1.2k requests), every /v1/embeddings request did include dimensions: 1024 — the proxy received and honored it (server-side MRL truncation + L2 renormalization from 2048 → 1024). So the claim that "_should_send_dimensions() returns False for custom api_base and the dimension is never sent" does not match this deployed build's behavior; the static reading applies to current main HEAD (_provider == "openai" → False unconditionally), which contradicts the method's own docstring. Possibly the deployed build predates/postdates a behavior change, or the check was intended to special-case official OpenAI only.

Suggest maintainers verify the intended semantics at HEAD: for provider: "openai" + custom api_base, dimensions should be forwarded per the docstring, but current code returns False unconditionally.

The main multimodal finding (input: "multimodal" ignored for provider=openai) is unaffected by this correction.

blakejia avatar Aug 27 '26 17:08 blakejia