ARRA (Autoregressive Representation Alignment) is a novel training framework that enables autoregressive LLMs to perform high-quality text-to-image generation without architectural modifications. The key designs include:
<HYBNEXT> token (enforcing dual local-global constraints)


conda create -n arra python=3.10 -y
conda activate arra
pip install -r requirements.txt
pip install flash-attn --no-build-isolation
# bash
# go to the root path of the project
cd ARRA
# install as package
pip install -e .
Please manually download the original VQ-VAE weights provided by Meta and put them to the following directory:
ARRA
- arra/
- ckpts/
- chameleon/
- tokenizer/
- text_tokenizer.json
- vqgan.yaml
- vqgan.ckpt
- xllmx/
- ...
| Model | Size | Huggingface |
|---|---|---|
| ARRA-Adapt-MIMIC-7B | 7B | xing0916/ARRA-Adapt-MIMIC-7B |
python3 arra/inference_vision.py
The generated images will be saved to ./generated_image.
For efficiency considerations, the multi-modal datasets are pre-tokenized into sequences of token ids. This leads to significantly faster training.
This stage tokenizes each data point, consisting of interleaved image and text, into a single sequence of integer tokens. After tokenization, the sequence is saved to disk for trainining-time usage. Together with the saved tokens, a json-formatted record file is also generated for indexing all the saved token files. For faster tokenization, you may use multiple GPUs and dispatch different subsets of data to them.
for i in {0..7}
do
export CUDA_VISIBLE_DEVICES=${i}
python -u pre_tokenize/pre_tokenize_new.py \
--splits=8 \
--rank=${i} \
--in_filename /path/to/in_filename.json \
--out_dir /path/to/out_dir \
--target_size 512 &> ${i}.log &
done
in_filename is expected to be a json file with the following format:
[
{...},
{...},
{
"conversations": [
{
"from": "human",
"value": "AP view chest x-ray image, Nasogastric tube is coiled in the stomach."
},
{
"from": "gpt",
"value": "<|image|>"
}
],
"image": [
"./datasets/MIMIC-CXR/files/p19/p19023118/s50489739/da2a33b1-a3e756c6-9aec59ef-dcc2bfe8-0e872a6f.jpg"
]
},
{
"conversations": [
{
"from": "human",
"value": "AP view chest x-ray image, No acute cardiopulmonary process. No evidence of free air beneath the diaphragms."
},
{
"from": "gpt",
"value": "<|image|>"
}
],
"image": [
"./datasets/MIMIC-CXR/files/p19/p19023118/s50688363/2d8ff122-9033f698-4190575b-d5de4716-f11842b9.jpg"
]
},
{...},
{...}
]
Rules:
image key, otherwise the image key can be omitted<|image|> symbol
<|image|> symbol should be equal to the number of images in the image keyIf you have your own data with a different format, you can easily adapt the code to deal with it by modifying the pre_tokenize.py file.
We have prepared the space, which is in ItemProcessor.process_item, for adding your logic that converts data points of your own format into the standard format.
After tokenization, You need to concat the record files generated by different processes (GPUs) into one single record file. Note that we use the term "record file" to refer to the meta file that contains the information of all the saved token files, which is different from the token files themselves.
python -u pre_tokenize/concat_record.py \
--sub_record_dir /path/to/out_dir \
--save_path /path/to/out_dir/record.json
First you need to download the corresponding foundation model from huggingface (BioMedCLIP, CLIP-L, MedSAM).
Next you can extract external representation for training:
python pre_tokenize/pre_biomedclip_feature.py
or
python pre_tokenize/pre_medsam_feature.py
We provide an example experiment scripts scrpits/7B.sh for training the 7B model.
bash scrpits/7B.sh
--data_config argument:The --data_config argument should point to a *.yaml file, which is a meta file that gathers one or multiple record files.
In other words, you may pre-tokenize multiple datasets independently and list the record files in the same data config file
for joint training.
This code is build on the following repositories: https://github.com/Alpha-VLLM/Lumina-mGPT.
@article{xie2025unleashing,
title={Unleashing the Potential of Large Language Models for Text-to-Image Generation through Autoregressive Representation Alignment},
author={Xie, Xing and Liu, Jiawei and Lin, Ziyue and Fan, Huijie and Han, Zhi and Tang, Yandong and Qu, Liangqiong},
journal={arXiv preprint arXiv:2503.07334},
year={2025}
}
35 commits
Python
99.8%
ARRA (Autoregressive Representation Alignment) is a novel training framework that enables autoregressive LLMs to perform high-quality text-to-image generation without architectural modifications. The key designs include:
<HYBNEXT> token (enforcing dual local-global constraints)


