Paper | Project Page | Models
JUICE (Joint Unified multimodal modeling In Continuous Encoder spaces) is one flow-matching Transformer (MM-RiT, 2.1 B parameters) that generates images and text together. It does not use pixels or token ids. It works in the representation spaces of frozen pretrained encoders:
- Images: the patch states of SigLIP2 or WebSSL-DINO (256 x 1152 or 256 x 1024).
- Text: the token states of Flan-T5-Small (128 x 512).
One flow-matching objective trains text-to-image generation, question answering and joint image-and-text generation. A frozen decoder changes image states into pixels. A small parallel text head (the parallel decoder of the paper) changes text states into words.
This repository holds the code for inference, evaluation, training (all stages) and data preparation.
- Environment
- Models
- Inference
- Training
- Evaluation
- Guides and repository structure
- License
- Citation
- Acknowledgements
| Item | Requirement | We used |
|---|---|---|
| System | Linux, NVIDIA GPU with CUDA | NVIDIA A100 and H100 GPUs with 80 GB |
| Python | 3.10 or later | 3.11 |
| PyTorch | 2.5 or later | 2.5.1 |
conda create -n juice python=3.11 -y
conda activate juice
# PyTorch. This command installs the PyPI build for CUDA 12.4.
# For a different CUDA version, get the command from https://pytorch.org.
pip install torch==2.5.1 torchvision==0.20.1
# JUICE and all optional parts
git clone https://github.com/Ced3-han/JUICE-Code.git
cd JUICE-Code
pip install -e ".[train,eval]"You can also use a Python virtual environment (python -m venv) instead of conda.
If you need only some parts, install only the extras that you need:
| Command | Adds | You need it for |
|---|---|---|
pip install -e . |
transformers, huggingface_hub, safetensors, Pillow | inference |
pip install -e ".[train]" |
webdataset | training |
pip install -e ".[eval]" |
pyarrow | question-answering benchmarks |
pyproject.toml keeps transformers at a version earlier than 5.14,
because transformers 5.19 does not operate with PyTorch 2.5.
Do not upgrade huggingface_hub to 2.x: transformers 5.13 needs a version earlier than 2.0.
Run the unit tests (CPU, approximately 20 seconds):
python -m unittest discover -s tests -t .The first run downloads the frozen encoders and decoders from Hugging Face
(6.2 GB for a SigLIP2 model, 3.1 GB for a WebSSL-DINO model) and the JUICE model (8.6 GB).
The code pins each download to the revision that the paper used.
To keep the downloads in a different folder, set HF_HOME before the first run:
export HF_HOME=/path/to/huggingfacedocs/INSTALL.md gives the list of the downloads, the use without a network connection
and the package versions that we tested.
All models are in the Hugging Face collection.
| Model | Image encoder | Training | Use |
|---|---|---|---|
CedLJH/JUICE-2B-SigLIP2 |
SigLIP2 | pretraining + SFT | text-to-image, question answering (recommended) |
CedLJH/JUICE-2B-DINO |
WebSSL-DINO | pretraining + SFT | text-to-image, question answering |
CedLJH/JUICE-2B-SigLIP2-Base |
SigLIP2 | pretraining | text-to-image, start of a fine-tune |
CedLJH/JUICE-2B-DINO-Base |
WebSSL-DINO | pretraining | text-to-image, start of a fine-tune |
Each model folder holds the weights that we evaluated (the fast EMA weights),
config.json with the inference settings of the paper, and the text head (text_head/).
docs/MODEL_ZOO.md gives the details and the results.
The scripts download a model when you give its Hugging Face name. To download a model folder before you use it:
hf download CedLJH/JUICE-2B-SigLIP2 --local-dir JUICE-2B-SigLIP2In all commands, --model is a Hugging Face name or a local model folder.
The default settings are the settings of the paper (config.json of the model folder).
python -m scripts.inference.text_to_image --model CedLJH/JUICE-2B-SigLIP2 \
--prompt "a red bicycle next to a blue door" --num-images 4 --out bicycleThe command writes bicycle_0.png to bicycle_3.png (224 x 224).
| Option | Default | Meaning |
|---|---|---|
--num-images |
4 | number of images. The script makes the images in batches of 4. |
--seed |
0 | random seed. Batch k uses the seed (seed + 4k). |
--steps |
25 | number of sampling steps |
--cfg-scale |
5.0 | classifier-free guidance scale |
python -m scripts.inference.answer --model CedLJH/JUICE-2B-SigLIP2 --short \
--image photo.jpg --question "What color is the door?"The command writes one line for each question: the image, the question and the answer.
--shortadds the short-answer instruction of the benchmarks ("Answer the question using a single word or phrase.").- To ask more questions, give
--imageand--questionagain, in the same order (one question for each image). - For a multiple-choice question, put the options in the question.
docs/EVAL_VQA.mdshows the format.
The default settings are 16 steps, guidance 3 and an answer window of 12 slots.
from juice.pipeline import SHORT_ANSWER, JuicePipeline
pipe = JuicePipeline.from_pretrained("CedLJH/JUICE-2B-SigLIP2", device="cuda")
# Text to image: a list of PIL images (224 x 224)
images = pipe.text_to_image("a red bicycle next to a blue door", num_images=4, seed=0)
images[0].save("bicycle.png")
# Question answering: one question for each image (a file path or a PIL image)
answers = pipe.answer(["photo.jpg"], [f"What color is the door?\n{SHORT_ANSWER}"])
print(answers[0])We do not release the planning models.
docs/PLANNING.md tells you how to make the data, fine-tune an SFT model, train the task head and export
a planning model. Then this command solves one puzzle and writes the solved image:
python -m scripts.inference.plan --model my-jmaze-siglip2 --puzzles data/jmaze/test_id.jsonl \
--index 0 --out maze0.pngJUICE has three training stages. One trainer (scripts/train/train.py) does all stages.
One YAML file in configs/train/ holds the settings of one run of the paper.
| Stage | Configs | Starts from | Steps | Global batch | Paper GPUs |
|---|---|---|---|---|---|
| 1. Pretraining | pretrain_siglip2.yaml, pretrain_dino.yaml |
random initialization | 60,000 | 4,096 | 8 |
| 2. SFT | sft_siglip2.yaml, sft_dino.yaml |
stage 1, step 60,000 | 15,000 | 1,024 | 8 |
| 3. Task fine-tune | jmaze_siglip2.yaml, jmaze_dino.yaml, vsp_siglip2.yaml |
stage 2, step 15,000 | 5,000 | 1,024 | 8 (VSP: 4) |
Each GPU must have 80 GB of memory. The text head (question answering) and the task head (planning) have their own trainers. Each uses one GPU.
We do not distribute the training data. You download the public datasets and run our scripts.
-
Download the datasets:
docs/DATA.md, section 2 (approximately 6.3 TB). -
Build the WebDataset packs and the manifests (approximately 2.1 TB more):
STEP=all JOBS=16 bash scripts/data/prepare_data.sh
The configs read the manifests in data/manifests/.
At the end, the script compares the row counts of the packs with the counts of the paper runs.
torchrun --nproc_per_node 8 scripts/train/train.py --config configs/train/pretrain_siglip2.yamlFor WebSSL-DINO, use configs/train/pretrain_dino.yaml.
The trainer writes to outputs/train/<run_name>/:
config.json (the settings), log.jsonl (loss and learning rate, every 50 steps)
and checkpoints/checkpoint_<step>.pt.
torchrun --nproc_per_node 8 scripts/train/train.py --config configs/train/sft_siglip2.yamlThe config starts from the raw weights of your stage-1 run at step 60,000
(outputs/train/pretrain_siglip2/checkpoints/checkpoint_060000.pt).
To start from a released Base model, give its folder:
torchrun --nproc_per_node 8 scripts/train/train.py --config configs/train/sft_siglip2.yaml \
--set init_from=/path/to/JUICE-2B-SigLIP2-BaseThe released folders hold EMA weights, not raw weights. Thus the result can be slightly different from the paper.
docs/PLANNING.md, section 2, gives the data, the fine-tune, the task head and the export of a planning model.
The text head reads the answer text from the text states. It trains alone, on the texts of the pretraining data, and it does not use the JUICE model. It has two stages of 8,000 steps (approximately 1.3 hours each on one A100 GPU):
python scripts/train/train_text_head.py --config configs/train/text_head.yamlThe released head is outputs/train/text_head/stage_2.
One head serves the SigLIP2 and the WebSSL-DINO models.
The inference scripts read a model folder. To make one from a checkpoint, export one weight set
(the paper evaluated ema_fast) and add the text head:
python -m juice.export --checkpoint outputs/train/sft_siglip2/checkpoints/checkpoint_015000.pt \
--weights ema_fast --text-head outputs/train/text_head/stage_2 --out my-sft-siglip2
python -m scripts.inference.text_to_image --model my-sft-siglip2 \
--prompt "a red bicycle next to a blue door" --out test-
Number of GPUs. The global batch is
micro_batch_size(8) xgrad_accum_stepsx number of GPUs. It must be equal tobatch_size. For a different number of GPUs, changegrad_accum_steps. For example, SFT on 4 GPUs:torchrun --nproc_per_node 4 scripts/train/train.py --config configs/train/sft_siglip2.yaml \ --set grad_accum_steps=32 -
Other settings.
--set key=valuereplaces a config key (the values are YAML), for example--set output_dir=/scratch/juice num_workers=4. -
Continue a run.
--resumeloads the weights, the EMA copies, the optimizer state and the step:torchrun --nproc_per_node 8 scripts/train/train.py --config configs/train/pretrain_siglip2.yaml \ --resume outputs/train/pretrain_siglip2/checkpoints/checkpoint_030000.pt
docs/TRAIN.md gives all the settings, the checkpoint contents and our reproducibility checks.
| Benchmark | Guide |
|---|---|
| GenEval, DPG-Bench | docs/EVAL_T2I.md |
| VQAv2, OK-VQA, VizWiz, POPE, MME, GQA, MMBench, AI2D, MMMU, ScienceQA-IMG, RealWorldQA | docs/EVAL_VQA.md |
| JMaze, VSP | docs/PLANNING.md |
Each guide gives the data downloads, the commands and the expected numbers.
| Guide | Content |
|---|---|
docs/INSTALL.md |
environment, downloads, use without a network connection, tested versions |
docs/MODEL_ZOO.md |
released models, folder contents, inference settings, results |
docs/DATA.md |
training data: downloads, packs, manifests, checks |
docs/TRAIN.md |
all training stages, text head, task head, checkpoints |
docs/EVAL_T2I.md |
GenEval and DPG-Bench |
docs/EVAL_VQA.md |
question-answering benchmarks |
docs/PLANNING.md |
JMaze and VSP: data, fine-tune, evaluation |
JUICE-Code/
├── juice/ # the Python package
│ ├── model.py # MM-RiT
│ ├── sampling.py # samplers: text to image, question answering, joint generation
│ ├── pipeline.py # JuicePipeline (inference API)
│ ├── representations.py # frozen encoders: SigLIP2, WebSSL-DINO, Flan-T5-Small
│ ├── rae_decoder.py # frozen image decoders
│ ├── heads.py # text head and task head
│ ├── export.py # checkpoint to model folder
│ ├── train/ # trainer, loss, data loader, head trainers
│ ├── eval/ # benchmark scoring
│ └── tasks/ # JMaze and VSP
├── scripts/
│ ├── inference/ # text_to_image.py, answer.py, plan.py
│ ├── train/ # train.py, train_text_head.py, train_task_head.py
│ ├── eval/ # benchmark generation and scoring
│ ├── data/ # training data preparation
│ └── export_planning.py # checkpoint to planning model folder
├── configs/train/ # one YAML file for each run of the paper
├── docs/ # guides
└── tests/ # unit tests (CPU)
- Code: MIT License (
LICENSE). - Model weights: CC BY-NC 4.0.
- Third-party components keep their own licenses. See
THIRD_PARTY_LICENSES.md.
@article{li2026juice,
title = {{JUICE}: Unified Multimodal Modeling in Pretrained Representation Spaces},
author = {Li, Jiahan and Su, Huangyuan and Tong, Shengbang and Yang, Shusheng and
Guo, Ruihan and Huang, Suozhi and Zhao, Hexu and Sharma, Pratyusha and
Yang, Sherry and Gu, Jiatao and Fergus, Rob and Cho, Kyunghyun},
journal = {arXiv preprint arXiv:2610.28801},
year = {2026}
}This code uses parts of Scale-RAE (image decoders) and MiniT2I. The frozen encoders are SigLIP2, WebSSL-DINO and Flan-T5. We thank the authors of GenEval, DPG-Bench, lmms-eval and VSP for their benchmarks.