diff --git a/apps/pii/requirements-gliner.txt b/apps/pii/requirements-gliner.txt index a3d002f3850..1fa34dd7c07 100644 --- a/apps/pii/requirements-gliner.txt +++ b/apps/pii/requirements-gliner.txt @@ -6,5 +6,5 @@ # torch is pinned in the Dockerfile instead: the CPU and CUDA targets install # the same version from different wheel indexes. gliner==0.2.27 -transformers==5.3.0 -huggingface_hub==1.3.0 +transformers==5.5.0 +huggingface_hub==1.23.0 diff --git a/docker/pii.Dockerfile b/docker/pii.Dockerfile index 205462bad3f..66a32757af7 100644 --- a/docker/pii.Dockerfile +++ b/docker/pii.Dockerfile @@ -87,9 +87,16 @@ RUN --mount=type=cache,target=/root/.cache/pip \ # Bake the GLiNER weights at build time (cached layer) so startup never # touches the network. HF_HUB_OFFLINE makes a missing/overridden # PII_GLINER_MODEL fail fast at startup instead of silently downloading. +# The predict_entities smoke assert (labels from engines.py's +# GLINER_ENTITY_MAPPING) fails the build if a transformers/gliner bump loads +# the model fine but silently stops returning detections. ENV HF_HOME=/opt/hf-cache ARG GLINER_MODEL=urchade/gliner_multi_pii-v1 -RUN python -c "from gliner import GLiNER; GLiNER.from_pretrained('${GLINER_MODEL}')" && \ +RUN python -c "from gliner import GLiNER; \ +model = GLiNER.from_pretrained('${GLINER_MODEL}'); \ +ents = model.predict_entities('John Smith flew to Paris on 4 May 2021.', ['person', 'location', 'date']); \ +labels = {e['label'] for e in ents}; \ +assert {'person', 'location', 'date'} <= labels, f'GLiNER smoke inference failed, got: {ents}'" && \ chmod -R a+rX /opt/hf-cache ENV HF_HUB_OFFLINE=1