From 8666ec9bd66ab86c67416ca7b37bce2f5bac3f83 Mon Sep 17 00:00:00 2001 From: Roland Tannous Date: Sun, 24 May 2026 21:48:02 +0400 Subject: [PATCH] Studio: swap multimodal RAG embedder to Qwen3-VL-Embedding-2B MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Built on Qwen3 (not CLIP), so the 77-token text cap that bit BGE-VL-base is gone — long chunks embed losslessly. Loads via vanilla SentenceTransformer with trust_remote_code, no custom adapter needed. 2048-d shared text+image space. Adds qwen-vl-utils>=0.0.14 to rag.txt for image preprocessing, required by the Qwen3-VL embedder family. --- studio/backend/requirements/rag.txt | 4 ++++ studio/backend/utils/rag/config.py | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/studio/backend/requirements/rag.txt b/studio/backend/requirements/rag.txt index 11bbf906e5..3614a969e9 100644 --- a/studio/backend/requirements/rag.txt +++ b/studio/backend/requirements/rag.txt @@ -10,6 +10,10 @@ qdrant-client>=1.12 bm25s>=0.2 +# Image preprocessing helpers required by Qwen3-VL-Embedding-2B (the +# multimodal embedder). Not used in text-only mode. +qwen-vl-utils>=0.0.14 + # Layout-aware Markdown extraction (Phase 3A) so the chunker can split # on real headings instead of running paragraphs together. pymupdf4llm # preserves headings + pipe-tables; mammoth handles DOCX Heading styles; diff --git a/studio/backend/utils/rag/config.py b/studio/backend/utils/rag/config.py index fb16be0e27..fbe5366260 100644 --- a/studio/backend/utils/rag/config.py +++ b/studio/backend/utils/rag/config.py @@ -40,12 +40,12 @@ RAG_EMBEDDING_MODEL: str = ( 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", - # BGE-VL-base is loaded via the canonical `transformers.AutoModel` - # path (with trust_remote_code) — see `_BGEVLAdapter` in - # core/rag/embeddings.py. This bypasses BGE-VL's sentence-transformers - # shim entirely, sidestepping the ST-version coupling in the repo's - # custom Transformer subclass. 512-d shared text+image space. - ("multimodal", "standard"): "BAAI/BGE-VL-base", + # Qwen3-VL-Embedding-2B: 2B-param multimodal embedder built on + # Qwen3 (not CLIP), so no 77-token text cap — long chunks embed + # losslessly. Loads through vanilla SentenceTransformer with + # trust_remote_code, no shim. 2048-d shared text/image space. + # Trade-off: ~4 GB download / VRAM vs BGE-VL-base's ~600 MB. + ("multimodal", "standard"): "Qwen/Qwen3-VL-Embedding-2B", }