Intel / llava-llama-3-8b

huggingface.co
Total runs: 1.3K
24-hour runs: 0
7-day runs: 0
30-day runs: 0
Model's Last Updated: July 01 2024
image-text-to-text

Introduction of llava-llama-3-8b

Model Details of llava-llama-3-8b

Model Details: LLaVA-llama-3-8B

llava-llama-3-8b is a large multimodal model (LMM) trained using the LLaVA-v1.5 framework with the 8-billion parameter meta-llama/Meta-Llama-3-8B-Instruct model as language backbone and the CLIP-based vision encoder.

Model Details Description
Authors Intel: Musashi Hinck* , Matthew L. Olson* , Vasudev Lal
Date May 2024
Version 1
Type Large multimodal model (LMM)
Paper or Other Resources Improved Baselines with Visual Instruction Tuning
License Intel Research Use License
Questions or Comments Community Tab and Intel DevHub Discord

This model card was created by Eduardo Alvarez and the authors listed above.

Intended Use
Intended Use Description
Primary intended uses The model has been finetuned for multimodal benchmark evaluations, but can also be used as a multimodal chatbot.
Primary intended users Anyone using or evaluating multimodal models.
Out-of-scope uses This model is not intended for uses that require high levels of factuality, high stakes situations, mental health or medical applications, generating misinformation or disinformation, impersonating others, facilitating or inciting harassment or violence, any use that could lead to the violation of a human right under the UN Declaration of Human Rights.
How to use

Please note, we only provide the trained weights difference and do not provide a copy of the base meta-llama/Meta-Llama-3-8B-Instruct model. Any use of these weights requires a separate download of the base model.

# Copyright 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

import requests
import torch
from PIL import Image
from transformers import AutoProcessor, AutoModelForPreTraining
import transformers

def expand2square(pil_img, background_color):
    width, height = pil_img.size
    if width == height:
        return pil_img
    elif width > height:
        result = Image.new(pil_img.mode, (width, width), background_color)
        result.paste(pil_img, (0, (width - height) // 2))
        return result
    else:
        result = Image.new(pil_img.mode, (height, height), background_color)
        result.paste(pil_img, ((height - width) // 2, 0))
        return result

def add_model_a_to_b(model_a, model_b):
    state_dict_a = model_a.state_dict()
    state_dict_b = model_b.state_dict()

    # Ensure keys match before subtraction
    if set(state_dict_a.keys()) != set(state_dict_b.keys()):
        raise ValueError("Model state dicts do not have the same keys.")

    for key in state_dict_a:
        if state_dict_a[key].shape != state_dict_b[key].shape:
            raise ValueError(f"Shape mismatch for key '{key}': {state_dict_a[key].shape} vs {state_dict_b[key].shape}")
        # Subtract model_a's weights from model_b for the matching key
        state_dict_b[key] = state_dict_b[key] + state_dict_a[key]

    # Update model_b with the new weights
    model_b.load_state_dict(state_dict_b)

output_checkpoint = "" # set if you don't want to merge every time
hf_checkpoint = "Intel/llava-llama-3-8b"
device = "cuda" if torch.cuda.is_available() else "cpu"

processor = AutoProcessor.from_pretrained(hf_checkpoint)
model = AutoModelForPreTraining.from_pretrained(hf_checkpoint)
if model.language_model.model.embed_tokens.weight[-1].sum() == 0:
    print("adding llama3 weights")
    model_id = "meta-llama/Meta-Llama-3-8B-Instruct"
    pipeline = transformers.pipeline(
        "text-generation",
        model=model_id,
        model_kwargs={"torch_dtype": torch.bfloat16},
        device_map="cpu",
    )
    llama3 = pipeline.model
    add_model_a_to_b(llama3, model.language_model)
    if output_checkpoint:
        print("saving weights, so no adding is needed again")
        model.save_pretrained(output_checkpoint)

device = "cuda" if torch.cuda.is_available() else "cpu"
model.to(device)

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)

#original llava pads with mean, HF llava pads with zeros
image = expand2square(image, tuple(int(x*255) for x in processor.image_processor.image_mean)) 
inputs = processor(text=prompt, images=image, return_tensors="pt").to(device)
# 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)
Factors
Factors Description
Environment Trained on a 4 node cluster with a total of 32 Gaudi 2 accelerators
Card Prompts Model training and deployment on alternate hardware and software will change model performance
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.
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.

Ethical Considerations Description
Data The model was trained using the LLaVA-v1.5 data mixture as described above.
Human life The model is not intended to inform decisions central to human life or flourishing.
Mitigations No additional risk mitigation strategies were considered during model development.
Risks and harms This model has not been assessed for harm or biases, and should not be used for sensitive applications where it may cause harm.
Use cases -
Caveats and Recommendations

Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. This model has not been assessed for harm or biases, and should not be used for sensitive applications where it may cause harm.

Runs of Intel llava-llama-3-8b on huggingface.co

1.3K
Total runs
0
24-hour runs
0
3-day runs
0
7-day runs
0
30-day runs

More Information About llava-llama-3-8b huggingface.co Model

llava-llama-3-8b huggingface.co

llava-llama-3-8b huggingface.co is an AI model on huggingface.co that provides llava-llama-3-8b's model effect (), which can be used instantly with this Intel llava-llama-3-8b model. huggingface.co supports a free trial of the llava-llama-3-8b model, and also provides paid use of the llava-llama-3-8b. Support call llava-llama-3-8b model through api, including Node.js, Python, http.

llava-llama-3-8b huggingface.co Url

https://huggingface.co/Intel/llava-llama-3-8b

Intel llava-llama-3-8b online free

llava-llama-3-8b huggingface.co is an online trial and call api platform, which integrates llava-llama-3-8b's modeling effects, including api services, and provides a free online trial of llava-llama-3-8b, you can try llava-llama-3-8b online for free by clicking the link below.

Intel llava-llama-3-8b online free url in huggingface.co:

https://huggingface.co/Intel/llava-llama-3-8b

llava-llama-3-8b install

llava-llama-3-8b is an open source model from GitHub that offers a free installation service, and any user can find llava-llama-3-8b on GitHub to install. At the same time, huggingface.co provides the effect of llava-llama-3-8b install, users can directly use llava-llama-3-8b installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

llava-llama-3-8b install url in huggingface.co:

https://huggingface.co/Intel/llava-llama-3-8b

Url of llava-llama-3-8b

llava-llama-3-8b huggingface.co Url

Provider of llava-llama-3-8b huggingface.co

Intel
ORGANIZATIONS

Other API from Intel

huggingface.co

Total runs: 787.0K
Run Growth: 466.6K
Growth Rate: 59.33%
Updated:February 09 2024
huggingface.co

Total runs: 41.5K
Run Growth: -2.4K
Growth Rate: -5.73%
Updated:February 24 2024
huggingface.co

Total runs: 27.4K
Run Growth: 5.2K
Growth Rate: 19.02%
Updated:March 29 2024
huggingface.co

Total runs: 11.1K
Run Growth: -850
Growth Rate: -7.69%
Updated:February 24 2025
huggingface.co

Total runs: 2.4K
Run Growth: -891
Growth Rate: -37.52%
Updated:March 26 2024
huggingface.co

Total runs: 1.5K
Run Growth: 284
Growth Rate: 18.92%
Updated:May 20 2024