                          GMAIL: Generative Modality Alignment for generated Image Learning

Algorithm 1 GMAIL Algorithm: Training and Inference on Generated and Real Images
Require: Datasets of real images Dr = {(xr , yr )}, generated images Dg = {(xg , yg )}, and image pairs D = {(xg , xr )},
    pre-trained CLIP models fr and fg , learning rate η, batch size |B|, temperature τ , LoRA parameters.
Ensure: Fine-tuned model fg for generated images, aligned with fr for real images.
 1: Initialize: Load the pre-trained CLIP models fr and fg trained on real and generated images, respectively.
 2: Gen-CLIP Flow: Aligning Generated and Real Images.
 3: for each mini-batch B = {(xg , xr )} from D do
 4:   Extract generated image features fg (xg ) for each xg ∈ B using fg .
 5:   Extract real image features fr (xr ) for each xr ∈ B using fr .
 6:   Compute cross-modality alignment loss Lalign :

                                            1       X                   exp(sim(fg (xg ), fr (xr ))/τ )
                              Lalign = −                       log P                                ′
                                           |B|                        x′r ∈B exp(sim(fg (xg ), fr (xr ))/τ )
                                                 (xg ,xr )∈B

 7:   Apply LoRA updates to minimize Lalign .
 8:   Update model parameters fg ← fg − η∇fg Lalign .
 9: end for
10: Alignment with Vision-Language Models for downstream tasks.
11: for each LLM (e.g., from CLIPCap, LLaVA, LLaMA3) do
12:   Fine-tune the LLM using the aligned generated and real image embeddings from Dg and Dr , respectively.
13: end for
14: CLIP Flow: VLM Inference on Real Images.
15: for each real image xr for inference do
16:   Extract real image features fr (xr ) using fr .
17:   Use fr (xr ) instead fg (xr ) for inference the VLM model on real images.
18: end for
19: Return: VLM models with fg trained on generated images, aligned with the real-image model fr .



  • CC3M (Sharma et al., 2018) and CC12M (Changpinyo et al., 2021): These large-scale datasets provide millions of
    image-caption pairs, allowing us to explore the scalability of our Gen-Real alignment framework. We evaluate our
    model’s performance when trained on both real and generated data from these expansive datasets.

  • ShareGPT4V: To evaluate long caption retrieval, we use the ShareGPT4V dataset, which includes complex and
    descriptive captions associated with both generated and real images. This dataset emphasizes the importance of strong
    cross-modal alignment for retrieving long, detailed captions.

Evaluation Metrics. To comprehensively evaluate our framework, we employ task-specific metrics tailored to image
captioning, zero-shot image retrieval, and zero-shot image classification:

  • Image Captioning: Performance is assessed using standard metrics such as BLEU@4 (B@4) (Papineni et al., 2002),
    METEOR (Denkowski & Lavie, 2014), CIDEr (Vedantam et al., 2014), SPICE (Anderson et al., 2016), ROUGE-L (Lin
    & Och, 2004), and Word Mover’s Distance (WMD) (Kusner et al., 2015). These metrics evaluate the quality and
    semantic accuracy of generated captions compared to the ground truth.

  • Zero-Shot Image Retrieval: We measure both image-to-text and text-to-image retrieval capabilities using Recall@1,
    Recall@5, and Recall@10. These metrics assess the model’s ability to correctly retrieve relevant items based on the
    provided query, highlighting its cross-modal understanding.

  • Zero-Shot Image Classification: Classification performance on unseen categories is evaluated using top-1 accuracy,
    which reflects the model’s generalization ability to classify new classes without prior training on those specific
    categories.

This experimental setup allows us to thoroughly validate our Gen-Real alignment framework across a wide range of

                                                                 14
