/ Модель

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

Параметры
101 млн
Лицензия
MIT
Опубликована
11 фев 2023

bridgetower-large-itm-mlm-itc

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

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

56 388скачиваний за 30 дней12лайковвеса обновлены8 мар 2023

Бенчмарки

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

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

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

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

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

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

BridgeTower large-itm-mlm-itc — модель для обучения совместных представлений изображений и текста, разработанная Xiao Xu, Chenfei Wu, Shachar Rosenman, Vasudev Lal, Wanxiang Che и Nan Duan. Она использует архитектуру BridgeTower с визуальным и текстовым энкодерами, соединёнными несколькими мостовыми слоями для согласования и объединения представлений разных уровней. В модели около 100,7 млн параметров.

Модель предварительно обучена на английском языке с задачами masked language modeling и image-text matching на наборах Conceptual Captions, Conceptual 12M, SBU Captions, MSCOCO Captions и Visual Genome. Она предназначена для получения и сопоставления представлений изображений и текстов, поиска изображений по описанию и других задач vision-language; в статье также приводятся результаты для визуальных вопросов и ответов. Репозиторий содержит веса PyTorch. Лицензия — MIT.

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

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

Ограничения

Предварительное обучение ориентировано на английский язык и пары изображений с текстовыми подписями; README не описывает ограничения по качеству или безопасному применению.

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

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

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

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

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

Открыть на Hugging Face

BridgeTower large-itm-mlm-itc model

The BridgeTower model was proposed in "BridgeTower: Building Bridges Between Encoders in Vision-Language Representative Learning" by Xiao Xu, Chenfei Wu, Shachar Rosenman, Vasudev Lal, Wanxiang Che, Nan Duan. The model was pretrained on English language using masked language modeling (MLM) and image text matching (ITM)objectives. It was introduced in this paper and first released in this repository.

BridgeTower got accepted to AAAI'23.

Model description

The abstract from the paper is the following: Vision-Language (VL) models with the Two-Tower architecture have dominated visual-language representation learning in recent years. Current VL models either use lightweight uni-modal encoders and learn to extract, align and fuse both modalities simultaneously in a deep cross-modal encoder, or feed the last-layer uni-modal representations from the deep pre-trained uni-modal encoders into the top cross-modal encoder. Both approaches potentially restrict vision-language representation learning and limit model performance. In this paper, we propose BridgeTower, which introduces multiple bridge layers that build a connection between the top layers of uni-modal encoders and each layer of the cross-modal encoder. This enables effective bottom-up cross-modal alignment and fusion between visual and textual representations of different semantic levels of pre-trained uni-modal encoders in the cross-modal encoder. Pre-trained with only 4M images, BridgeTower achieves state-of-the-art performance on various downstream vision-language tasks. In particular, on the VQAv2 test-std set, BridgeTower achieves an accuracy of 78.73%, outperforming the previous state-of-the-art model METER by 1.09% with the same pre-training data and almost negligible additional parameters and computational costs. Notably, when further scaling the model, BridgeTower achieves an accuracy of 81.15%, surpassing models that are pre-trained on orders-of-magnitude larger datasets.

Intended uses & limitations

How to use

Here is how to use this model to perform contrastive learning between image and text pairs:

from transformers import BridgeTowerProcessor, BridgeTowerForContrastiveLearning
import requests
from PIL import Image
import torch

image_urls = [
    "https://farm4.staticflickr.com/3395/3428278415_81c3e27f15_z.jpg",
    "http://images.cocodataset.org/val2017/000000039769.jpg"]
texts = [
    "two dogs in a car",
    "two cats sleeping on a couch"]
images = [Image.open(requests.get(url, stream=True).raw) for url in image_urls]

processor = BridgeTowerProcessor.from_pretrained("BridgeTower/bridgetower-large-itm-mlm")
model = BridgeTowerForContrastiveLearning.from_pretrained("BridgeTower/bridgetower-large-itm-mlm-itc")

inputs  = processor(images, texts, padding=True, return_tensors="pt")
outputs = model(**inputs)

inputs  = processor(images, texts[::-1], padding=True, return_tensors="pt")
outputs_swapped = model(**inputs)

print('Loss', outputs.loss.item())
# Loss 0.00191505195107311
print('Loss with swapped images', outputs_swapped.loss.item())
# Loss with swapped images 2.1259872913360596 

Here is how to use this model to perform image and text matching

from transformers import BridgeTowerProcessor, BridgeTowerForImageAndTextRetrieval
import requests
from PIL import Image

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
texts = ["An image of two cats chilling on a couch", "A football player scoring a goal"]

processor = BridgeTowerProcessor.from_pretrained("BridgeTower/bridgetower-large-itm-mlm-gaudi")
model = BridgeTowerForImageAndTextRetrieval.from_pretrained("BridgeTower/bridgetower-large-itm-mlm-gaudi")

# forward pass
scores = dict()
for text in texts:
    # prepare inputs
    encoding = processor(image, text, return_tensors="pt")
    outputs = model(**encoding)
    scores[text] = outputs.logits[0,1].item()

Here is how to use this model to perform masked language modeling:

from transformers import BridgeTowerProcessor, BridgeTowerForMaskedLM
from PIL import Image
import requests

url = "http://images.cocodataset.org/val2017/000000360943.jpg"
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
text = "a <mask> looking out of the window"

processor = BridgeTowerProcessor.from_pretrained("BridgeTower/bridgetower-large-itm-mlm-gaudi")
model = BridgeTowerForMaskedLM.from_pretrained("BridgeTower/bridgetower-large-itm-mlm-gaudi")

# prepare inputs
encoding = processor(image, text, return_tensors="pt")

# forward pass
outputs = model(**encoding)

results = processor.decode(outputs.logits.argmax(dim=-1).squeeze(0).tolist())

print(results)
#.a cat looking out of the window.

Training data

The BridgeTower model was pretrained on four public image-caption datasets:

The total number of unique images in the combined data is around 14M.

Training procedure

Pretraining

The model was pre-trained for 10 epochs on an Intel AI supercomputing cluster using 512 Gaudis and 128 Xeons with a batch size of 2048. The optimizer used was AdamW with a learning rate of 1e-7. No data augmentation was used except for center-crop. The image resolution in pre-training is set to 294 x 294.

Evaluation results

Please refer to Table 5 for BridgeTower's performance on Image Retrieval and other downstream tasks.

BibTeX entry and citation info

@article{xu2022bridge,
  title={BridgeTower: Building Bridges Between Encoders in Vision-Language Representation Learning},
  author={Xu, Xiao and Wu, Chenfei and Rosenman, Shachar and Lal, Vasudev and Che, Wanxiang and Duan, Nan},
  journal={arXiv preprint arXiv:2206.08657},
  year={2022}
}

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

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

GPU в ailist

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

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

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

Ревизия весов
0e15d64

0 моделей