From: Stefan Gasser Date: Tue, 23 Jun 2026 11:41:55 +0000 (+0200) Subject: Tune GLiNER confidence floors (#114) X-Git-Tag: v0.7.0~3 X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=a7b8acf0fdb6da9187fdaf237fe0c20ba0fde419;p=sgasser-llm-shield.git Tune GLiNER confidence floors (#114) * Tune GLiNER confidence floors * Fix Docker torch dependency install --- diff --git a/detector/detector/gliner_layer.py b/detector/detector/gliner_layer.py index 2b23756..e9290c5 100644 --- a/detector/detector/gliner_layer.py +++ b/detector/detector/gliner_layer.py @@ -26,11 +26,11 @@ def _floor(label: str, default: float) -> float: # overridable via env, e.g. DETECTOR_FLOOR_LOCATION=0.6). Role nouns are demoted # by the suppressor labels (below), not by this floor. PER_LABEL_FLOOR = { - "person": _floor("person", 0.85), - "location": _floor("location", 0.50), + "person": _floor("person", 0.95), + "location": _floor("location", 0.80), # A dedicated "address" label recovers full street addresses that a bare # "location" reading misses; emitted as LOCATION (see _LABEL_TO_TYPE). - "address": _floor("address", 0.70), + "address": _floor("address", 0.80), } # Labels the request `score_threshold` may raise (high-volume, deployment-tunable). _TUNABLE = {"person", "location", "address"} diff --git a/docker/Dockerfile b/docker/Dockerfile index bc14936..7083cb9 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -37,7 +37,8 @@ FROM python:3.11-slim AS detector # pin it for every arch. (PyPI's DEFAULT index now ships CUDA builds for # linux/arm64 too — e.g. torch 2.x+cuXXX — which would drag ~6 GB of unused # CUDA libraries into the image; the explicit CPU index avoids that.) -RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu +RUN pip install --no-cache-dir typing-extensions \ + && pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu # Install the detector package (pulls fastapi/uvicorn/gliner/stdnum/...). COPY detector/pyproject.toml /srv/detector/