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
release: v0.7.1
github-actions[bot]94c9dec13ede
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ba888f303..4dc3c6a9c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1,5 +1,15 @@# Changelog+## v0.7.1++- chore(release): refresh locks and generated sources+- chore(main): release 0.7.1+- fix(server): meter executed GLiNER token window+- test(bench): gate docling OCR on measured English-recogniser floors+- test(server): scope the OCR smoke floor to what it provably catches+- test(server): assert the adapter error channel in the OCR smoke test+- feat(server): serve docling OCR with the English recogniser+## v0.7.0- chore(release): refresh locks and generated sourcesdiff --git a/Cargo.lock b/Cargo.lockindex 0fc4e319f..10ea400d3 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -3583,7 +3583,7 @@ checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"[[package]]name = "sie-audio-prep"-version = "0.7.0"+version = "0.7.1"dependencies = ["audioadapter-buffers","opusic-sys",@@ -3597,7 +3597,7 @@ dependencies = [[[package]]name = "sie-gateway"-version = "0.7.0"+version = "0.7.1"dependencies = ["arc-swap","async-nats",@@ -3655,7 +3655,7 @@ dependencies = [[[package]]name = "sie-server-sidecar"-version = "0.7.0"+version = "0.7.1"dependencies = ["anyhow","async-nats",diff --git a/deploy/helm/sie-cluster/Chart.yaml b/deploy/helm/sie-cluster/Chart.yamlindex 39c084b28..1de881f8b 100644--- a/deploy/helm/sie-cluster/Chart.yaml+++ b/deploy/helm/sie-cluster/Chart.yaml@@ -4,8 +4,8 @@ description: >-SIE (Search Inference Engine) Kubernetes deployment with gateway, GPU workers,and observabilitytype: application-version: 0.7.0 # x-release-please-version-appVersion: v0.7.0 # x-release-please-version+version: 0.7.1 # x-release-please-version+appVersion: v0.7.1 # x-release-please-versionkeywords:- inference- embeddingdiff --git a/integrations/sie_chroma/pyproject.toml b/integrations/sie_chroma/pyproject.tomlindex fdb1f9798..582abfeb6 100644--- a/integrations/sie_chroma/pyproject.toml+++ b/integrations/sie_chroma/pyproject.toml@@ -1,6 +1,6 @@[project]name = "sie-chroma"-version = "0.7.0"+version = "0.7.1"description = "SIE integration for ChromaDB"readme = "README.md"requires-python = ">=3.10"diff --git a/integrations/sie_crewai/pyproject.toml b/integrations/sie_crewai/pyproject.tomlindex 979ed7758..eed5a94b3 100644--- a/integrations/sie_crewai/pyproject.toml+++ b/integrations/sie_crewai/pyproject.toml@@ -1,6 +1,6 @@[project]name = "sie-crewai"-version = "0.7.0"+version = "0.7.1"description = "SIE integration for CrewAI"readme = "README.md"requires-python = ">=3.10"diff --git a/integrations/sie_dspy/pyproject.toml b/integrations/sie_dspy/pyproject.tomlindex b76cfd202..690bf17ac 100644--- a/integrations/sie_dspy/pyproject.toml+++ b/integrations/sie_dspy/pyproject.toml@@ -1,6 +1,6 @@[project]name = "sie-dspy"-version = "0.7.0"+version = "0.7.1"description = "SIE integration for DSPy"readme = "README.md"requires-python = ">=3.10"diff --git a/integrations/sie_haystack/pyproject.toml b/integrations/sie_haystack/pyproject.tomlindex 680e1032a..c3283de37 100644--- a/integrations/sie_haystack/pyproject.toml+++ b/integrations/sie_haystack/pyproject.toml@@ -1,6 +1,6 @@[project]name = "sie-haystack"-version = "0.7.0"+version = "0.7.1"description = "SIE integration for Haystack"readme = "README.md"requires-python = ">=3.10"diff --git a/integrations/sie_lancedb/pyproject.toml b/integrations/sie_lancedb/pyproject.tomlindex 412b9d934..6b4e1d7ed 100644--- a/integrations/sie_lancedb/pyproject.toml+++ b/integrations/sie_lancedb/pyproject.toml@@ -1,6 +1,6 @@[project]name = "sie-lancedb"-version = "0.7.0"+version = "0.7.1"description = "SIE integration for LanceDB"requires-python = ">=3.12"dependencies = [diff --git a/integrations/sie_langchain/pyproject.toml b/integrations/sie_langchain/pyproject.tomlindex 1da786e4f..34a74fdaf 100644--- a/integrations/sie_langchain/pyproject.toml+++ b/integrations/sie_langchain/pyproject.toml@@ -1,6 +1,6 @@[project]name = "sie-langchain"-version = "0.7.0"+version = "0.7.1"description = "SIE integration for LangChain"requires-python = ">=3.10"dependencies = [diff --git a/integrations/sie_llamaindex/pyproject.toml b/integrations/sie_llamaindex/pyproject.tomlindex 54955d21e..8e8ca7e6c 100644--- a/integrations/sie_llamaindex/pyproject.toml+++ b/integrations/sie_llamaindex/pyproject.toml@@ -1,6 +1,6 @@[project]name = "sie-llamaindex"-version = "0.7.0"+version = "0.7.1"description = "SIE integration for LlamaIndex"requires-python = ">=3.10"dependencies = [diff --git a/integrations/sie_qdrant/pyproject.toml b/integrations/sie_qdrant/pyproject.tomlindex 1f4723dc9..703d46d51 100644--- a/integrations/sie_qdrant/pyproject.toml+++ b/integrations/sie_qdrant/pyproject.toml@@ -1,6 +1,6 @@[project]name = "sie-qdrant"-version = "0.7.0"+version = "0.7.1"description = "SIE integration for Qdrant"readme = "README.md"requires-python = ">=3.10"diff --git a/integrations/sie_ts_chroma/package.json b/integrations/sie_ts_chroma/package.jsonindex 37a1a671b..ffb1d4eb3 100644--- a/integrations/sie_ts_chroma/package.json+++ b/integrations/sie_ts_chroma/package.json@@ -1,6 +1,6 @@{"name": "@superlinked/sie-chroma",- "version": "0.7.0",+ "version": "0.7.1","description": "SIE embedding function for ChromaDB","type": "module","main": "./dist/index.cjs",diff --git a/integrations/sie_ts_lancedb/package.json b/integrations/sie_ts_lancedb/package.jsonindex 4f712015c..f75ab02bc 100644--- a/integrations/sie_ts_lancedb/package.json+++ b/integrations/sie_ts_lancedb/package.json@@ -1,6 +1,6 @@{"name": "@superlinked/sie-lancedb",- "version": "0.7.0",+ "version": "0.7.1","description": "SIE embedding function and reranker for LanceDB","type": "module","main": "./dist/index.cjs",diff --git a/integrations/sie_ts_langchain/package.json b/integrations/sie_ts_langchain/package.jsonindex 4dd2d09bb..617f0921d 100644--- a/integrations/sie_ts_langchain/package.json+++ b/integrations/sie_ts_langchain/package.json@@ -1,6 +1,6 @@{"name": "@superlinked/sie-langchain",- "version": "0.7.0",+ "version": "0.7.1","description": "SIE embeddings integration for LangChain.js","type": "module","main": "./dist/index.cjs",diff --git a/integrations/sie_ts_llamaindex/package.json b/integrations/sie_ts_llamaindex/package.jsonindex b01eb6c4c..4a421bfe0 100644--- a/integrations/sie_ts_llamaindex/package.json+++ b/integrations/sie_ts_llamaindex/package.json@@ -1,6 +1,6 @@{"name": "@superlinked/sie-llamaindex",- "version": "0.7.0",+ "version": "0.7.1","description": "SIE embeddings integration for LlamaIndex.TS","type": "module","main": "./dist/index.cjs",diff --git a/integrations/sie_weaviate/pyproject.toml b/integrations/sie_weaviate/pyproject.tomlindex e56c81903..f9e03b4f9 100644--- a/integrations/sie_weaviate/pyproject.toml+++ b/integrations/sie_weaviate/pyproject.toml@@ -1,6 +1,6 @@[project]name = "sie-weaviate"-version = "0.7.0"+version = "0.7.1"description = "SIE integration for Weaviate"readme = "README.md"requires-python = ">=3.10"diff --git a/packages/sie_audio_prep/Cargo.toml b/packages/sie_audio_prep/Cargo.tomlindex b33609411..c5eece835 100644--- a/packages/sie_audio_prep/Cargo.toml+++ b/packages/sie_audio_prep/Cargo.toml@@ -1,6 +1,6 @@[package]name = "sie-audio-prep"-version = "0.7.0"+version = "0.7.1"edition = "2021"license = "Apache-2.0"description = "Bounded, shared audio decoding and resampling for SIE workers."diff --git a/packages/sie_audio_prep/build_wheel.py b/packages/sie_audio_prep/build_wheel.pyindex 45bec2959..b196d47cc 100644--- a/packages/sie_audio_prep/build_wheel.py+++ b/packages/sie_audio_prep/build_wheel.py@@ -16,7 +16,7 @@ import zipfilefrom pathlib import PathMATURIN_VERSION = "1.13.3"-AUDIO_PREP_VERSION = "0.7.0" # x-release-please-version+AUDIO_PREP_VERSION = "0.7.1" # x-release-please-versionAUDIO_WHEEL_COMPATIBILITY = "manylinux_2_28"AUDIO_WHEEL_FILENAME = f"sie_audio_prep-{AUDIO_PREP_VERSION}-cp312-abi3-{AUDIO_WHEEL_COMPATIBILITY}_x86_64.whl"AUDIO_WHEEL_REMOTE = f"/opt/sie/wheels/{AUDIO_WHEEL_FILENAME}"diff --git a/packages/sie_audio_prep/pyproject.toml b/packages/sie_audio_prep/pyproject.tomlindex ab9ef3dda..2929995f0 100644--- a/packages/sie_audio_prep/pyproject.toml+++ b/packages/sie_audio_prep/pyproject.toml@@ -4,7 +4,7 @@ build-backend = "maturin"[project]name = "sie-audio-prep"-version = "0.7.0"+version = "0.7.1"description = "Bounded, shared audio decoding and resampling for SIE workers."requires-python = ">=3.12,<3.13"license = { text = "Apache-2.0" }diff --git a/packages/sie_gateway/Cargo.toml b/packages/sie_gateway/Cargo.tomlindex e5eabe526..2f8431267 100644--- a/packages/sie_gateway/Cargo.toml+++ b/packages/sie_gateway/Cargo.toml@@ -1,6 +1,6 @@[package]name = "sie-gateway"-version = "0.7.0"+version = "0.7.1"edition = "2021"publish = falsediff --git a/packages/sie_gateway/openapi.json b/packages/sie_gateway/openapi.jsonindex 263d484a7..71f715438 100644--- a/packages/sie_gateway/openapi.json+++ b/packages/sie_gateway/openapi.json@@ -3745,7 +3745,7 @@"url": "https://www.apache.org/licenses/LICENSE-2.0.html"},"title": "SIE Gateway",- "version": "0.7.0"+ "version": "0.7.1"},"openapi": "3.1.0","paths": {diff --git a/packages/sie_sdk/pyproject.toml b/packages/sie_sdk/pyproject.tomlindex 83995bdc4..3f523aa2f 100644--- a/packages/sie_sdk/pyproject.toml+++ b/packages/sie_sdk/pyproject.toml@@ -1,6 +1,6 @@[project]name = "sie-sdk"-version = "0.7.0"+version = "0.7.1"description = "Search Inference Engine - Python SDK"requires-python = ">=3.12"license = { text = "Apache-2.0" }diff --git a/packages/sie_server/models/docling.yaml b/packages/sie_server/models/docling.yamlindex e47b0103c..3618d6eee 100644--- a/packages/sie_server/models/docling.yaml+++ b/packages/sie_server/models/docling.yaml@@ -1,6 +1,6 @@sie_id: doclinghf_id: superlinked/docling-artifacts-hf_revision: 6281da328c88328d2b36af759ff19d470b4f7411+hf_revision: 310479be56f3a99a0fea75d930e11eea38bf5ef7inputs:text: falseimage: truediff --git a/packages/sie_server/openapi.json b/packages/sie_server/openapi.jsonindex 208aec5ef..fa554acf6 100644--- a/packages/sie_server/openapi.json+++ b/packages/sie_server/openapi.json@@ -3,7 +3,7 @@"info": {"title": "SIE Server","description": "Search Inference Engine - GPU inference server for search workloads",- "version": "0.7.0"+ "version": "0.7.1"},"paths": {"/healthz": {diff --git a/packages/sie_server/pyproject.toml b/packages/sie_server/pyproject.tomlindex 033b077bc..c4752b577 100644--- a/packages/sie_server/pyproject.toml+++ b/packages/sie_server/pyproject.toml@@ -1,6 +1,6 @@[project]name = "sie-server"-version = "0.7.0"+version = "0.7.1"description = "Search Inference Engine - GPU inference server for search workloads"requires-python = ">=3.12,<3.13"license = { text = "Apache-2.0" }@@ -52,8 +52,9 @@ dependencies = [# PINNED TO THE ARTIFACT REVISION, NOT FLOATED (#2872). Docling resolves# its RapidOCR det/cls/rec files by a version-specific path table, so the# library version and the immutable artifact revision pinned in- # models/docling.yaml (superlinked/docling-artifacts @ 6281da32, the- # "Docling 2.99 inference artifacts" commit) are ONE compatibility pair.+ # models/docling.yaml (superlinked/docling-artifacts @ 310479be, which+ # republishes the Docling 2.99 inference artifacts with BOTH the English+ # and Chinese RapidOCR sets, #2919) are ONE compatibility pair.# A floating '>=2,<3' let the Linux resolution drift to 2.116, whose table# asks for PP-OCRv6 while the committed artifacts ship PP-OCRv4 only —# docling then failed to load on BOTH profiles. Moving this range requiresdiff --git a/packages/sie_server/src/sie_server/adapters/docling/adapter.py b/packages/sie_server/src/sie_server/adapters/docling/adapter.pyindex 7ec3162df..7a10d808e 100644--- a/packages/sie_server/src/sie_server/adapters/docling/adapter.py+++ b/packages/sie_server/src/sie_server/adapters/docling/adapter.py@@ -390,15 +390,25 @@ class DoclingAdapter(BaseAdapter):accelerator_options = self._build_accelerator_options()from docling.datamodel.base_models import InputFormat # ty: ignore[unresolved-import]- from docling.datamodel.pipeline_options import PdfPipelineOptions # ty: ignore[unresolved-import]+ from docling.datamodel.pipeline_options import ( # ty: ignore[unresolved-import]+ PdfPipelineOptions,+ RapidOcrOptions,+ )from docling.document_converter import ImageFormatOption, PdfFormatOption # ty: ignore[unresolved-import]# Pass do_ocr explicitly on both paths. Docling's PdfPipelineOptions defaults# do_ocr=True, so an unset default would silently OCR every PDF and make the# `ocr` profile a no-op vs. the default profile.+ #+ # The OCR language is pinned to English (#2919, #2441 Decision 3): with no+ # ocr_options, RapidOcrOptions' `["chinese"]` default applied and English+ # pages came back word-joined ("Documentreference"). The pinned artifact+ # revision ships BOTH language sets, so this stays a one-line flip if the+ # served traffic mix ever argues for CJK.pdf_kwargs: dict[str, Any] = {"do_ocr": ocr_enabled,"document_timeout": self._document_timeout_s,+ "ocr_options": RapidOcrOptions(lang=["en"]),}artifacts_path = self._artifacts_path or self._package_artifact_rootif artifacts_path is not None:diff --git a/packages/sie_server/src/sie_server/adapters/gliner/__init__.py b/packages/sie_server/src/sie_server/adapters/gliner/__init__.pyindex 113790b15..9e7961a73 100644--- a/packages/sie_server/src/sie_server/adapters/gliner/__init__.py+++ b/packages/sie_server/src/sie_server/adapters/gliner/__init__.py@@ -28,6 +28,8 @@ from sie_server.types.responses import Entity# Error messages_ERR_REQUIRES_LABELS = "GLiNER requires labels parameter for extraction"+_ERR_REQUIRES_NON_BLANK_TEXT = "GLiNER requires non-blank text for extraction"+_ERR_PROMPT_EXHAUSTS_DOCUMENT = "GLiNER label prompt leaves no document tokens for extraction"class GLiNERAdapter(BaseAdapter):@@ -171,6 +173,13 @@ class GLiNERAdapter(BaseAdapter):# Extract texts from all itemstexts = [self._extract_text(item) for item in items]+ if any(not text.strip() for text in texts):+ raise ValueError(_ERR_REQUIRES_NON_BLANK_TEXT)++ # Meter the exact post-word-truncation document window before GPU work.+ # Besides producing the authoritative terminal counts, this rejects a+ # finite-tokenizer prompt that leaves no represented document subword.+ input_token_counts = self._doc_input_token_counts(texts, labels)# Get options with fallback to model defaultsopts = options or {}@@ -210,38 +219,82 @@ class GLiNERAdapter(BaseAdapter):all_entities.append(entity_results)- return ExtractOutput(entities=all_entities, input_token_counts=self._doc_input_token_counts(texts))+ return ExtractOutput(entities=all_entities, input_token_counts=input_token_counts)++ def _doc_input_token_counts(self, texts: list[str], labels: list[str]) -> list[int] | None:+ """Count the document subwords represented by GLiNER's real processor.- def _doc_input_token_counts(self, texts: list[str]) -> list[int] | None:- """Real per-document input-token counts for the unit meter (§7.3).+ Classic GLiNER first splits and truncates each document in WORDS, then+ prepends the label prompt and transformer-tokenizes that retained word+ window. Tokenizing the original string separately therefore counts+ discarded tail text and is not an authoritative execution meter.- GLiNER's ``inference`` owns tokenization opaquely, so we recover the- billable count by running each document through the model's own- transformer tokenizer (``data_processor.transformer_tokenizer``) — the- same subword vocabulary the forward pass uses. We count the DOCUMENT- tokens only; the entity-type label prompt is request schema (re-used- across docs, not billed content), matching "$ per 1M input tokens" over- the document (§7.1). Best-effort: any tokenizer-shape quirk returns- ``None`` so the meter falls back to its reserve estimate rather than- billing an approximation as a count.+ Delegate splitting, processor-specific truncation, label mapping, and+ prompt construction to the pinned GLiNER processor. ``word_ids`` then+ identifies every represented document subword while excluding prompt+ words. Attention masking excludes padding; tokenizer specials remain+ billable, matching the existing document-token contract. Batches match+ GLiNER inference's default batch size so a finite tokenizer cap is+ observed identically."""processor = getattr(self._model, "data_processor", None)- tokenizer = getattr(processor, "transformer_tokenizer", None)- if tokenizer is None:+ prepare_inputs = getattr(self._model, "prepare_inputs", None)+ prepare_base_input = getattr(self._model, "prepare_base_input", None)+ if processor is None or prepare_inputs is None or prepare_base_input is None:return None- # Cap truncation at the tokenizer's own ``model_max_length`` when it- # declares a plausible one; HF sets an ``int(1e30)`` sentinel for- # uncapped tokenizers, which we treat as "no cap" (documents are short- # relative to that and counting the full length is still authoritative).- raw_max = getattr(tokenizer, "model_max_length", None)- max_length = raw_max if isinstance(raw_max, int) and 0 < raw_max < 1_000_000 else None+try:- encoded = tokenizer(texts, truncation=max_length is not None, max_length=max_length)- counts = [len(ids) for ids in encoded["input_ids"]]+ split_texts, _, _ = prepare_inputs(texts)+ raw_items = prepare_base_input(split_texts)+ counts: list[int] = []+ has_document_subwords: list[bool] = []+ for start in range(0, len(raw_items), 8):+ raw_batch = processor.collate_raw_batch(+ raw_items[start : start + 8],+ entity_types=labels,+ )+ retained_words = raw_batch["tokens"]+ entity_mappings = raw_batch["classes_to_id"]+ encoded = processor.tokenize_inputs(retained_words, entity_mappings)+ for batch_index in range(len(retained_words)):+ word_ids = encoded.word_ids(batch_index)+ attention_mask = encoded["attention_mask"][batch_index].tolist()+ words_mask = encoded["words_mask"][batch_index].tolist()+ if len(word_ids) != len(attention_mask) or len(word_ids) != len(words_mask):+ return None+ first_document_index = next(+ (index for index, word_mask in enumerate(words_mask) if word_mask > 0),+ None,+ )+ first_document_word_id = (+ word_ids[first_document_index] if first_document_index is not None else None+ )+ represented_document = [+ bool(+ attended+ and first_document_word_id is not None+ and word_id is not None+ and word_id >= first_document_word_id+ )+ for attended, word_id in zip(attention_mask, word_ids)+ ]+ has_document_subwords.append(any(represented_document))+ counts.append(+ sum(+ bool(attended)+ and (+ word_id is None+ or (first_document_word_id is not None and word_id >= first_document_word_id)+ )+ for attended, word_id in zip(attention_mask, word_ids)+ )+ )except Exception: # noqa: BLE001 — metering must never fail an extractionreturn None- if len(counts) != len(texts):+ if len(counts) != len(texts) or len(has_document_subwords) != len(texts):return None+ if not all(has_document_subwords):+ raise ValueError(_ERR_PROMPT_EXHAUSTS_DOCUMENT)return countsdef _merge_entities(self, entities: list[Entity], text: str) -> list[Entity]:diff --git a/packages/sie_server/tests/adapters/test_docling.py b/packages/sie_server/tests/adapters/test_docling.pyindex f07e21efd..f3e600168 100644--- a/packages/sie_server/tests/adapters/test_docling.py+++ b/packages/sie_server/tests/adapters/test_docling.py@@ -562,7 +562,13 @@ class TestDoclingMakeConverter:):adapter._make_converter(ocr_enabled=False)- mock_opts.assert_called_once_with(do_ocr=False, document_timeout=90.0)+ mock_opts.assert_called_once()+ kwargs = mock_opts.call_args.kwargs+ assert kwargs["do_ocr"] is False+ assert kwargs["document_timeout"] == 90.0+ # #2919: the recogniser language is pinned, never docling's ["chinese"]+ # default — word-joined English output was a defect on a billed profile.+ assert kwargs["ocr_options"].lang == ["en"]mock_fmt_opt.assert_called_once()mock_cls.assert_called_once()assert "format_options" in mock_cls.call_args.kwargs@@ -578,7 +584,13 @@ class TestDoclingMakeConverter:):adapter._make_converter(ocr_enabled=True)- mock_opts.assert_called_once_with(do_ocr=True, document_timeout=90.0)+ mock_opts.assert_called_once()+ kwargs = mock_opts.call_args.kwargs+ assert kwargs["do_ocr"] is True+ assert kwargs["document_timeout"] == 90.0+ # #2919: the OCR profile serves the English RapidOCR set from the pinned+ # artifact revision; both language sets ship, so this stays a data flip.+ assert kwargs["ocr_options"].lang == ["en"]mock_fmt_opt.assert_called_once()mock_cls.assert_called_once()assert "format_options" in mock_cls.call_args.kwargsdiff --git a/packages/sie_server/tests/adapters/test_docling_smoke.py b/packages/sie_server/tests/adapters/test_docling_smoke.pyindex 8abfec06e..01506d2fc 100644--- a/packages/sie_server/tests/adapters/test_docling_smoke.py+++ b/packages/sie_server/tests/adapters/test_docling_smoke.py@@ -2,6 +2,7 @@ from __future__ import annotationsimport iofrom collections.abc import Callable+from pathlib import Pathimport pytest@@ -63,3 +64,91 @@ def test_extract_real_document(loaded_adapter: DoclingAdapter, format_hint: str,assert "error" not in item, f"adapter reported error: {item.get('error')}"assert "Smoke test heading" in item["text"] or "Smoke test heading" in item["markdown"]assert "document" in item+++_PROSE = (+ "Alice was beginning to get very tired of sitting by her sister "+ "on the bank and of having nothing to do once or twice she had "+ "peeped into the book her sister was reading"+)+++def _make_prose_image_bytes() -> bytes:+ pil = pytest.importorskip("PIL")+ from PIL import Image, ImageDraw, ImageFont # ty: ignore[unresolved-import]++ _ = pil+ image = Image.new("RGB", (1400, 400), "white")+ draw = ImageDraw.Draw(image)+ font = ImageFont.load_default(size=40)+ words = _PROSE.split()+ for row in range(0, len(words), 8):+ draw.text((40, 40 + (row // 8) * 70), " ".join(words[row : row + 8]), fill="black", font=font)+ buf = io.BytesIO()+ image.save(buf, format="PNG")+ return buf.getvalue()+++def test_served_ocr_output_keeps_word_boundaries() -> None:+ """#2919: end-to-end sanity of the ARTIFACT-BACKED served OCR path.++ This exercises the real pinned artifact revision end to end: it proves the+ revision resolves a usable RapidOCR set on the served path and returns+ segmented text, which a bare adapter on docling's own cache cannot show.++ SCOPE — measured, not assumed. This floor does NOT discriminate the+ recogniser language. Mutating the adapter to ``lang=["ch"]`` provably+ reaches a different recogniser (``ch_PP-OCRv4_rec_mobile.onnx`` instead of+ ``en_PP-OCRv4_rec_mobile.onnx``) yet yields BYTE-IDENTICAL text here+ (density 0.2741 both ways): the Chinese set reads clean, large, synthetic+ renders of Latin script perfectly. Degrading the fixture does not rescue+ the separation — across six render variants the two languages are+ non-monotonic, and on a gray/noisy variant the Chinese set scored HIGHER+ (0.2296 vs 0.1290). Threshold-fitting a synthetic image would buy a flaky+ test, not a guard.++ What actually holds the language pin is+ ``test_docling.py::TestDoclingMakeConverter`` (both cases assert+ ``ocr_options.lang == ["en"]``; flipping the adapter fails them in the+ default suite). What catches DEGRADED-but-segmented output on real pages is+ the quality floor now committed at+ ``benchmarks/ocr__Teklia__IAM-line/docling/quality/target.ocr.extract.json``+ (#2919): over 2,915 real pages the ocr profile scores mean_similarity+ 0.3878 with the English recogniser and 0.3743 with the Chinese one, so a+ ``lang=["ch"]`` flip lands 3.49% under the floor and reds the gate. The+ same holds on olmOCR-bench (0.3458 vs 0.3347, -3.22%).+ ``test_benchmark_repository_contracts.py`` replays both and fails if either+ floor stops rejecting the defect.++ So: keep this as a served-path smoke over the pinned revision. Do not read+ it as evidence that the language is correct.+ """+ yaml = pytest.importorskip("yaml")+ model_yaml = Path(__file__).resolve().parents[2] / "models" / "docling.yaml"+ pinned = yaml.safe_load(model_yaml.read_text())++ adapter = DoclingAdapter(+ model_name_or_path=pinned["hf_id"],+ revision=pinned["hf_revision"],+ )+ adapter.load("cpu")+ out = adapter.extract(+ [Item(images=[{"data": _make_prose_image_bytes(), "format": "png"}])],+ options={"ocr": True},+ )++ assert out.data is not None+ assert out.errors is None, f"adapter reported errors: {out.errors}"+ item = out.data[0]+ text = item["text"]+ alpha = sum(1 for ch in text if ch.isalpha())+ whitespace = sum(1 for ch in text if ch.isspace())+ assert alpha > 40, f"OCR recognised too little text to judge: {text!r}"+ density = whitespace / alpha+ assert density > 0.10, (+ f"served OCR output is word-joined (whitespace/alpha = {density:.3f}); "+ f"the pinned artifact revision resolves no recogniser able to segment "+ f"this page at all. This is a catastrophic-failure floor, not a "+ f"language check — see the docstring: {text!r}"+ )diff --git a/packages/sie_server/tests/adapters/test_gliner_metering.py b/packages/sie_server/tests/adapters/test_gliner_metering.pynew file mode 100644index 000000000..397844afd--- /dev/null+++ b/packages/sie_server/tests/adapters/test_gliner_metering.py@@ -0,0 +1,205 @@+from importlib.metadata import version+from typing import Any+from unittest.mock import MagicMock++import pytest+import torch+from sie_server.adapters.gliner import GLiNERAdapter+from sie_server.types.inputs import Item+++class FakeEncoding:+ def __init__(+ self,+ word_ids: list[list[int | None]],+ words_masks: list[list[int]],+ attention_masks: list[list[int]],+ ) -> None:+ self._word_ids = word_ids+ self._attention_mask = [torch.tensor(mask, dtype=torch.long) for mask in attention_masks]+ self._words_mask = [torch.tensor(mask, dtype=torch.long) for mask in words_masks]++ def word_ids(self, batch_index: int) -> list[int | None]:+ return self._word_ids[batch_index]++ def __getitem__(self, key: str) -> list[torch.Tensor]:+ if key == "attention_mask":+ return self._attention_mask+ if key == "words_mask":+ return self._words_mask+ raise KeyError(key)+++class FakeProcessor:+ def __init__(self, *, tokenizer_word_limit: int | None = None) -> None:+ self.tokenizer_word_limit = tokenizer_word_limit+ self.raw_batches: list[list[dict[str, Any]]] = []++ def collate_raw_batch(+ self,+ batch: list[dict[str, Any]],+ *,+ entity_types: list[str],+ ) -> dict[str, Any]:+ self.raw_batches.append(batch)+ labels = list(dict.fromkeys(entity_types))+ return {+ "tokens": [item["tokenized_text"][:3] for item in batch],+ "classes_to_id": {label: index for index, label in enumerate(labels, start=1)},+ }++ def prepare_inputs(+ self,+ texts: list[list[str]],+ entity_mappings: dict[str, int],+ ) -> tuple[list[list[str]], list[int]]:+ prompt_length = len(entity_mappings) * 2 + 1+ return texts, [prompt_length] * len(texts)++ def tokenize_inputs(+ self,+ texts: list[list[str]],+ entity_mappings: dict[str, int],+ ) -> FakeEncoding:+ prompt_length = len(entity_mappings) * 2 + 1+ batches: list[list[int | None]] = []+ words_masks: list[list[int]] = []+ for words in texts:+ ids: list[int | None] = [None]+ word_mask = [0]+ ids.extend(range(prompt_length))+ word_mask.extend([0] * prompt_length)+ for word_index, word in enumerate(words, start=prompt_length):+ ids.extend([word_index] * len(word))+ word_mask.extend([word_index - prompt_length + 1] + [0] * (len(word) - 1))+ ids.append(None)+ word_mask.append(0)+ if self.tokenizer_word_limit is not None:+ ids = ids[: self.tokenizer_word_limit]+ word_mask = word_mask[: self.tokenizer_word_limit]+ batches.append(ids)+ words_masks.append(word_mask)+ max_length = max(map(len, batches))+ attention_masks = [[1] * len(ids) + [0] * (max_length - len(ids)) for ids in batches]+ for ids, word_mask in zip(batches, words_masks):+ padding = max_length - len(ids)+ ids.extend([None] * padding)+ word_mask.extend([0] * padding)+ return FakeEncoding(batches, words_masks, attention_masks)+++def adapter_with_processor(processor: FakeProcessor) -> GLiNERAdapter:+ adapter = GLiNERAdapter("test-model")+ model = MagicMock()+ model.data_processor = processor+ model.prepare_inputs.side_effect = lambda texts: (+ [text.split() for text in texts],+ [[] for _ in texts],+ [[] for _ in texts],+ )+ model.prepare_base_input.side_effect = lambda texts: [{"tokenized_text": text, "ner": None} for text in texts]+ model.inference.return_value = [[]]+ adapter._model = model+ adapter._device = "cpu"+ return adapter+++def test_meter_counts_only_processor_retained_document_subwords() -> None:+ adapter = adapter_with_processor(FakeProcessor())++ counts = adapter._doc_input_token_counts(+ ["a bb ccc discarded tail"],+ ["party", "date", "party"],+ )+ deduplicated_counts = adapter._doc_input_token_counts(+ ["a bb ccc discarded tail"],+ ["party", "date"],+ )++ assert counts == deduplicated_counts == [8]+++def test_meter_batches_like_inference_and_preserves_alignment() -> None:+ processor = FakeProcessor()+ adapter = adapter_with_processor(processor)+ texts: list[str] = [f"{'x' * (index + 1)} tail" for index in range(10)]++ counts = adapter._doc_input_token_counts(texts, ["entity"])++ assert counts == [index + 1 + 6 for index in range(10)]+ assert [len(batch) for batch in processor.raw_batches] == [8, 2]+++def test_extract_rejects_blank_document_before_inference() -> None:+ adapter = adapter_with_processor(FakeProcessor())++ with pytest.raises(ValueError, match="non-blank"):+ adapter.extract([Item(text=" \n\t")], labels=["entity"])++ adapter._model.inference.assert_not_called()+++def test_extract_rejects_prompt_that_leaves_no_document_subword() -> None:+ adapter = adapter_with_processor(FakeProcessor(tokenizer_word_limit=4))++ with pytest.raises(ValueError, match="leaves no document tokens"):+ adapter.extract([Item(text="represented")], labels=["entity"])++ adapter._model.inference.assert_not_called()+++def test_meter_observes_finite_tokenizer_tail_truncation() -> None:+ adapter = adapter_with_processor(FakeProcessor(tokenizer_word_limit=6))++ counts = adapter._doc_input_token_counts(["represented"], ["entity"])++ # The finite tokenizer represents only two document subwords after CLS and+ # the three-word prompt. The truncated SEP is not counted.+ assert counts == [3]+++def test_appending_words_beyond_processor_window_does_not_change_meter() -> None:+ adapter = adapter_with_processor(FakeProcessor())++ prefix = "a bb ccc"+ counts = adapter._doc_input_token_counts(+ [prefix, f"{prefix} {'suffix ' * 500}"],+ ["entity"],+ )++ assert counts == [8, 8]+++ ("model_id", "revision"),+ [+ ("urchade/gliner_multi-v2.1", "443d26d654e0324125a96bebd8e796c14ff2efe6"),+ ("numind/NuNER_Zero", "c90187673f464518dca09f41689184ed6976242c"),+ ],+)+def test_pinned_classic_processors_meter_only_the_executed_word_window(+ model_id: str,+ revision: str,+) -> None:+ if not torch.cuda.is_available():+ pytest.skip("real classic GLiNER metering regression requires a GPU")+ assert version("gliner") == "0.2.26"++ adapter = GLiNERAdapter(model_id, revision=revision)+ adapter.load("cuda:0")+ labels = ["party", "date", "term", "law", "money", "obligation", "notice"]+ prefix = " ".join(f"contractword{index}" for index in range(384))+ suffix = " ".join(f"discarded{index}" for index in range(120))+ try:+ prefix_count = adapter._doc_input_token_counts([prefix], labels)+ extended_count = adapter._doc_input_token_counts([f"{prefix} {suffix}"], labels)+ output = adapter.extract([Item(text=f"{prefix} {suffix}")], labels=labels)+ finally:+ adapter.unload()++ assert prefix_count is not None+ assert extended_count == prefix_count+ assert output.input_token_counts == prefix_count+ assert prefix_count[0] > 384diff --git a/packages/sie_server_sidecar/Cargo.toml b/packages/sie_server_sidecar/Cargo.tomlindex 83d3e8a8e..0c0844868 100644--- a/packages/sie_server_sidecar/Cargo.toml+++ b/packages/sie_server_sidecar/Cargo.toml@@ -1,6 +1,6 @@[package]name = "sie-server-sidecar"-version = "0.7.0"+version = "0.7.1"edition = "2021"publish = falsedescription = "SIE worker sidecar: NATS JetStream consumer, scheduler, IPC client, and GPU-independent prep for sie-server pods."diff --git a/packages/sie_ts_sdk/package.json b/packages/sie_ts_sdk/package.jsonindex ce5fb8b36..69de1fab9 100644--- a/packages/sie_ts_sdk/package.json+++ b/packages/sie_ts_sdk/package.json@@ -1,6 +1,6 @@{"name": "@superlinked/sie-sdk",- "version": "0.7.0",+ "version": "0.7.1","description": "Official TypeScript SDK for SIE (Search Inference Engine)","type": "module","main": "./dist/index.cjs",diff --git a/packages/sie_ts_sdk/src/version.ts b/packages/sie_ts_sdk/src/version.tsindex 73ffb60ca..6bc7e555c 100644--- a/packages/sie_ts_sdk/src/version.ts+++ b/packages/sie_ts_sdk/src/version.ts@@ -1 +1 @@-export const SDK_VERSION = "0.7.0"; // x-release-please-version+export const SDK_VERSION = "0.7.1"; // x-release-please-versiondiff --git a/uv.lock b/uv.lockindex 3653ed688..8050fe1ea 100644--- a/uv.lock+++ b/uv.lock@@ -4388,12 +4388,12 @@ dev = [[[package]]name = "sie-audio-prep"-version = "0.7.0"+version = "0.7.1"source = { editable = "packages/sie_audio_prep" }[[package]]name = "sie-chroma"-version = "0.7.0"+version = "0.7.1"source = { editable = "integrations/sie_chroma" }dependencies = [{ name = "chromadb" },@@ -4473,7 +4473,7 @@ dev = [[[package]]name = "sie-crewai"-version = "0.7.0"+version = "0.7.1"source = { editable = "integrations/sie_crewai" }dependencies = [{ name = "crewai" },@@ -4498,7 +4498,7 @@ requires-dist = [[[package]]name = "sie-dspy"-version = "0.7.0"+version = "0.7.1"source = { editable = "integrations/sie_dspy" }dependencies = [{ name = "dspy" },@@ -4523,7 +4523,7 @@ requires-dist = [[[package]]name = "sie-haystack"-version = "0.7.0"+version = "0.7.1"source = { editable = "integrations/sie_haystack" }dependencies = [{ name = "haystack-ai" },@@ -4550,7 +4550,7 @@ requires-dist = [[[package]]name = "sie-lancedb"-version = "0.7.0"+version = "0.7.1"source = { editable = "integrations/sie_lancedb" }dependencies = [{ name = "lancedb" },@@ -4577,7 +4577,7 @@ requires-dist = [[[package]]name = "sie-langchain"-version = "0.7.0"+version = "0.7.1"source = { editable = "integrations/sie_langchain" }dependencies = [{ name = "langchain-core" },@@ -4604,7 +4604,7 @@ requires-dist = [[[package]]name = "sie-llamaindex"-version = "0.7.0"+version = "0.7.1"source = { editable = "integrations/sie_llamaindex" }dependencies = [{ name = "llama-index-core" },@@ -4670,7 +4670,7 @@ dev = [[[package]]name = "sie-qdrant"-version = "0.7.0"+version = "0.7.1"source = { editable = "integrations/sie_qdrant" }dependencies = [{ name = "qdrant-client" },@@ -4693,7 +4693,7 @@ requires-dist = [[[package]]name = "sie-sdk"-version = "0.7.0"+version = "0.7.1"source = { editable = "packages/sie_sdk" }dependencies = [{ name = "aiohttp" },@@ -4746,7 +4746,7 @@ requires-dist = [[[package]]name = "sie-server"-version = "0.7.0"+version = "0.7.1"source = { editable = "packages/sie_server" }dependencies = [{ name = "blake3" },@@ -4875,7 +4875,7 @@ dev = [][[package]]name = "sie-weaviate"-version = "0.7.0"+version = "0.7.1"source = { editable = "integrations/sie_weaviate" }dependencies = [{ name = "sie-sdk" },