Debugging and Runtime Analysis of Neural Networks with VLMs (A Case Study)

Boyue Caroline Hu, Divya Gopinath, Corina S. Pasareanu, Nina Narodytska, Ravi Mangal, Susmit Jha · DOI

Abstract

Deep Neural Networks (DNNs) are often criticized as "black boxes," where internal decision-making processes remain opaque to human developers. This paper introduces a novel framework that utilizes Vision-Language Models (VLMs) as a semantic bridge to interpret the internal representations of vision models. By aligning the embedding spaces of a target model and a VLM, the authors generate "semantic heatmaps" that translate high-dimensional vectors into human-understandable concepts. This approach enables precise fault localization—distinguishing between encoder and classification head errors—and provides a lightweight runtime monitor for detecting adversarial attacks and natural misclassifications.

Introduction

Despite the ubiquity of Deep Neural Networks in computer vision, debugging these models remains a significant challenge. When a classifier fails, traditional attribution methods (like Saliency Maps) might highlight relevant pixels, but they fail to explain the semantic reason for the failure. This "semantic gap" exists because models operate in high-dimensional vector spaces, while humans reason using discrete concepts like "wheels," "fur," or "metallic surfaces."

This research addresses the gap by leveraging the pre-existing semantic knowledge within Vision-Language Models (VLMs) such as CLIP. Instead of replacing specialized vision models with VLMs, the authors use the VLM as a "semantic oracle" to audit and monitor the target model's health during both development and deployment.

Methodology

The proposed framework consists of a multi-stage pipeline designed to extract human-readable insights from a target vision model (e.g., ResNet18).

1. Space Alignment

The first step involves learning a mathematical mapping—specifically an affine transformation—that aligns the internal representation space of the target model with the embedding space of the VLM. This allows the system to project the target model's features into a space where they can be compared against text-based concepts.

2. Semantic Heatmaps and Predicates

The authors define 2D grids where axes represent high-level concepts. Each cell in the grid represents a "predicate," comparing the relative strength of two concepts (e.g., "Does the model perceive more 'wings' than 'wheels' in this image?"). By visualizing these predicates, developers can see the "semantic signature" of a specific class or input.

3. Fault Localization

A key innovation of this framework is the ability to localize errors within the network architecture:

  • Encoder Error: The model failed to extract the correct semantic features from the image.
  • Head Error: The model extracted the correct features but the classification head reached the wrong logical conclusion.

4. Runtime Monitoring

To protect models in production, the authors developed a monitor that computes heatmaps for incoming data in real-time. By comparing the "Intersection over Union" (IoU) of a new input's heatmap against a known "clean" profile, the system can flag adversarial perturbations or high-probability misclassifications without the overhead of running a full VLM alongside the primary model.

Experimental Evaluation

The framework was evaluated using the RIVAL10 dataset, a subset of ImageNet-1k containing 10 classes with expert-annotated attributes (e.g., furry, metallic, wings). The primary target model was a ResNet18, and CLIP (ViT-B/16) served as the grounding VLM.

Key Findings

  • Adversarial Localization: A significant discovery was that over 90% of adversarial errors (such as PGD attacks) are localized in the encoder. The attack effectively "scrambles" the semantic features before they ever reach the classification head.
  • Detection Performance: The runtime monitor achieved approximately 80% accuracy in detecting adversarial perturbations (FGSM and PGD $l_\infty$ attacks).
  • Natural Misclassifications: The system successfully flagged natural errors with high accuracy, notably 80% for the "truck" class and 75% for "dogs."
  • Concept Sensitivity: Heatmaps revealed that while models are robust to certain concepts (e.g., "rectangular"), they are highly sensitive to others (e.g., "wheels"), providing a roadmap for targeted data augmentation.

Discussion and Limitations

While the framework provides a powerful new toolkit for model transparency, it is not without limitations. The current method relies on a predefined dictionary of human-defined concepts; if a model fails due to a concept not present in the dictionary, the heatmap cannot represent it. Furthermore, the reliability of the debugging process is tethered to the reliability of the VLM itself. For instance, the authors noted that CLIP’s sensitivity to brightness changes could potentially lead to false positives in fault detection.

Future work aims to automate "concept discovery," where the VLM identifies relevant features without human intervention, and to move from diagnosis to "repair"—using semantic insights to automatically curate training sets that fix identified conceptual weaknesses.

Conclusion

By bridging the gap between vector representations and natural language, this framework transforms DNN debugging from a syntactic exercise into a semantic one. The ability to localize faults and monitor model health at runtime represents a significant step toward building more reliable and interpretable AI systems.

Summary updated

BibTeX
@inproceedings{hu2025debugging,
  author = {Boyue Caroline Hu and Divya Gopinath and Corina S. Pasareanu and Nina Narodytska and Ravi Mangal and Susmit Jha},
  title = {{Debugging and Runtime Analysis of Neural Networks with VLMs (A Case Study)}},
  booktitle = {CAIN},
  year = {2025},
  doi = {10.1109/cain66642.2025.00027},
}
Figure