TinyLLaVA Factory: A Modularized Codebase for Small-scale Large Multimodal Models

Junlong Jia, Ying Hu, Xi Weng, Yiming Shi, Miao Li, Xingjian Zhang, Baichuan Zhou, Ziyu Liu, Jie Luo, Lei Huang, Ji WuarXiv 2024 · DOI

Abstract

TinyLLaVA Factory is an open-source, modular codebase designed to simplify the development and training of small-scale Large Multimodal Models (LMMs). By applying the "factory" software design pattern, it allows researchers to easily swap out vision towers, language models, and connectors, making high-performance multimodal AI accessible even with limited computational resources.

Introduction

Building Large Multimodal Models (LMMs) is traditionally a complex, resource-heavy endeavor. Practitioners often face two major hurdles: the complexity and rigidity of monolithic codebases, and the massive computational barriers required for training state-of-the-art models. Existing frameworks often tightly couple vision and language components, making experimentation with alternative architectures error-prone and difficult.

To democratize LMM research, we introduce TinyLLaVA Factory, a modular, reproducible framework specifically optimized for models in the 450M to 2.7B parameter range. This codebase enables researchers to explore efficient architectures without the need for industrial-scale GPU clusters.

Methods

The core innovation of TinyLLaVA Factory is the application of the Factory Design Pattern to the LMM pipeline. The system is decomposed into five interchangeable modules:

  • Data: Standardized preprocessing for images and text, including diverse chat templates.
  • Model: Modularized into the Vision Tower (e.g., CLIP, SigLIP), the Connector (e.g., MLP, Q-former), and the LLM (e.g., Phi-2, Gemma).
  • Training Recipe: Manages training stages, defining frozen vs. tuned parameters and PEFT methods like LoRA/QLoRA.
  • Trainer: Leverages Hugging Face and DeepSpeed for efficient training features like gradient accumulation and ZeRO optimization.
  • Evaluator: A standardized suite for benchmarking across various multimodal tasks.
The modular architecture of TinyLLaVA Factory, illustrating the 'factory' design pattern applied to data, models, and training components.

This "plug-and-play" architecture allows users to define new model variants via configuration files, significantly reducing the need for custom logic implementation.

Key Results and Insights

Models were trained using the LLaVA-1.5 dataset for the "base" recipe and ShareGPT4V for the "share" recipe. Evaluation spanned standard benchmarks including Image Question Answering (VQA-v2, GQA, SQA, TextVQA) and comprehensive suites (MM-Vet, POPE, MME, MMMU).

Performance comparison of various Vision Tower (VT) and LLM combinations across multiple benchmarks.

Several key insights emerged from the experimental results:

  • The Power of Small Models: Models under 3B parameters achieve highly competitive results. Notably, the Phi-2-2.7B variant outperforms many larger models on reasoning-heavy benchmarks like MMMU.
  • Superiority of SigLIP: Across all tested LLM backbones, switching from the standard OpenAI CLIP vision tower to Google's SigLIP resulted in a consistent performance boost.
  • Top Performance: The Phi-2-2.7B model using SigLIP and the "share" training recipe achieved state-of-the-art performance for its size class, scoring 80.1 on VQAv2 and 38.4 on MMMU-val.
  • Efficiency: Even the smallest model, OpenELM-450M, achieved a respectable 71.7 on VQAv2 when paired with SigLIP, proving that multimodal capabilities can be squeezed into extremely small footprints.

Conclusion

TinyLLaVA Factory provides a robust foundation for small-scale LMM research by prioritizing modularity and code quality. While currently focused on models up to 2.7B parameters, the framework is designed to be extensible. Future work will include the integration of more advanced fine-tuning techniques and a broader catalog of state-of-the-art small LLMs and vision encoders.

Summary updated

BibTeX
@misc{jia2024tinyllava,
  author = {Junlong Jia and Ying Hu and Xi Weng and Yiming Shi and Miao Li and Xingjian Zhang and Baichuan Zhou and Ziyu Liu and Jie Luo and Lei Huang and Ji Wu},
  title = {{TinyLLaVA Factory: A Modularized Codebase for Small-scale Large Multimodal Models}},
  year = {2024},
  eprint = {2405.11788},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.11788},
}
Figure