/ Модель

Характеристики

Контекст
131 072 токена
Размер весов
17,9 ГБ
Архитектура
llava · dense
Базовая модель
Llama-3.1-8B-Instruct
Опубликована
8 окт 2024

llama-joycaption-alpha-two-hf-llava

Языковая модель4 профессии

Визуально-языковая модель JoyCaption на базе LLaVA для автоматического создания текстовых описаний изображений, в том числе для подготовки данных обучения диффузионных моделей.

24 402скачиваний за 30 дней218лайковвеса обновлены29 ноя 2024

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

Llama JoyCaption Alpha Two — визуально-языковая модель семейства LLaVA, разработанная проектом JoyCaption для автоматического описания изображений. Она предназначена прежде всего для создания подробных текстовых подписей к изображениям и подготовки описаний для обучения и дообучения диффузионных моделей. В README модель заявлена как открытая и ориентированная на широкий спектр визуальных стилей и тем; пример запуска через vLLM ограничивает длину последовательности 4096 токенами.

Модель объединяет SigLIP SO400M Patch14 384 и Llama 3.1 8B Instruct. Она принимает изображения и текстовые запросы и генерирует текстовые описания. Карточка заявляет охват как обычного, так и откровенного контента. Доступны веса в формате safetensors; README указывает на GitHub как источник инструкций по запуску, но не называет лицензию, поэтому условия использования весов по этим данным определить нельзя.

Модель рассчитана на автоматизацию аннотирования изображений и может применяться для разных стилей, включая цифровое искусство, фотореализм и аниме. README предупреждает, что запуск через vLLM может требовать настройки параметров памяти и режима выполнения. Заявления о качестве относительно GPT-4o приведены разработчиком и не сопровождаются здесь независимыми результатами оценки.

Сценарии применения

  • создание подписей к изображениям для датасетов
  • подготовка описаний изображений для обучения диффузионных моделей
  • аннотирование цифрового искусства и иллюстраций
  • описание фотографий и сцен
  • создание подписей к изображениям в стиле аниме

Ограничения

Для работы через vLLM может потребоваться настройка памяти и параметров выполнения; приведённый в README предел max-model-len составляет 4096 токенов. Лицензия в предоставленных материалах не указана.

Для каких профессий подходит4

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

Model Card for Llama JoyCaption Alpha Two

Github

JoyCaption is an image captioning Visual Language Model (VLM) being built from the ground up as a free, open, and uncensored model for the community to use in training Diffusion models.

Key Features:

  • Free and Open: It will be released for free, open weights, no restrictions, and just like bigASP, will come with training scripts and lots of juicy details on how it gets built.
  • Uncensored: Equal coverage of SFW and NSFW concepts. No "cylindrical shaped object with a white substance coming out on it" here.
  • Diversity: All are welcome here. Do you like digital art? Photoreal? Anime? Furry? JoyCaption is for everyone. Pains are being taken to ensure broad coverage of image styles, content, ethnicity, gender, orientation, etc.
  • Minimal Filtering: JoyCaption is trained on large swathes of images so that it can understand almost all aspects of our world. almost. Illegal content will never be tolerated in JoyCaption's training.

Motivation

Automated descriptive captions enable the training and finetuning of diffusion models on a wider range of images, since trainers are no longer required to either find images with already associated text or write the descriptions themselves. They also improve the quality of generations produced by Text-to-Image models trained on them (ref: DALL-E 3 paper). But to-date, the community has been stuck with ChatGPT, which is expensive and heavily censored; or alternative models, like CogVLM, which are weaker than ChatGPT and have abysmal performance outside of the SFW domain.

I'm building JoyCaption to help fill this gap by performing near or on-par with GPT4o in captioning images, while being free, unrestricted, and open.

How to Get Started with the Model

Please see the Github for more details.

Example usage:

import torch
from PIL import Image
from transformers import AutoProcessor, LlavaForConditionalGeneration


IMAGE_PATH = "image.jpg"
PROMPT = "Write a long descriptive caption for this image in a formal tone."
MODEL_NAME = "fancyfeast/llama-joycaption-alpha-two-hf-llava"


# Load JoyCaption
# bfloat16 is the native dtype of the LLM used in JoyCaption (Llama 3.1)
# device_map=0 loads the model into the first GPU
processor = AutoProcessor.from_pretrained(MODEL_NAME)
llava_model = LlavaForConditionalGeneration.from_pretrained(MODEL_NAME, torch_dtype="bfloat16", device_map=0)
llava_model.eval()

with torch.no_grad():
	# Load image
	image = Image.open(IMAGE_PATH)

	# Build the conversation
	convo = [
		{
			"role": "system",
			"content": "You are a helpful image captioner.",
		},
		{
			"role": "user",
			"content": PROMPT,
		},
	]

	# Format the conversation
	# WARNING: HF's handling of chat's on Llava models is very fragile.  This specific combination of processor.apply_chat_template(), and processor() works
	# but if using other combinations always inspect the final input_ids to ensure they are correct.  Often times you will end up with multiple <bos> tokens
	# if not careful, which can make the model perform poorly.
	convo_string = processor.apply_chat_template(convo, tokenize = False, add_generation_prompt = True)
	assert isinstance(convo_string, str)

	# Process the inputs
	inputs = processor(text=[convo_string], images=[image], return_tensors="pt").to('cuda')
	inputs['pixel_values'] = inputs['pixel_values'].to(torch.bfloat16)

	# Generate the captions
	generate_ids = llava_model.generate(
		**inputs,
		max_new_tokens=300,
		do_sample=True,
		suppress_tokens=None,
		use_cache=True,
		temperature=0.6,
		top_k=None,
		top_p=0.9,
	)[0]

	# Trim off the prompt
	generate_ids = generate_ids[inputs['input_ids'].shape[1]:]

	# Decode the caption
	caption = processor.tokenizer.decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)
	caption = caption.strip()
	print(caption)

vLLM

vLLM provides the highest performance inference for JoyCaption, and an OpenAI compatible API so JoyCaption can be used like any other VLMs. Example usage:

vllm serve fancyfeast/llama-joycaption-alpha-two-hf-llava --max-model-len 4096 --enable-prefix-caching

VLMs are a bit finicky on vLLM, and vLLM is memory hungry, so you may have to adjust settings for your particular environment, such as forcing eager mode, adjusting max-model-len, adjusting gpu_memory_utilization, etc.

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм

Нельзя запустить

У модели не указана задача.

Класс архитектуры
LlavaForConditionalGeneration
Ревизия весов
de9952a

0 моделей