PiShield: A PyTorch Package for Learning with Requirements

Mihaela C. Stoian, Alex Tatomir, Thomas Lukasiewicz, Eleonora Giunchiglia, Ramtin Zand, Ramy Harik, Amit Sheth

Abstract

In modern assembly pipelines, identifying anomalies is crucial in ensuring product quality and operational efficiency. Conventional single-modality methods fail to capture the intricate relationships required for precise anomaly prediction in complex predictive environments with abundant data and multiple modalities. This paper proposes a neurosymbolic AI and fusion-based approach for multimodal anomaly prediction in assembly pipelines. We introduce a time series and image-based fusion model that leverages decision-level fusion techniques. Our research builds upon three primary novel approaches in multimodal learning: time series and image-based decision-level fusion modeling, transfer learning for fusion, and knowledge-infused learning. We evaluate the novel method using our derived and publicly available multimodal dataset and conduct comprehensive ablation studies to assess the impact of our preprocessing techniques and fusion model compared to traditional baselines. The results demonstrate that a neurosymbolic AI-based fusion approach that uses transfer learning can effectively harness the complementary strengths of time series and image data, offering a robust and interpretable approach for anomaly prediction in assembly pipelines with enhanced performance. The datasets, codes to reproduce the results, supplementary materials, and demo are available at https://github.com/ChathurangiShyalika/NSF-MAP.

Introduction

Deep Neural Networks (DNNs) are often criticized for being "black-box" models that can produce outputs violating basic logic or safety protocols. For instance, an autonomous driving model might simultaneously predict that a pedestrian is on both the left and right sides of the road, or a medical model might generate synthetic data where a patient's minimum temperature exceeds their maximum. While researchers have traditionally used "soft constraints" in loss functions to discourage these errors, these are merely suggestions that the model can ignore.

We address this gap by introducing a method to enforce "hard constraints" that a model physically cannot bypass. This is achieved through the integration of specialized layers that guarantee model outputs will always comply with specified domain requirements, regardless of the input.

The Shield Layer Architecture

The core innovation of this approach is the Shield Layer, a specialized component designed to be appended to the end of any standard neural network. This layer transforms a standard DNN into a "Shielded DNN," providing a mathematical guarantee of requirement satisfaction.

The Shielded DNN architecture integrates a Shield Layer to enforce domain requirements, ensuring valid outputs.

Practitioners can integrate a Shield Layer with minimal effort, requiring only the dimension of the input and a specification of the requirements. The package supports two primary types of constraints:

  1. Propositional Logic: Expressed in Conjunctive Normal Form (CNF) to enforce logical consistency (e.g., "If a traffic light is detected, it must have a color").
  2. Linear Inequalities: Mathematical constraints to ensure physical or clinical validity (e.g., $y_{max} \ge y_{min}$).

Multimodal Evaluation and Datasets

The effectiveness of this neurosymbolic approach was evaluated across three distinct multimodal domains:

  • Autonomous Driving: Using the ROAD-R dataset, which contains 243 manual logical constraints, the model was tested on its ability to handle real-world driving scenes without contradictory labels.
  • Tabular Data Generation: Tested on five datasets for synthetic data generation involving up to 31 linear inequality constraints, such as clinical trial parameters.
  • Functional Genomics: Applied to Hierarchical Multi-label Classification (HMC) tasks across eight datasets, where gene functions must follow a strict hierarchy.

Key Results and Insights

Contrary to the misconception that adding constraints hampers model performance, our findings show that "shielded" models consistently outperform unconstrained baselines. By pruning the space of impossible outputs, the model can focus its learning capacity on valid regions, leading to higher accuracy and better data quality.

PiShield ensures that synthetic tabular data respects linear inequalities, such as minimum hemoglobin not exceeding maximum hemoglobin, effectively avoiding the invalid red zone.

Key performance improvements include:

  • Autonomous Driving: Frame-wise mean average precision (f-mAP) improved from 0.288 to 0.303.
  • Functional Genomics: Area under the precision-recall curve (AU(PRC)) rose from 0.225 to 0.241.
  • Tabular Data: The utility score (Utility-F1) increased from 0.430 to 0.458.

Qualitatively, the Shield Layer successfully eliminated contradictory predictions—such as labeling a person as both a "pedestrian" and a "cyclist"—that were frequent in the baseline models.

Conclusion and Future Work

By moving constraints from the loss function to the network topology, we provide a robust framework for safety-critical AI applications. Future work will explore the computational overhead of complex interlocking constraints and expand the implementation to support more complex temporal or first-order logic. This approach represents a significant step toward making deep learning models both interpretable and reliably safe for deployment in complex environments like assembly pipelines.

Summary updated

BibTeX
@inproceedings{stoian2024pishield,
  author = {Mihaela C. Stoian and Alex Tatomir and Thomas Lukasiewicz and Eleonora Giunchiglia and Ramtin Zand and Ramy Harik and Amit Sheth},
  title = {{PiShield: A PyTorch Package for Learning with Requirements}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2024},
  url = {https://openreview.net/forum?id=RM97NoQgzq},
}
Figure