Graphical Models with Attention for Context-Specific Independence and an Application to Perceptual Grouping

Guangyao Zhou, Wolfgang Lehrach, Antoine Dedieu, Miguel Lázaro-Gredilla, Dileep GeorgearXiv 2021

Abstract

Probabilistic Graphical Models (PGMs) like Markov Random Fields (MRFs) are powerful for modeling dependencies but often struggle with Context-Specific Independence (CSI)—where dependencies between variables change based on their values. This paper introduces the Markov Attention Model (MAM), which reinterprets "attention" as a mechanism to dynamically toggle these dependencies. By formulating attention within a standard discrete MRF framework, the authors enable scalable inference via Max-Product Belief Propagation on GPUs. MAM achieves state-of-the-art results on perceptual grouping tasks, demonstrating extreme sample efficiency and superior generalization compared to deep learning baselines.

Introduction

Standard MRFs assume fixed dependencies: if two variables are connected, they are dependent regardless of context. However, in tasks like visual perception, dependencies are often conditional; for instance, two line segments are only dependent if they belong to the same object. While theoretical frameworks for CSI exist, they typically require specialized, non-scalable inference methods. This work bridges the gap between the flexibility of modern attention mechanisms and the formal rigor of PGMs by treating attention as a structural property of the graph.

Methods

The Markov Attention Model (MAM) introduces binary "attention variables" for every pair of interacting regular variables (e.g., object parts). An "ON" state indicates a dependency, while an "OFF" state encodes conditional independence. Higher-order factors (HOFs) are used to enforce structural consistency, such as ensuring a part variable is active only if it is "attending" to at least one other part. This structure allows the model to encode "Gestalt laws"—such as continuity and proximity—directly into the factor graph.

The MAM architecture reinterprets attention as a mechanism to toggle dependencies, transforming a standard MRF (left) into a factor graph with explicit attention variables (right).

To bridge the gap between raw pixels and symbolic models, the authors utilize a "sparsifier"—a simple binary MRF that maps dense image data to sparse symbolic part activations. Inference is performed using Max-Product Belief Propagation (MPBP). By implementing this in JAX, the authors leverage GPU parallelization to overcome the historical scaling issues associated with CSI models.

Results and Discussion

The model was evaluated on three challenges: the Pathfinder task, the cABC distorted letter task, and real-world RGB-D images of objects in totes.

Sample Efficiency and Generalization

On the Pathfinder "hard" task, MAM reached near-perfect accuracy with only 5,000 training images. In stark contrast, a state-of-the-art recurrent neural network (H-CNN) required 900,000 images and still performed significantly worse. Furthermore, MAMs trained on "easy" versions of a task generalized almost perfectly to "ultimate" difficulty levels (longer, more complex contours), a scenario where RNN baselines completely failed to generalize to novel setups.

The MAM pipeline for perceptual grouping: from identifying object parts to modeling their relationships via attention factors in the Pathfinder and cABC tasks.

Interpretability and Real-World Application

Unlike "black box" neural networks, MAM's grouping process is visually interpretable. By examining which attention variables are "ON," researchers can see exactly how the model grouped parts into a coherent object. In realistic RGB-D datasets, MAM achieved a median Intersection over Union (IoU) of 0.71 for object detection, demonstrating its viability beyond synthetic benchmarks despite being trained on a very small number of images.

Conclusion

MAM provides a mathematically grounded and scalable approach to attention through the lens of context-specific independence. By combining symbolic structure with efficient probabilistic inference, it achieves superior sample efficiency and generalization in structured perception tasks. Future work may extend MAMs to other domains where CSI is prevalent, such as gene regulatory networks or word sense disambiguation.

Summary updated

BibTeX
@misc{zhou2021graphical,
  author = {Guangyao Zhou and Wolfgang Lehrach and Antoine Dedieu and Miguel Lázaro-Gredilla and Dileep George},
  title = {{Graphical Models with Attention for Context-Specific Independence and an Application to Perceptual Grouping}},
  year = {2021},
  eprint = {2112.03371},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2112.03371},
}
Figure