]> git.99rst.org Git - sgasser-llm-shield.git/commitdiff
Tune GLiNER confidence floors (#114)
authorStefan Gasser <redacted>
Tue, 23 Jun 2026 11:41:55 +0000 (13:41 +0200)
committerGitHub <redacted>
Tue, 23 Jun 2026 11:41:55 +0000 (13:41 +0200)
* Tune GLiNER confidence floors

* Fix Docker torch dependency install

detector/detector/gliner_layer.py
docker/Dockerfile

index 2b237560291bbe794b87865e868f4917d2c602fd..e9290c521a3e7ea30d2e421ce97ab76353d78b3a 100644 (file)
@@ -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"}
index bc14936cc9096cb79532f76711ae4b6ec4e1e4cc..7083cb97f7f8f235db7d7f8e9cb60af46cb5b108 100644 (file)
@@ -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/
git clone https://git.99rst.org/PROJECT