conda create -n arra python=3.10 -y
conda activate arra
pip install -r requirements.txt
pip install flash-attn --no-build-isolation
# bash
# go to the root path of the project
cd ARRA
# install as package
pip install -e .
Please manually download the original VQ-VAE weights provided by Meta and put them to the following directory:
ARRA
- arra/
- ckpts/
- chameleon/
- tokenizer/
- text_tokenizer.json
- vqgan.yaml
- vqgan.ckpt
- xllmx/
- ...
| Model | Size | Huggingface |
|---|---|---|
| ARRA-Adapt-MIMIC-7B | 7B | xing0916/ARRA-Adapt-MIMIC-7B |
python3 arra/inference_vision.py
The generated images will be saved to ./generated_image.
For efficiency considerations, the multi-modal datasets are pre-tokenized into sequences of token ids. This leads to significantly faster training.
This stage tokenizes each data point, consisting of interleaved image and text, into a single sequence of integer tokens. After tokenization, the sequence is saved to disk for trainining-time usage. Together with the saved tokens, a json-formatted record file is also generated for indexing all the saved token files. For faster tokenization, you may use multiple GPUs and dispatch different subsets of data to them.
for i in {0..7}
do
export CUDA_VISIBLE_DEVICES=${i}
python -u pre_tokenize/pre_tokenize_new.py \
--splits=8 \
--rank=${i} \
--in_filename /path/to/in_filename.json \
--out_dir /path/to/out_dir \
--target_size 512 &> ${i}.log &
done
in_filename is expected to be a json file with the following format:
[
{...},
{...},
{
"conversations": [
{
"from": "human",
"value": "AP view chest x-ray image, Nasogastric tube is coiled in the stomach."
},
{
"from": "gpt",
"value": "<|image|>"
}
],
"image": [
"./datasets/MIMIC-CXR/files/p19/p19023118/s50489739/da2a33b1-a3e756c6-9aec59ef-dcc2bfe8-0e872a6f.jpg"
]
},
{
"conversations": [
{
"from": "human",
"value": "AP view chest x-ray image, No acute cardiopulmonary process. No evidence of free air beneath the diaphragms."
},
{
"from": "gpt",
"value": "<|image|>"
}
],
"image": [
"./datasets/MIMIC-CXR/files/p19/p19023118/s50688363/2d8ff122-9033f698-4190575b-d5de4716-f11842b9.jpg"
]
},
{...},
{...}
]
Rules:
image key, otherwise the image key can be omitted<|image|> symbol
<|image|> symbol should be equal to the number of images in the image keyIf you have your own data with a different format, you can easily adapt the code to deal with it by modifying the pre_tokenize.py file.
We have prepared the space, which is in ItemProcessor.process_item, for adding your logic that converts data points of your own format into the standard format.
After tokenization, You need to concat the record files generated by different processes (GPUs) into one single record file. Note that we use the term "record file" to refer to the meta file that contains the information of all the saved token files, which is different from the token files themselves.
python -u pre_tokenize/concat_record.py \
--sub_record_dir /path/to/out_dir \
--save_path /path/to/out_dir/record.json
First you need to download the corresponding foundation model from huggingface (BioMedCLIP, CLIP-L, MedSAM).
Next you can extract external representation for training:
python pre_tokenize/pre_biomedclip_feature.py
or
python pre_tokenize/pre_medsam_feature.py
We provide an example experiment scripts scrpits/7B.sh for training the 7B model.
bash scrpits/7B.sh
--data_config argument:The --data_config argument should point to a *.yaml file, which is a meta file that gathers one or multiple record files.
In other words, you may pre-tokenize multiple datasets independently and list the record files in the same data config file
for joint training.
This code is build on the following repositories: https://github.com/Alpha-VLLM/Lumina-mGPT.
@article{xie2025unleashing,
title={Unleashing the Potential of Large Language Models for Text-to-Image Generation through Autoregressive Representation Alignment},
author={Xie, Xing and Liu, Jiawei and Lin, Ziyue and Fan, Huijie and Han, Zhi and Tang, Yandong and Qu, Liangqiong},
journal={arXiv preprint arXiv:2503.07334},
year={2025}
}
35 commits
Python
99.8%