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
feat(server): add Qwen3Guard-Gen-4B and Qwen3Guard-Gen-0.6B guard models (#448)
svonava471189c55c95
diff --git a/README.md b/README.mdindex 95cf77b2e..09c08ea8f 100644--- a/README.md+++ b/README.md@@ -48,7 +48,7 @@ One SIE cluster runs the inference behind a whole agent. Each task is a handful| **Structured output** | Schema-valid JSON, extracted or generated. | [`gliner2`](packages/sie_server/models/fastino__gliner2-large-v1.yaml), [`gliner-relex`](packages/sie_server/models/knowledgator__gliner-relex-large-v1.0.yaml), [`gliformer`](packages/sie_server/models/knowledgator__gliformer-large-v1.yaml), [`nuner-zero`](packages/sie_server/models/numind__NuNER_Zero.yaml), [`qwen3.8-27b`](packages/sie_server/models/Qwen__Qwen3.8-27B-FP8.yaml), [`qwen3.6-27b`](packages/sie_server/models/Qwen__Qwen3.6-27B.yaml) || **Decide** | Choice, yes/no, and score answers with probabilities to typed questions about a text or JSON state. | [`laya`](packages/sie_server/models/convaiinnovations__laya.yaml), [`laya-multilingual`](packages/sie_server/models/convaiinnovations__laya-multilingual.yaml), [`laya-typed-decisions`](packages/sie_server/models/convaiinnovations__laya-typed-decisions.yaml), [`gliner2.5-decide`](packages/sie_server/models/fastino__GLiNER2.5-Decide.yaml), [`gliner2.5-multi-decide`](packages/sie_server/models/fastino__GLiNER2.5-multi-Decide.yaml), [`gliner2.5-decide-1b`](packages/sie_server/models/fastino__GLiNER2.5-Decide-1B.yaml) || **Classify** | Zero-shot labels, with several label groups answered in one call. The instruct models also follow a task instruction and few-shot examples. | [`gliclass-large-v3`](packages/sie_server/models/knowledgator__gliclass-large-v3.0.yaml), [`gliclass-instruct-large`](packages/sie_server/models/knowledgator__gliclass-instruct-large-v1.0.yaml), [`gliclass-multilang-mini`](packages/sie_server/models/knowledgator__gliclass-multilang-mini.yaml) |-| **Guard content** | A safety verdict: Yes/No with the threshold set in the model config, or safe/unsafe and policy-label scores with the threshold chosen per request. | [`granite-guardian-2b`](packages/sie_server/models/ibm-granite__granite-guardian-3.0-2b.yaml), [`opir-multitask-large`](packages/sie_server/models/knowledgator__opir-multitask-large-v1.0.yaml), [`opir-edge`](packages/sie_server/models/knowledgator__opir-edge-v1.0.yaml) |+| **Guard content** | A safety verdict: Safe, Unsafe, or Controversial with the unsafe categories; Yes/No with the threshold set in the model config; or safe/unsafe and policy-label scores with the threshold chosen per request. | [`qwen3guard-gen-4b`](packages/sie_server/models/Qwen__Qwen3Guard-Gen-4B.yaml), [`granite-guardian-2b`](packages/sie_server/models/ibm-granite__granite-guardian-3.0-2b.yaml), [`opir-multitask-large`](packages/sie_server/models/knowledgator__opir-multitask-large-v1.0.yaml), [`opir-edge`](packages/sie_server/models/knowledgator__opir-edge-v1.0.yaml) || **Run the agent loop** | Plan steps and call tools with an open LLM, streaming included. | [`qwen3.8-27b`](packages/sie_server/models/Qwen__Qwen3.8-27B-FP8.yaml), [`qwen3.6-27b`](packages/sie_server/models/Qwen__Qwen3.6-27B.yaml) || **Translate** | Text between 400+ languages. | [`madlad400-3b-mt`](packages/sie_server/models/google__madlad400-3b-mt.yaml) || **See images** | Caption, detect objects, and answer questions about images. | [`florence-2`](packages/sie_server/models/microsoft__Florence-2-large.yaml), [`owlv2`](packages/sie_server/models/google__owlv2-base-patch16-ensemble.yaml), [`grounding-dino`](packages/sie_server/models/IDEA-Research__grounding-dino-base.yaml) |diff --git a/packages/sie_server/models/Qwen__Qwen3Guard-Gen-0.6B.yaml b/packages/sie_server/models/Qwen__Qwen3Guard-Gen-0.6B.yamlnew file mode 100644index 000000000..845035d19--- /dev/null+++ b/packages/sie_server/models/Qwen__Qwen3Guard-Gen-0.6B.yaml@@ -0,0 +1,91 @@+sie_id: Qwen/Qwen3Guard-Gen-0.6B+hf_id: Qwen/Qwen3Guard-Gen-0.6B+hf_revision: fada3b2f655b89601929198343c94cd2f64d93cc+inputs:+ text: true+ image: false+ audio: false+ video: false+tasks:+ # CHECK POLICY job: a generative guard model (Apache-2.0, ungated). Send the+ # text to check as the only user message through chat completions; the+ # model's own chat template wraps it in the moderation prompt (policy, nine+ # unsafe categories) and the model answers in two lines:+ #+ # Safety: Unsafe+ # Categories: Violent+ #+ # The first line is one of Safe / Unsafe / Controversial; the second lists+ # the unsafe categories, or "None". A trailing assistant turn switches the+ # template to response moderation, which adds a "Refusal: Yes|No" line.+ # /v1/generate passes raw input without the template; to use that route,+ # render the template client-side first.+ #+ # Served as plain greedy generation: there is no ``guard`` loadtime block,+ # because the adapter's logprob threshold reads a one-token Yes/No verdict+ # (Granite Guardian's format) and does not apply to this output.+ generate:+ # The model's native window. Long inputs are checked whole, not+ # truncated; the template itself adds about 330 tokens.+ context_length: 32768+ # The verdict is about ten tokens. The cap only bounds a runaway answer.+ max_output_tokens: 128+ # No chat_template_kwargs: the template takes none and already emits an+ # empty <think></think> block, so the model never reasons first.+ capabilities:+ grammar: []+ streaming: true+ tools: false+ # Content-moderation / policy-check job. Informational (not+ # request-gated); the model="guard" alias is unchanged.+ guard: true+max_sequence_length: 32768+# KV-cache memory math (Qwen3ForCausalLM 0.6B, bf16), same geometry as+# Qwen/Qwen3-0.6B:+# layers=28, kv_heads=8, head_dim=128, bytes_per_elem=2+# kv_bytes_per_token = 2 x 28 x 8 x 128 x 2 = 114,688 B (112 KB)+# About 1.5 GB of weights leaves (24 x 0.85 - 1.5) GB / 112 KB = 177,000+# tokens of KV on an L4 and about 300,000 on an A100-40GB. The budgets below+# admit two (L4) or four (A100) full-context checks at once.+profiles:+ default:+ # max_batch_tokens is a generic engine knob; generation does not batch at+ # the SIE layer (SGLang batches internally) but the validator requires it.+ max_batch_tokens: 16384+ compute_precision: bfloat16+ adapter_path: sie_server.adapters.sglang.generation:SGLangGenerationAdapter+ # Measured on an L4 with SGLang 0.5.10.post1: p50 about 100 ms per check+ # (ToxicChat prompts, one request in flight).+ # L4 baseline: two full-context checks, or many short ones, in flight.+ kv_budget_tokens: 65536+ adapter_options:+ loadtime:+ mem_fraction_static: 0.85+ served_model_name: Qwen/Qwen3Guard-Gen-0.6B+ runtime:+ first_chunk_timeout_s: 30+ inter_chunk_timeout_s: 10+ overall_timeout_s: 300+ # Greedy: a guard verdict must be deterministic.+ default_sampling:+ temperature: 0.0+ stop_tokens:+ - "<|im_end|>"+ a100-40gb:+ max_batch_tokens: 32768+ compute_precision: bfloat16+ adapter_path: sie_server.adapters.sglang.generation:SGLangGenerationAdapter+ # Four full-context admissions.+ kv_budget_tokens: 131072+ adapter_options:+ loadtime:+ mem_fraction_static: 0.85+ served_model_name: Qwen/Qwen3Guard-Gen-0.6B+ runtime:+ first_chunk_timeout_s: 30+ inter_chunk_timeout_s: 10+ overall_timeout_s: 300+ default_sampling:+ temperature: 0.0+ stop_tokens:+ - "<|im_end|>"diff --git a/packages/sie_server/models/Qwen__Qwen3Guard-Gen-4B.yaml b/packages/sie_server/models/Qwen__Qwen3Guard-Gen-4B.yamlnew file mode 100644index 000000000..9b2de3a18--- /dev/null+++ b/packages/sie_server/models/Qwen__Qwen3Guard-Gen-4B.yaml@@ -0,0 +1,91 @@+sie_id: Qwen/Qwen3Guard-Gen-4B+hf_id: Qwen/Qwen3Guard-Gen-4B+hf_revision: 6ec42827da0c1ff11e7a49dc269d2e810d27e108+inputs:+ text: true+ image: false+ audio: false+ video: false+tasks:+ # CHECK POLICY job: a generative guard model (Apache-2.0, ungated). Send the+ # text to check as the only user message through chat completions; the+ # model's own chat template wraps it in the moderation prompt (policy, nine+ # unsafe categories) and the model answers in two lines:+ #+ # Safety: Unsafe+ # Categories: Violent+ #+ # The first line is one of Safe / Unsafe / Controversial; the second lists+ # the unsafe categories, or "None". A trailing assistant turn switches the+ # template to response moderation, which adds a "Refusal: Yes|No" line.+ # /v1/generate passes raw input without the template; to use that route,+ # render the template client-side first.+ #+ # Served as plain greedy generation: there is no ``guard`` loadtime block,+ # because the adapter's logprob threshold reads a one-token Yes/No verdict+ # (Granite Guardian's format) and does not apply to this output.+ generate:+ # The model's native window. Long inputs are checked whole, not+ # truncated; the template itself adds about 330 tokens.+ context_length: 32768+ # The verdict is about ten tokens. The cap only bounds a runaway answer.+ max_output_tokens: 128+ # No chat_template_kwargs: the template takes none and already emits an+ # empty <think></think> block, so the model never reasons first.+ capabilities:+ grammar: []+ streaming: true+ tools: false+ # Content-moderation / policy-check job. Informational (not+ # request-gated); the model="guard" alias is unchanged.+ guard: true+max_sequence_length: 32768+# KV-cache memory math (Qwen3ForCausalLM 4B, bf16), same geometry as+# Qwen/Qwen3-4B-Instruct-2507:+# layers=36, kv_heads=8, head_dim=128, bytes_per_elem=2+# kv_bytes_per_token = 2 x 36 x 8 x 128 x 2 = 147,456 B (144 KB)+# About 8 GB of weights leaves (24 x 0.85 - 8) GB / 144 KB = 90,000 tokens of+# KV on an L4, and SGLang reported 185,081 tokens for the same architecture on+# an A100-40GB. The budgets below are the sibling Qwen3-4B values.+profiles:+ default:+ # max_batch_tokens is a generic engine knob; generation does not batch at+ # the SIE layer (SGLang batches internally) but the validator requires it.+ max_batch_tokens: 16384+ compute_precision: bfloat16+ adapter_path: sie_server.adapters.sglang.generation:SGLangGenerationAdapter+ # Measured on an L4 with SGLang 0.5.10.post1: p50 about 330 ms per check+ # (ToxicChat prompts, one request in flight).+ # L4 baseline: one full-context check, or many short ones, in flight.+ kv_budget_tokens: 32768+ adapter_options:+ loadtime:+ mem_fraction_static: 0.85+ served_model_name: Qwen/Qwen3Guard-Gen-4B+ runtime:+ first_chunk_timeout_s: 30+ inter_chunk_timeout_s: 10+ overall_timeout_s: 300+ # Greedy: a guard verdict must be deterministic.+ default_sampling:+ temperature: 0.0+ stop_tokens:+ - "<|im_end|>"+ a100-40gb:+ max_batch_tokens: 32768+ compute_precision: bfloat16+ adapter_path: sie_server.adapters.sglang.generation:SGLangGenerationAdapter+ # 185,081 / 4 concurrent full-context admissions, rounded down.+ kv_budget_tokens: 45056+ adapter_options:+ loadtime:+ mem_fraction_static: 0.85+ served_model_name: Qwen/Qwen3Guard-Gen-4B+ runtime:+ first_chunk_timeout_s: 30+ inter_chunk_timeout_s: 10+ overall_timeout_s: 300+ default_sampling:+ temperature: 0.0+ stop_tokens:+ - "<|im_end|>"diff --git a/packages/sie_server/tests/config/test_profile_backend_consistency.py b/packages/sie_server/tests/config/test_profile_backend_consistency.pyindex e9796bc19..12cb01518 100644--- a/packages/sie_server/tests/config/test_profile_backend_consistency.py+++ b/packages/sie_server/tests/config/test_profile_backend_consistency.py@@ -177,3 +177,39 @@ def test_guardian_task_pins_harm_risk() -> None:assert generate.get("chat_template_kwargs") == {"guardian_config": {"risk_name": "harm"},}+++QWEN3GUARD_PROFILES = sorted(MODELS_DIR.glob("Qwen__Qwen3Guard-Gen-*.yaml"))++[email protected]("path", QWEN3GUARD_PROFILES, ids=lambda p: p.stem)+def test_qwen3guard_profiles_serve_greedy_text_verdicts(path: Path) -> None:+ """Qwen3Guard answers in text lines, so it must stay greedy and off the logprob dial.++ The adapter's ``guard`` load-time block reads a one-token Yes/No verdict+ from logprobs. Qwen3Guard answers ``Safety: ...`` / ``Categories: ...``+ instead, so a ``guard`` block would misread it. Every profile is+ non-extending, so each must repeat greedy sampling and the stop token.+ """+ data = yaml.safe_load(path.read_text()) or {}+ generate = (data.get("tasks") or {}).get("generate") or {}+ assert (generate.get("capabilities") or {}).get("guard") is True+ assert "chat_template_kwargs" not in generate++ profiles = data.get("profiles") or {}+ assert profiles, f"No profiles found in {path.name}"+ for name, entry in profiles.items():+ options = entry.get("adapter_options") or {}+ loadtime = options.get("loadtime") or {}+ runtime = options.get("runtime") or {}+ assert "guard" not in loadtime, f"{path.name}:{name} must not carry a logprob guard block"+ assert loadtime.get("served_model_name") == data["sie_id"], f"{path.name}:{name}"+ assert runtime.get("default_sampling") == {"temperature": 0.0}, f"{path.name}:{name}"+ assert runtime.get("stop_tokens") == ["<|im_end|>"], f"{path.name}:{name}"+++def test_qwen3guard_catalog_entries_present() -> None:+ assert [p.name for p in QWEN3GUARD_PROFILES] == [+ "Qwen__Qwen3Guard-Gen-0.6B.yaml",+ "Qwen__Qwen3Guard-Gen-4B.yaml",+ ]