Open-source inference server and production cluster for all the models your agent needs.
Python bgecolbertdata-pipelinedeep-learningembeddingsinferenceinference-serverinformation-retrievalllmmlmlopsnatural-language-processingnlppythonrerankingretrievalretrieval-augmented-generationsemantic-searchspladevector-search
examples(vision-doc-rag): all-Qwen pipeline + curated corpus
svonavab83507829931
diff --git a/examples/vision-doc-rag/README.md b/examples/vision-doc-rag/README.mdindex 52e37cd15..87280a52d 100644--- a/examples/vision-doc-rag/README.md+++ b/examples/vision-doc-rag/README.md@@ -1,10 +1,12 @@# Vision-first document RAG-Retrieve by image, answer by image. ColQwen2.5 reads each PDF page as a-picture and ranks pages via late interaction; Florence-2-DocVQA reads the-winning page and produces the textual answer. OCR never enters the score path,-so schematics, pinout diagrams, architecture slides, charts, and other layout-cues still drive ranking. Everything runs on one SIE endpoint.+Retrieve by image, answer by image. The whole pipeline is Qwen-family:+ColQwen2.5 reads each PDF page as a picture and ranks pages via late+interaction; Qwen3.5-4B (a vision LLM) reads the winning page image and+produces the textual answer. OCR never enters the score path, so schematics,+pinout diagrams, architecture slides, charts, and scanned engineering drawings+still drive ranking — and because the answer model reads the image too, a page+never needs a text layer at all. Everything runs on one SIE endpoint.Each page also carries a `client` tag, so the same corpus serves multipletenants from one index. Queries scoped to `embedded-lab` cannot retrieve@@ -19,8 +21,8 @@ fast while still indexing visually rich pages.| Tenant | Sources | Visual signal ||---|---|---|| `embedded-lab` | Raspberry Pi Pico datasheet, Arduino UNO R3 datasheet, Arduino UNO R3 schematic | Pinout diagrams, board diagrams, circuit schematics |-| `ops-eng` | PostgreSQL manual, CNCF Kubernetes / cloud-native architecture material | Architecture diagrams, operational flows, dense technical tables |-| `aerospace` | NASA NTRS nozzle and booster reports | Engineering drawings, cross-sections, charts, mission technical figures |+| `ops-eng` | PostgreSQL 18 manual (config reference), CNCF Kubernetes / cloud-native architecture material | Architecture diagrams, operational flows, dense config tables |+| `aerospace` | NASA SP-8115 / SP-8120 rocket nozzle design reports | Scanned engineering drawings and nozzle cross-sections — pages with **no text layer**, so only visual retrieval finds them |Generated files are ignored:@@ -38,15 +40,17 @@ data/multivectors.npz # page multivectors from ingest.py- `encode` - `vidore/colqwen2.5-v0.2` on page images at ingest and on querytext at search time. Output is a `[tokens, 128]` multivector. Lateinteraction (`sie_sdk.scoring.maxsim`) is the first-stage ranking signal.-- `extract` - `mynkchaudhry/Florence-2-FT-DocVQA`. Called with- `instruction=<your question>` to get a textual answer for the top page, and- without `instruction` to OCR the same page for a display snippet. The OCR- snippet is UX-only; it never enters ranking.+- chat/completions - `Qwen/Qwen3.5-4B`, a vision+text LLM, reads the winning+ page image plus the question and returns a short answer. It runs over SIE's+ OpenAI-compatible `/v1/chat/completions` endpoint (the SIE SDK's `generate()`+ is text-only); see `python/search.py:_vqa_answer`. Because it reads the page+ as an image, scanned pages with no text layer still get answered.- `score` optional - `Qwen/Qwen3-VL-Reranker-2B` second-stage rerank over- `(query text, page image)`. Off by default while we wait for upstream fixes- (image inputs on the SDK `score()` path and the cluster-side visual rerank- adapter); flip `search.visual_rerank: true` in `config.yaml` to enable it on- a stack that has them.+ `(query text, page image)`, keeping reranking in the same visual modality as+ retrieval. Off by default; flip `search.visual_rerank: true` in `config.yaml`+ to enable it on a deployment that serves the visual reranker (multi-image+ rerank also needs the gateway payload store configured). If the stack can't+ serve it, search falls back to the MaxSim ranking.## Run it@@ -77,9 +81,14 @@ open http://localhost:8888not installed, it falls back to PyMuPDF, which is installed from`python/requirements.txt`.-First run on a cold cluster pays a one-time model load. ColQwen2.5 and-Florence-2 are both several GB, so expect roughly a minute on CPU and a few-seconds on GPU before the warm path kicks in.+First run on a cold cluster pays a one-time model load. ColQwen2.5 and the+Qwen3.5-4B answer model are several GB each, so expect a wait before the warm+path kicks in. The answer model runs on the generation bundle, which can scale+from zero — the first question may take a few minutes to provision while later+ones are fast; `_vqa_answer` retries the "still loading" responses under+`cluster.provision_timeout_s`. To skip that wait on a managed cluster, keep the+generation bundle warm — give it `minReplicas: 1` in your SIE deployment so+Qwen3.5-4B stays resident between queries.### Managed cluster@@ -94,45 +103,41 @@ explicit GPU class.## Try these queries-Queries are grouped by what they exercise. Each row names the expected target-page so you can spot regressions at a glance.+Each row names the page the demo should retrieve — and, for value lookups, the+answer the vision model reads off it — so you can spot regressions at a glance.+These are the runs that back the CLI demo in `python/search.py`.### Visual signal — the ranking comes from the page image, not OCR-| Tenant | Query | Expected target | Why it's interesting |+| Tenant | Query | Retrieves | Why it's interesting ||---|---|---|---|-| `embedded-lab` | Raspberry Pi Pico pinout GP21 | Pi Pico datasheet pinout (pp 4-5) | Abbreviated visual label still drives retrieval. |-| `embedded-lab` | where is the ATmega16U2 on the schematic? | Arduino UNO R3 schematic (pp 1-2) | Circuit schematic retrieval, not prose. |-| `ops-eng` | cloud native architecture diagram | CNCF AI whitepaper or Kubernetes slides | Visual architecture page instead of OCR text. |-| `aerospace` | solid rocket motor nozzle design figure | Solid rocket motor nozzles report | Engineering drawing in a figure-heavy report. |+| `embedded-lab` | Raspberry Pi Pico pinout diagram | Pi Pico datasheet pinout page | Colored pinout diagram drives ranking, not prose. |+| `ops-eng` | Kubernetes architecture diagram | CNCF Kubernetes slides | Visual architecture slide instead of OCR text. |+| `aerospace` | solid rocket motor nozzle cross-section drawing | Solid nozzle report (NASA SP-8115) | Scanned drawing with **no text layer** — only visual retrieval finds it. |+| _(no filter)_ | Arduino UNO power tree diagram | Arduino UNO datasheet power-tree page | Routes to the right tenant unfiltered. |-### Table / value lookups — the DocVQA answer is the point+### Value lookups — the vision model reads a value off the page-| Tenant | Query | Expected target | Expected answer |+| Tenant | Query | Page | Answer ||---|---|---|---|-| `embedded-lab` | What is the operating voltage range of the Raspberry Pi Pico? | Pi Pico datasheet electrical characteristics (pp 6-8) | A voltage range, e.g. 1.8-5.5 V |-| `embedded-lab` | Which Arduino UNO pin is the built-in LED on? | UNO R3 datasheet pinout (pp 5-11) | D13 / PB5 |-| `ops-eng` | PostgreSQL default listening port | PG 18 manual config section (pp 19-24) | 5432 |-| `ops-eng` | What is the default value of max_connections in PostgreSQL? | PG 18 manual parameter table (pp 19-24) | 100 |-| `aerospace` | What is the throat diameter shown in the nozzle drawing? | Nozzle design figure | A labeled dimension off the drawing |+| `ops-eng` | What is the default TCP port a PostgreSQL server listens on? | PG 18 manual, Connection Settings | `5432` |+| `ops-eng` | What is the default value of max_connections in PostgreSQL? | PG 18 manual, Connection Settings | `100` |+| `embedded-lab` | What is the GPIO (IO) voltage of the Raspberry Pi Pico? | Pi Pico datasheet | `3.3V` |-### Disambiguation — two PDFs in one tenant, the right one must win+### Disambiguation — two reports in one tenant, the right one must win-| Tenant | Query | Should pick | Should beat |+| Tenant | Query | Picks | Beats ||---|---|---|---|-| `aerospace` | solid propellant rocket nozzle cross-section | `solid-rocket-motor-nozzles.pdf` | `liquid-rocket-engine-nozzles.pdf` |-| `aerospace` | regeneratively cooled nozzle | `liquid-rocket-engine-nozzles.pdf` (regen cooling is liquid-specific) | `solid-rocket-motor-nozzles.pdf` |-| `embedded-lab` | USB-to-serial interface chip on the schematic | `arduino-uno-r3-schematic.pdf` (ATmega16U2) | `raspberry-pi-pico-datasheet.pdf` |-| `embedded-lab` | RP2040 GPIO function table | `raspberry-pi-pico-datasheet.pdf` | `arduino-uno-r3-datasheet.pdf` |+| `aerospace` | regeneratively cooled nozzle | `liquid-rocket-engine-nozzles.pdf` (regenerative cooling is liquid-specific) | `solid-rocket-motor-nozzles.pdf` |+| `aerospace` | solid rocket motor nozzle cross-section drawing | `solid-rocket-motor-nozzles.pdf` | `liquid-rocket-engine-nozzles.pdf` |### Tenant-leak negatives — the matching content lives in a different tenant| Scoped to | Query | Pass condition ||---|---|---|-| `ops-eng` | Raspberry Pi Pico pinout GP21 | No embedded-lab pages return. || `ops-eng` | regeneratively cooled nozzle | No aerospace pages return. |-| `aerospace` | cloud native architecture diagram | No ops-eng pages return. |-| `embedded-lab` | PostgreSQL connection pool | No ops-eng pages return. |+| `aerospace` | Kubernetes architecture diagram | No ops-eng pages return. |+| `embedded-lab` | PostgreSQL default port | No ops-eng pages return. |## API@@ -144,14 +149,14 @@ page so you can spot regressions at a glance.| `client` | no | Tenant filter, for example `embedded-lab`. Omitted means search all tenants. |```bash-curl "http://localhost:8888/api/search?q=Raspberry+Pi+Pico+pinout+GP21&client=embedded-lab"+curl "http://localhost:8888/api/search?q=What+is+the+GPIO+voltage+of+the+Raspberry+Pi+Pico%3F&client=embedded-lab"``````json{- "query": "Raspberry Pi Pico pinout GP21",+ "query": "What is the GPIO voltage of the Raspberry Pi Pico?","client": "embedded-lab",- "answer": "GP21 can be used for ...",+ "answer": "1.8-3.3V","results": [{"page_id": "embedded-lab__raspberry-pi-pico-datasheet__p005",@@ -162,7 +167,7 @@ curl "http://localhost:8888/api/search?q=Raspberry+Pi+Pico+pinout+GP21&client=em"page_number": 5,"citation": "raspberry-pi-pico-datasheet.pdf · p.5","page_image": "/pages/embedded-lab/raspberry-pi-pico-datasheet_p005.png",- "scores": { "maxsim": 14.44, "rerank": null }+ "scores": { "maxsim": 19.63, "rerank": null }}]}@@ -187,12 +192,12 @@ Tenant list and runtime config: active models, rerank on/off, and page count.-> filter metadata by tenant-> sie_sdk.scoring.maxsim -> top_k_candidates-> optional SIE.score(Qwen3-VL-Reranker, q, images)- -> SIE.extract(Florence-2-DocVQA, instruction=q, images=[top_page])- -> SIE.extract(Florence-2-DocVQA, images=[top_page]) for display OCR+ -> Qwen3.5-4B (vision) via /v1/chat/completions on [top_page] -> answer```-OCR is never on the score path. The visual reranker, when enabled, ranks over-the same modality as retrieval, so layout cues survive both stages.+OCR is never on the score path — retrieval and the answer both read the page as+an image. The visual reranker, when enabled, ranks over the same modality as+retrieval, so layout cues survive every stage.The corpus is small enough that MaxSim runs in Python. For thousands of pages,hand the multivectors to LanceDB, Vespa, or another multivector store; the SIE@@ -227,7 +232,7 @@ python python/ingest.py```yamlmodels:retriever: "vidore/colqwen2.5-v0.2"- docvqa: "mynkchaudhry/Florence-2-FT-DocVQA"+ answer: "Qwen/Qwen3.5-4B"reranker: "Qwen/Qwen3-VL-Reranker-2B"render:backend: "auto"@@ -237,7 +242,6 @@ search:top_k_results: 3visual_rerank: falseanswer: true- ocr_snippet: true```## Project layoutdiff --git a/examples/vision-doc-rag/config.yaml b/examples/vision-doc-rag/config.yamlindex 1094ff022..9a5cf62b1 100644--- a/examples/vision-doc-rag/config.yaml+++ b/examples/vision-doc-rag/config.yaml@@ -6,25 +6,27 @@ cluster:gpu: "" # only set for managed multi-GPU clusters (e.g. "l4-spot"); ignored locallyprovision_timeout_s: 600-# Models. The retrieval signal is vision end-to-end: ColQwen2.5 reads each page-# as an image and we late-interact (MaxSim) against the same model's text-side-# embedding of the query. No OCR is involved in ranking, so charts, screenshots,-# tables, and any other layout cue that wouldn't survive an OCR round-trip-# still contributes to the score.+# Models. The pipeline is Qwen-family end to end and never collapses a page+# through OCR. ColQwen2.5 reads each page as an image and we late-interact+# (MaxSim) against the same model's text-side embedding of the query, so charts,+# screenshots, tables, and any other layout cue that wouldn't survive an OCR+# round-trip still contributes to the score.#-# DocVQA produces a textual answer for the top page. The model takes the page-# image + the user's question (passed via `instruction`) and returns the answer-# as an entity in the response — no separate LLM call needed.+# The answer model (Qwen3.5-4B) is a vision+text LLM: it reads the winning page+# image and the user's question and returns a short textual answer. Because it+# reads the image, the page never needs a text layer — scanned drawings work.+# It runs over SIE's OpenAI-compatible /v1/chat/completions endpoint (the SIE+# SDK's generate() is text-only); see python/search.py:_vqa_answer.models:retriever: "vidore/colqwen2.5-v0.2"- docvqa: "mynkchaudhry/Florence-2-FT-DocVQA"- # Optional second-stage cross-encoder rerank. Visual model so we don't have to- # collapse the page through OCR before reranking. Disabled by default — two- # blockers as of 0.6.4 (verified against sie-test 2026-06-12):- # https://github.com/superlinked/sie-internal/issues/1368 (sdk: score() image inputs)- # https://github.com/superlinked/sie-internal/issues/1367 (server: adapter image tokens)- # Text-only rerank works. Re-enable with search.visual_rerank: true once both- # fixes ship.+ answer: "Qwen/Qwen3.5-4B"+ # Optional second-stage cross-encoder rerank over (query text, page image), so+ # layout cues survive reranking instead of being flattened through OCR. Off by+ # default: it needs a SIE deployment recent enough to serve the visual reranker,+ # and multi-image score requests rely on the gateway payload store being+ # configured (large work items get offloaded to object storage rather than sent+ # inline over the queue). Flip search.visual_rerank: true to enable it; if the+ # stack can't serve it, search falls back to the MaxSim ranking.reranker: "Qwen/Qwen3-VL-Reranker-2B"# Page rendering. `auto` tries pdf2image/Poppler first and falls back to@@ -38,5 +40,4 @@ search:top_k_candidates: 5 # how many pages survive MaxSimtop_k_results: 3 # how many pages return after optional rerankvisual_rerank: false # see models.reranker note above- answer: true # run DocVQA on the top page for a textual answer- ocr_snippet: true # OCR the top page for a display-only snippet in the UI+ answer: true # read the top page with the vision LLM for a textual answerdiff --git a/examples/vision-doc-rag/data/fetch_pdfs.py b/examples/vision-doc-rag/data/fetch_pdfs.pyindex 21ade8444..84a9b9f58 100644--- a/examples/vision-doc-rag/data/fetch_pdfs.py+++ b/examples/vision-doc-rag/data/fetch_pdfs.py@@ -52,7 +52,7 @@ SOURCES = ["publisher": "PostgreSQL Global Development Group","license": "PostgreSQL License","url": "https://www.postgresql.org/files/documentation/pdf/18/postgresql-18-A4.pdf",- "pages": [19, 20, 21, 22, 23, 24],+ "pages": [673, 674, 675, 676],},{"client": "ops-eng",@@ -75,29 +75,22 @@ SOURCES = [{"client": "aerospace","slug": "solid-rocket-motor-nozzles",- "title": "Solid Rocket Motor Nozzles",+ "title": "Solid Rocket Motor Nozzles (NASA SP-8115)","publisher": "NASA Technical Reports Server","license": "NASA STI public release",- "url": "https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19760013126.pdf",- "pages": [1, 2, 3, 4, 5, 6],+ # NTRS citation-download API returns the actual scanned report (with the+ # engineering drawings); the /archive/ path returns the HTML landing page.+ "url": "https://ntrs.nasa.gov/api/citations/19760013126/downloads/19760013126.pdf",+ "pages": [14, 15, 20, 22, 49, 50],},{"client": "aerospace","slug": "liquid-rocket-engine-nozzles",- "title": "Liquid Rocket Engine Nozzles",+ "title": "Liquid Rocket Engine Nozzles (NASA SP-8120)","publisher": "NASA Technical Reports Server","license": "NASA STI public release",- "url": "https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19770009165.pdf",- "pages": [1, 2, 3, 4, 5, 6],- },- {- "client": "aerospace",- "slug": "sls-booster-state-machine",- "title": "State Machine Modeling of the Space Launch System Solid Rocket Boosters",- "publisher": "NASA Technical Reports Server",- "license": "NASA STI public release",- "url": "https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20160000328.pdf",- "pages": [1, 2, 3, 4, 5, 6],+ "url": "https://ntrs.nasa.gov/api/citations/19770009165/downloads/19770009165.pdf",+ "pages": [23, 27, 42, 43, 46, 49],},]diff --git a/examples/vision-doc-rag/python/requirements.txt b/examples/vision-doc-rag/python/requirements.txtindex d482d62a2..c1839dd48 100644--- a/examples/vision-doc-rag/python/requirements.txt+++ b/examples/vision-doc-rag/python/requirements.txt@@ -1,4 +1,5 @@-sie-sdk==0.6.4+sie-sdk==0.6.8+httpx>=0.27.0fastapi>=0.115.0uvicorn>=0.30.0numpy>=1.26.0diff --git a/examples/vision-doc-rag/python/search.py b/examples/vision-doc-rag/python/search.pyindex 74f86cd1f..ea33b5bff 100644--- a/examples/vision-doc-rag/python/search.py+++ b/examples/vision-doc-rag/python/search.py@@ -1,19 +1,18 @@"""Visual document search + question answering, vision end-to-end.-Pipeline per query:- 1. encode(ColQwen2.5, text) — query multivector- 2. sie_sdk.scoring.maxsim — late interaction against page images- 3. score(Qwen3-VL-Reranker, query, images) — optional, off by default- 4. extract(Florence-2-FT-DocVQA, instruction=query, images=[top page])- — textual answer + citation- 5. extract(Florence-2-FT-DocVQA, images=[top page])- — OCR snippet for the UI (display only,- NOT in the ranking path)+The whole pipeline is Qwen-family and never collapses a page through OCR:++ 1. encode(ColQwen2.5, text) — query multivector+ 2. sie_sdk.scoring.maxsim — late interaction against page images+ 3. score(Qwen3-VL-Reranker, query, images) — optional second stage, off by default+ 4. Qwen3.5-4B (vision) via /v1/chat/completions — reads the winning page image+ and answers the questionThe ranking is decided by a vision model looking at the page image, so charts,-screenshots, tables, and any other visual signal that OCR would erase still-contributes. OCR runs only on the chosen page, only to provide on-screen text-the user can read or copy.+schematics, pinout diagrams, scanned engineering drawings, and any other layout+cue that an OCR round-trip would erase still contributes to the score. The+answer step also reads the page as an image, so the page never has to have a+text layer at all.Multi-tenant isolation is a Python filter on metadata before MaxSim, so aquery scoped to one client never sees another client's pages.@@ -21,11 +20,13 @@ query scoped to one client never sees another client's pages.from __future__ import annotations+import base64import jsonimport osimport timefrom pathlib import Path+import httpximport numpy as npimport yaml@@ -57,30 +58,66 @@ def load_index():return multivectors, metadata-def _ocr_snippet(entities: list[dict], max_chars: int = 400) -> str:- """Concatenate OCR text regions into a single readable snippet."""- pieces = []- for e in entities or []:- text = (e.get("text") or "").replace("</s>", "").strip()- if text:- pieces.append(text)- joined = " · ".join(pieces)- if len(joined) > max_chars:- return joined[: max_chars - 1] + "…"- return joined---def _docvqa_answer(entities: list[dict]) -> str:- """Pick the answer string out of a Florence-2 DocVQA response.-- Florence-2 returns the answer as an entity (often the single one when the- `<DocVQA>` task token is dispatched). We take the first non-empty text.+_ANSWER_SYSTEM = (+ "You are shown one page of a document as an image and a question about it. "+ "Answer with the shortest exact value, name, or phrase taken from the page — "+ "no explanation. If the page does not contain the answer, reply exactly: "+ "not shown on this page."+)+++def _vqa_answer(+ cluster_url: str,+ api_key: str,+ model: str,+ question: str,+ image_path: str,+ provision_timeout_s: float,+) -> str:+ """Answer a question about one page image with a vision LLM.++ Qwen3.5-4B is a vision+text generation model, so it reads the page image+ directly. SIE exposes generation through the OpenAI-compatible+ `/v1/chat/completions` endpoint (the SIE SDK's `generate()` is text-only),+ so this is a plain multimodal chat call rather than an SDK method."""- for e in entities or []:- text = (e.get("text") or "").replace("</s>", "").strip()- if text:- return text- return ""+ data = base64.b64encode(Path(image_path).read_bytes()).decode()+ payload = {+ "model": model,+ "messages": [+ {"role": "system", "content": _ANSWER_SYSTEM},+ {+ "role": "user",+ "content": [+ {"type": "text", "text": question},+ {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{data}"}},+ ],+ },+ ],+ "max_tokens": 64,+ "temperature": 0.0,+ }+ headers = {"Content-Type": "application/json"}+ if api_key:+ headers["Authorization"] = f"Bearer {api_key}"++ # The generation bundle can scale from zero. While it provisions, the+ # gateway may answer 202/503 ("still loading") or hold the connection until+ # it times out; retry both under the provisioning budget, like the SDK does.+ deadline = time.time() + provision_timeout_s+ while True:+ try:+ resp = httpx.post(f"{cluster_url}/v1/chat/completions", json=payload, headers=headers, timeout=120.0)+ except httpx.TransportError:+ if time.time() < deadline:+ time.sleep(5)+ continue+ raise+ if resp.status_code in (202, 503) and time.time() < deadline:+ time.sleep(5)+ continue+ resp.raise_for_status()+ return resp.json()["choices"][0]["message"]["content"].strip()def search(@@ -97,7 +134,8 @@ def search(top_k_results = config["search"]["top_k_results"]do_visual_rerank = config["search"].get("visual_rerank", False)do_answer = config["search"].get("answer", True)- do_ocr_snippet = config["search"].get("ocr_snippet", True)+ answer_url = os.environ.get("SIE_CLUSTER_URL", config["cluster"]["url"])+ answer_key = os.environ.get("SIE_API_KEY", config["cluster"]["api_key"])corpus = [m for m in metadata if not client_filter or m["client"] == client_filter]if not corpus:@@ -135,8 +173,8 @@ def search(candidates.append(c)# 3. Optional visual rerank. Image-in cross-encoder so OCR never enters the- # ranking path. Disabled by default — see config.yaml for the cluster- # bug we're waiting on.+ # ranking path. Off by default; see config.yaml for what a deployment+ # needs to serve it.if do_visual_rerank and candidates:try:t0 = time.time()@@ -159,50 +197,31 @@ def search(c["_rerank_score"] = float(s["score"]) if s else 0.0candidates.sort(key=lambda c: c["_rerank_score"] or 0.0, reverse=True)except Exception as exc:- # Cluster adapter bug fallback: keep MaxSim ordering, surface the- # failure to the caller. See sie-internal#1026.+ # If the deployment can't serve the reranker, keep the MaxSim+ # ordering and surface the failure to the caller.timings["visual_rerank_error"] = type(exc).__name__results = candidates[:top_k_results]- # 4. DocVQA answer from the top page image. instruction= goes in as the- # plain question; the adapter prepends Florence-2's `<DocVQA>` task- # token. See superlinked.com/docs/extract/vision.+ # 4. Answer from the top page image with the Qwen3.5-4B vision model. It+ # reads the page as an image, so the answer survives even on a scanned+ # page with no text layer.answer = Noneif do_answer and results:top = results[0]try:t0 = time.time()- qa = client.extract(- config["models"]["docvqa"],- Item(images=[str(pages_root / top["image_path"])]),- instruction=query,- gpu=gpu,- wait_for_capacity=True,- provision_timeout_s=timeout,- )- timings["docvqa_s"] = round(time.time() - t0, 3)- answer = _docvqa_answer(qa["entities"])- except Exception as exc:- timings["docvqa_error"] = type(exc).__name__-- # 5. OCR snippet for display — only on the top result so users see the- # text on the page they're being shown. Never used as a ranking signal.- if do_ocr_snippet and results:- top = results[0]- try:- t0 = time.time()- ocr = client.extract(- config["models"]["docvqa"], # same model, no `instruction` ⇒ OCR mode- Item(images=[str(pages_root / top["image_path"])]),- gpu=gpu,- wait_for_capacity=True,- provision_timeout_s=timeout,+ answer = _vqa_answer(+ answer_url,+ answer_key,+ config["models"]["answer"],+ query,+ str(pages_root / top["image_path"]),+ timeout,)- timings["ocr_snippet_s"] = round(time.time() - t0, 3)- top["ocr_snippet"] = _ocr_snippet(ocr["entities"])+ timings["answer_s"] = round(time.time() - t0, 3)except Exception as exc:- timings["ocr_snippet_error"] = type(exc).__name__+ timings["answer_error"] = type(exc).__name__return {"results": results, "answer": answer, "timings": timings}@@ -222,8 +241,6 @@ def print_run(out: dict, query: str, client_filter: str | None):print(f"\n {i}. [{r['client']}] {r['title']}")print(f" {r['source_pdf']} · p.{r['page_number']} · {r['publisher']}")print(f" maxsim={r['_maxsim_score']:.3f} {rerank_str}")- if r.get("ocr_snippet"):- print(f" OCR snippet: {r['ocr_snippet'][:200]}")print(f" url: {r['source_url']}")@@ -236,19 +253,21 @@ def main():api_key = os.environ.get("SIE_API_KEY", config["cluster"]["api_key"])demo = [- # Visual signal — ranking is driven by the page image.- ("Raspberry Pi Pico pinout GP21", "embedded-lab"),- ("cloud native architecture diagram", "ops-eng"),- ("solid rocket motor nozzle design figure", "aerospace"),- # No tenant filter: shows the query routes across tenants.- ("ATmega16U2 power tree diagram", None),- # Table / value lookup — DocVQA must return a specific value, not the title.- ("What is the operating voltage range of the Raspberry Pi Pico?", "embedded-lab"),- ("PostgreSQL default listening port", "ops-eng"),- # Disambiguation — two PDFs in one tenant; the right one must win.- ("solid propellant rocket nozzle cross-section", "aerospace"),- # Tenant-leak negative — the matching content lives in aerospace; scoping- # to ops-eng must return no aerospace pages.+ # Read a value straight off a dense config page.+ ("What is the default TCP port a PostgreSQL server listens on?", "ops-eng"),+ ("What is the default value of max_connections in PostgreSQL?", "ops-eng"),+ # Read a spec off a hardware datasheet.+ ("What is the GPIO (IO) voltage of the Raspberry Pi Pico?", "embedded-lab"),+ # Scanned engineering drawing: the page has no text layer, so only the+ # visual retrieval finds it — and the vision model still reads the figure.+ ("What does Figure 7 in the solid rocket motor nozzle report show?", "aerospace"),+ # No tenant filter: the question routes to the right tenant on its own.+ ("Which Arduino UNO datasheet section covers the power tree?", None),+ # Disambiguation: regenerative cooling is liquid-specific, so the liquid+ # report must win over the solid one in the same aerospace tenant.+ ("regeneratively cooled nozzle", "aerospace"),+ # Tenant isolation: that content lives in aerospace; scoped to ops-eng it+ # must surface zero aerospace pages.("regeneratively cooled nozzle", "ops-eng"),]with SIEClient(cluster_url, api_key=api_key) as client:diff --git a/examples/vision-doc-rag/python/server.py b/examples/vision-doc-rag/python/server.pyindex 990857fac..a3ce84587 100644--- a/examples/vision-doc-rag/python/server.py+++ b/examples/vision-doc-rag/python/server.py@@ -88,7 +88,6 @@ def api_search("page_number": r["page_number"],"citation": f"{r['source_pdf']} · p.{r['page_number']}","page_image": f"/{r['image_path']}",- "ocr_snippet": r.get("ocr_snippet", ""),"scores": {"maxsim": round(r["_maxsim_score"], 4),"rerank": round(r["_rerank_score"], 4) if r.get("_rerank_score") is not None else None,diff --git a/examples/vision-doc-rag/static/index.html b/examples/vision-doc-rag/static/index.htmlindex 2b3eb7c31..b1dde2200 100644--- a/examples/vision-doc-rag/static/index.html+++ b/examples/vision-doc-rag/static/index.html@@ -115,7 +115,7 @@<body><header><h1>Multi-Tenant Visual Doc Search + QA</h1>- <p>ColQwen2.5 ranks pages by looking at the images. Florence-2-DocVQA reads the top page and answers the question. All on one SIE endpoint.</p>+ <p>ColQwen2.5 ranks pages by looking at the images. Qwen3.5-4B reads the top page image and answers the question. All on one SIE endpoint.</p></header><main><form id="searchForm">@@ -154,7 +154,7 @@const rerank = r.visual_rerank ? "on" : "off";statsEl.textContent =`${r.total_pages} pages · ${r.clients.length} clients · ` +- `retriever=${r.models.retriever} · docvqa=${r.models.docvqa} · visual rerank=${rerank}`;+ `retriever=${r.models.retriever} · answer=${r.models.answer} · visual rerank=${rerank}`;}form.addEventListener("submit", async (e) => {@@ -169,7 +169,7 @@if (res.answer) {answerEl.innerHTML = `<div class="answer-card">- <div class="label">Answer (Florence-2-DocVQA)</div>+ <div class="label">Answer (Qwen3.5-4B vision)</div><div class="text">${escapeHtml(res.answer)}</div></div>`;}@@ -187,7 +187,6 @@<div class="meta"><span class="tag">${escapeHtml(r.client)}</span> ${escapeHtml(r.citation)} · ${escapeHtml(r.publisher)}</div><div class="meta">${escapeHtml(r.license)} · <a href="${escapeHtml(r.source_url)}" target="_blank" rel="noreferrer">source PDF</a></div><div class="scores">maxsim=${r.scores.maxsim} rerank=${rerank}</div>- ${r.ocr_snippet ? `<div class="snippet">${escapeHtml(r.ocr_snippet)}</div>` : ""}</div></div>`;}).join("");