Skip to content

Commit e6884fa

Browse files
committed
improvement(pii): assert real GLiNER inference in the image build
The bake step previously only proved GLiNER.from_pretrained loads — a transformers/gliner bump that silently stops returning detections would still build and pass /health. The bake step now runs predict_entities on a sample sentence (labels from engines.py's GLINER_ENTITY_MAPPING) and fails the build unless person + location are detected. Verified against the exact bumped pin set (transformers 5.5.0, huggingface_hub 1.23.0, gliner 0.2.27, torch 2.11.0): person 0.9999, location 0.9951, date 0.9987.
1 parent b3eb3b0 commit e6884fa

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

docker/pii.Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,16 @@ RUN --mount=type=cache,target=/root/.cache/pip \
8787
# Bake the GLiNER weights at build time (cached layer) so startup never
8888
# touches the network. HF_HUB_OFFLINE makes a missing/overridden
8989
# PII_GLINER_MODEL fail fast at startup instead of silently downloading.
90+
# The predict_entities smoke assert (labels from engines.py's
91+
# GLINER_ENTITY_MAPPING) fails the build if a transformers/gliner bump loads
92+
# the model fine but silently stops returning detections.
9093
ENV HF_HOME=/opt/hf-cache
9194
ARG GLINER_MODEL=urchade/gliner_multi_pii-v1
92-
RUN python -c "from gliner import GLiNER; GLiNER.from_pretrained('${GLINER_MODEL}')" && \
95+
RUN python -c "from gliner import GLiNER; \
96+
model = GLiNER.from_pretrained('${GLINER_MODEL}'); \
97+
ents = model.predict_entities('John Smith flew to Paris on 4 May 2021.', ['person', 'location', 'date']); \
98+
labels = {e['label'] for e in ents}; \
99+
assert {'person', 'location'} <= labels, f'GLiNER smoke inference failed, got: {ents}'" && \
93100
chmod -R a+rX /opt/hf-cache
94101
ENV HF_HUB_OFFLINE=1
95102

0 commit comments

Comments
 (0)