AI & Computingarticle2026-10-17

Effect of hierarchical prompt engineering on convolutional neural networks generated by large language models for helmet wearing compliance classification

Open access0 citations

Abstract

Abstract Non-compliance with Personal Protective Equipment (PPE) use regulations, particularly helmet wearing, remains a critical occupational safety challenge in high-risk industrial environments. This study investigates how hierarchical prompt engineering shapes the quality of Convolutional Neural Networks (CNNs) generated by Large Language Models (LLMs) for image-level helmet-wearing compliance classification (helmet vs. no-helmet) as a mechanism for PPE compliance monitoring. Four LLMs (ChatGPT, Claude, Gemini, and Grok) produced executable PyTorch scripts across three prompt tiers of increasing specificity. These configurations were evaluated over 20 independent runs on a purpose-built dataset of 972 balanced images, using six classification metrics, four prompt quality metrics, and three resource efficiency dimensions. Ten of the twelve configurations converged to a high-performance plateau (accuracy 0.957-−0.967, AUC 0.985-−0.993). Claude at Tier 1 achieved the highest accuracy (0.967) and the lowest CPU usage (12.2%), whereas the best-calibrated (lowest-loss) pipelines were produced by Gemini and Grok at Tier 1 (test loss 0.127 and 0.142), reflecting an accuracy–calibration dissociation that we analyze in detail. However, Gemini and Grok experienced catastrophic convergence failures at Tier 3 (accuracy $$\approx $$ 0.58), revealing that over-specification of architectural and training constraints can destabilize CNN generation even when the produced scripts are syntactically valid. Higher prompt specificity does not consistently improve accuracy or validity rate. Instead, LLM identity interacts strongly with the prompt tier and emerges as a more critical factor than prompt design alone, although each LLM–tier condition is represented by a single generated script. Within the scope of this controlled, image-level evaluation, basic and structured prompting represent the recommended operating range for developing PPE compliance classifiers, delivering competitive accuracy and full validity rate across all models without the convergence failures observed at Tier 3. Validation in real industrial settings remains necessary.

// Source

View paper (DOI)Open access versionOpenAlexDiscover Artificial IntelligencePublished 2026-10-17

Authors: Jorge Antonio Párraga Álava, Jorge Rodas‐Silva

Institutions: Universidad Técnica de Manabí, Universidad Estatal de Milagro