Intel/llava-gemma-7b
Model Details: LLaVA-Gemma-7b
llava-gemma-7b is a large multimodal model (LMM) trained using the LLaVA-v1.5 framework with the 7-billion parameter google/gemma-7b-it model as language backbone and the CLIP-based vision encoder.
_NOTE:_ As of 06/03/2024, we have not yet converted the weights of this model to the HuggingFace LLaVA format. This model card will be updated when we do.
This model card was created by Benjamin Consolvo and the authors listed above.
Intended Use
How to use
Currently, using llava-gemma requires a modified preprocessor. We are currently working on modifying the `LlavaProcessor` class to streamline usage (see [PR #30030](https://github.com/huggingface/transformers/pull/30030)). Expect updates soon.
For current usage, see `usage.py` or the following code block:
import requests
from PIL import Image
from transformers import (
LlavaForConditionalGeneration,
AutoTokenizer,
CLIPImageProcessor
)
from processing_llavagemma import LlavaGemmaProcessor # This is in this repo
checkpoint = "Intel/llava-gemma-7b"
# Load model
model = LlavaForConditionalGeneration.from_pretrained(checkpoint)
processor = LlavaGemmaProcessor(
tokenizer=AutoTokenizer.from_pretrained(checkpoint),
image_processor=CLIPImageProcessor.from_pretrained(checkpoint)
)
# Prepare inputs
# Use gemma chat template
prompt = processor.tokenizer.apply_chat_template(
[{'role': 'user', 'content': "<image>\nWhat's the content of the image?"}],
tokenize=False,
add_generation_prompt=True
)
url = "https://www.ilankelman.org/stopsigns/australia.jpg"
image = Image.open(requests.get(url, stream=True).raw)
inputs = processor(text=prompt, images=image, return_tensors="pt")
# Generate
generate_ids = model.generate(**inputs, max_length=30)
output = processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
print(output)For straightforward use as a chatbot (without images), you can modify the last portion of code to the following:
# Prepare inputs
# Use gemma chat template
prompt = processor.tokenizer.apply_chat_template(
[{'role': 'user', 'content': "Summarize the following paragraph? In this paper, we introduced LLaVA-Gemma, a compact vision-language model leveraging the Gemma Large Language Model in two variants, Gemma-2B and Gemma-7B. Our work provides a unique opportunity for researchers to explore the trade-offs between computational efficiency and multimodal understanding in small-scale models. The availability of both variants allows for a comparative analysis that sheds light on how model size impacts performance in various tasks. Our evaluations demonstrate the versatility and effectiveness of LLaVA-Gemma across a range of datasets, highlighting its potential as a benchmark for future research in small-scale vision-language models. With these models, future practitioners can optimize the performance of small-scale multimodal models more directly."}],
tokenize=False,
add_generation_prompt=True
)
# url = "https://www.ilankelman.org/stopsigns/australia.jpg"
# image = Image.open(requests.get(url, stream=True).raw)
inputs = processor(text=prompt, images=None, return_tensors="pt")
# Generate
generate_ids = model.generate(**inputs, max_length=300)
output = processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
print(output)Factors
Metrics
Training Data
The model was trained using the LLaVA-v1.5 data mixture. This is listed as follows:
- 558K filtered image-text pairs from LAION/CC/SBU, captioned by BLIP.
- 158K GPT-generated multimodal instruction-following data.
- 450K academic-task-oriented VQA data mixture.
- 40K ShareGPT data.
Quantitative Analyses
Performance of LLaVA-Gemma models across seven benchmarks. Highlighted box indicates strongest performance amongst LLaVA-Gemma models. Bottom two rows show self-reported performance of Llava Phi-2 and LLaVA-v1.5 respectively. The bolded gemma-7b-it is the current model used here in this model card.
Ethical Considerations
Intel is committed to respecting human rights and avoiding causing or contributing to adverse impacts on human rights. See Intel’s Global Human Rights Principles. Intel’s products and software are intended only to be used in applications that do not cause or contribute to adverse impacts on human rights.
Caveats and Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
Citation details
@misc{hinck2024llavagemma,
title={LLaVA-Gemma: Accelerating Multimodal Foundation Models with a Compact Language Model},
author={Musashi Hinck and Matthew L. Olson and David Cobbley and Shao-Yen Tseng and Vasudev Lal},
year={2024},
eprint={2404.01331},
url={https://arxiv.org/abs/2404.01331},
archivePrefix={arXiv},
primaryClass={cs.CL}
}