From bdbf47a341d70cdc67b5c4ba95abaace7e79d88a Mon Sep 17 00:00:00 2001 From: Roland Tannous Date: Wed, 27 May 2026 00:11:40 +0400 Subject: [PATCH] Studio: default multimodal RAG embedder to BAAI/BGE-VL-large (Qwen3-VL kept as alt) --- studio/backend/requirements/extras-no-deps.txt | 7 ++++--- studio/backend/routes/rag.py | 7 +++---- studio/backend/utils/rag/config.py | 14 +++++++++++++- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/studio/backend/requirements/extras-no-deps.txt b/studio/backend/requirements/extras-no-deps.txt index 952a709137..78eec61cbf 100644 --- a/studio/backend/requirements/extras-no-deps.txt +++ b/studio/backend/requirements/extras-no-deps.txt @@ -15,9 +15,10 @@ git+https://github.com/meta-pytorch/OpenEnv.git # executorch>=1.0.1 # 41.5 MB - no imports in unsloth/zoo/studio torch-c-dlpack-ext # Bumped from 5.2.0 to expose the `sentence_transformers.base.modules` -# package that Qwen3-VL-Embedding-2B (the multimodal RAG embedder) -# references in its modules.json. Upper bound left at <7 to avoid -# accidental jumps across a future major rewrite. +# package that Qwen3-VL-Embedding-2B references in its modules.json +# (still supported as an alternative multimodal RAG embedder; the +# current default is BAAI/BGE-VL-large via our in-process adapter). +# Upper bound at <7 to avoid jumps across a future major rewrite. sentence_transformers>=5.3.0,<7 transformers==4.57.6 pytorch_tokenizers diff --git a/studio/backend/routes/rag.py b/studio/backend/routes/rag.py index 38ef6b14e4..7ad38c3b64 100644 --- a/studio/backend/routes/rag.py +++ b/studio/backend/routes/rag.py @@ -441,10 +441,9 @@ def warmup_rag_embedder( ) -> dict: """Preload the configured default embedder so the first retrieval is warm. - Called from the frontend when the user enables the RAG pill — moves the - cold-load latency (Qwen3-VL-Embedding-2B is ~4 GB) out of the first - chat-completion path, where a 30s+ load can race the llama-server - prefill timeout. + Called from the frontend when the user enables the RAG pill — moves + the cold-load latency out of the first chat-completion path, where a + multi-second load can race the llama-server prefill timeout. """ from utils.rag.config import resolve_embedder diff --git a/studio/backend/utils/rag/config.py b/studio/backend/utils/rag/config.py index e394288368..b265b90b51 100644 --- a/studio/backend/utils/rag/config.py +++ b/studio/backend/utils/rag/config.py @@ -33,10 +33,22 @@ RAG_EMBEDDING_MODEL: str = ( # Default embedder per (mode, chunking). (multimodal, late) is unsupported # and rejected at KB-create time in routes/rag.py. +# +# Multimodal default is BAAI/BGE-VL-large (~400 M params, 768-d, ~800 MB +# bf16) — small, fast, shared text/image space. Loaded via the +# `_BGEVLAdapter` in core/rag/embeddings.py which bypasses BGE-VL's +# fragile sentence-transformers shim and pre-truncates text to CLIP's +# 77-token cap. +# +# To switch back to Qwen3-VL-Embedding-2B (2 B params, 2048-d, no CLIP +# text cap; ~4 GB bf16 / ~1.5 GB 4-bit via FastSentenceTransformer), +# change the ("multimodal", "standard") entry below — the in-process +# loader supports both via `model_name.startswith("BAAI/BGE-VL")` +# routing. RAG_EMBEDDER_MATRIX: dict[tuple[str, str], str] = { ("text", "standard"): "BAAI/bge-small-en-v1.5", ("text", "late"): "nomic-ai/nomic-embed-text-v1.5", - ("multimodal", "standard"): "Qwen/Qwen3-VL-Embedding-2B", + ("multimodal", "standard"): "BAAI/BGE-VL-large", }