# Attention Score Enhancement Model Through Pairwise Image Comparison
## 2 Materials and Methods
### Pairwise Attention Enhancement (PAE)  
The Pairwise Attention Enhancement (PAE) model was developed to overcome the limitations of the ViT. The ViT divides the input image into patches and processes each patch independently to learn global relationships. However, the ViT has structural limitations in effectively capturing subtle differences between local features. Specifically, it struggles to detect fine differences between visually similar images, as its global learning approach does not fully account for interactions within the image. To address these limitations, the PAE model proposed in this study selects two images, designating one as the training image and the other as the reference image, and enhances the attention map based on the similarity between them. In this process, the reference image provides additional context to the training image, allowing the model to learn not only individual images but also the visual differences and similarities between them. Unlike the ViT, which focuses on global relationships, PAE emphasizes areas with high visual similarity between the two images through cross-referencing, enabling the detection of subtle differences. Figure 3 illustrates the overall structure of the PAE model in stages. Figure 3a,c shows the process of inputting the reference image and the training image into the PAE model. Once both images are input, each patch is processed through a multi-head attention layer, where the relationships between patches are learned independently. While the ViT learns independent relationships between patches at this stage, PAE evaluates similarity by comparing the attention scores of the training image and the reference image. The core algorithm of PAE is detailed in Figure 3b. In the first step, PAE calculates the cosine similarity by comparing the attention score maps of the training image and the reference image. If the similarity exceeds a certain threshold, the attention map of the reference image is fused with that of the training image in the second step. The combined attention map integrates the visual information of both images to create a more refined representation. In this step, PAE maintains the global learning capabilities of the ViT while effectively capturing subtle differences between local features. This fusion process goes beyond simple averaging, enhancing the unique characteristics of each image to enable richer representation. Finally, PAE generates an enhanced training image through the combined attention map. While the ViT independently learns and combines each patch to generate the final output, PAE strengthens the attention map by incorporating the reference image, transforming the training image into a deeper representation. Consequently, PAE effectively detects subtle differences in local features that are challenging for the ViT, particularly excelling in applications that require advanced visual features, such as cognitive impairment detection. PAE's distinct attention enhancement mechanism complements the traditional learning structure of the ViT, enabling it to better reflect differences between images with high visual similarity. This approach is crucial for understanding the background behind PAE's design, which aims to overcome the limitations of the ViT. PAE retains the ViT's global relationship learning abilities while focusing on learning finer visual patterns. As a result, unlike the ViT, PAE can leverage local feature learning to exhibit more refined perceptual abilities and effectively process complex visual data. PAE's design is based on the traditional Transformer architecture of the ViT, yet it extends beyond independent patch learning to incorporate image-to-image interactions. This makes it particularly suitable for medical fields where detailed visual information is critical, such as in the diagnosis of cognitive impairments.