CoolFace
Modelpublic

unum-cloud/uform3-image-text-multilingual-base

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
17likes6.5kdownloads
Model Card

<h1 align="center">UForm</h1> <h3 align="center"> Pocket-Sized Multimodal AI<br/> For Content Understanding and Generation<br/> In Python, JavaScript, and Swift<br/> </h3>


The uform3-image-text-multilingual-base UForm model is a tiny vision and multilingual language encoder, covering _21 languages, mapping them into a shared vector space. This model produces up to 256-dimensional embeddings_ and is made of:

  • Text encoder: 12-layer BERT for up to 50 input tokens.
  • Visual encoder: ViT-B/16 for images of 224 x 224 resolution.

Unlike most CLIP-like multomodal models, this model shares 4 layers between the text and visual encoder to allow for more data- and parameter-efficient training. Also unlike most models, UForm provides checkpoints compatible with PyTorch, ONNX, and CoreML, covering the absolute majority of AI-capable devices, with pre-quantized weights and inference code. If you need a larger, more accurate, or multilingual model, check our HuggingFace Hub. For more details on running the model, check out the UForm GitHub repository.

Evaluation

For all evaluations, the multimodal part was used unless otherwise stated.

Monolingual

DatasetRecall@1Recall@5Recall@10
Zero-Shot Flickr0.5580.8130.874
MS-COCO ¹0.4010.6800.781
¹ It's important to note, that the MS-COCO train split was present in the training data.

Multilingual

Recall@10 on the XTD-10 dataset:

EnglishGermanSpanishFrenchItalianRussianJapaneseKoreanTurkishChinesePolish
96.193.595.794.194.490.490.291.395.293.895.8

Recall@1, Recall@5, and Recall@10 on the COCO-SM dataset:

Target LanguageOpenCLIP @ 1UForm @ 1OpenCLIP @ 5UForm @ 5OpenCLIP @ 10UForm @ 10Speakers
Arabic22.731.744.957.855.869.2274 M
Armenian5.622.014.344.720.256.04 M
Chinese27.332.251.359.062.170.51'118 M
English37.837.763.565.073.575.91'452 M
French31.335.456.562.667.473.3274 M
German31.735.156.962.267.473.3134 M
Hebrew23.726.746.351.857.063.59 M
Hindi20.731.342.557.953.769.6602 M
Indonesian26.930.751.457.062.768.6199 M
Italian31.334.956.762.167.173.167 M
Japanese27.432.651.559.262.670.6125 M
Korean24.431.548.157.859.269.281 M
Persian24.028.847.054.657.866.277 M
Polish29.233.653.960.164.771.341 M
Portuguese31.632.757.159.667.971.0257 M
Russian29.933.954.860.965.872.0258 M
Spanish32.635.658.062.868.873.7548 M
Thai21.528.743.054.653.766.061 M
Turkish25.533.049.159.660.370.888 M
Ukranian26.030.649.956.760.968.141 M
Vietnamese25.428.349.253.960.365.585 M
Mean26.5±6.431.8±3.549.8±9.858.1±4.560.4±10.669.4±4.3-
Google Translate27.4±6.331.5±3.551.1±9.557.8±4.461.7±10.369.1±4.3-
Microsoft Translator27.2±6.431.4±3.650.8±9.857.7±4.761.4±10.668.9±4.6-
Meta NLLB24.9±6.732.4±3.547.5±10.358.9±4.558.2±11.270.2±4.3-

For a deeper comparison of output ranking check the following table for the Normalized Discounted Cumulative Gains for the first 20 results - NDCG@20:

ArabicArmenianChineseFrenchGermanHebrewHindiIndonesianItalianJapaneseKoreanPersianPolishPortugueseRussianSpanishThaiTurkishUkranianVietnameseMean (all)Mean (Google Translate)Mean(Microsoft Translator)Mean(NLLB)
OpenCLIP NDCG0.6390.2040.7310.8230.8060.6570.6160.7330.8110.7370.6860.6670.7640.8320.7770.8490.6060.7010.7040.6970.716 ± 0.1490.732 ± 0.1450.730 ± 0.1490.686 ± 0.158
UForm NDCG0.8680.6910.8800.9320.9270.7910.8790.8700.9300.8850.8690.8310.8970.8970.9060.9390.8220.8980.8510.8180.875 ± 0.0640.869 ± 0.0630.869 ± 0.0660.888 ± 0.064

Installation

bash
pip install "uform[torch,onnx]"

Usage

To load the model:

python
from uform import get_model, Modality

import requests
from io import BytesIO
from PIL import Image

model_name = 'unum-cloud/uform3-image-text-multilingual-base'
modalities = [Modality.TEXT_ENCODER, Modality.IMAGE_ENCODER]
processors, models = get_model(model_name, modalities=modalities)

model_text = models[Modality.TEXT_ENCODER]
model_image = models[Modality.IMAGE_ENCODER]
processor_text = processors[Modality.TEXT_ENCODER]
processor_image = processors[Modality.IMAGE_ENCODER]

To encode the content:

python
text = 'a cityscape bathed in the warm glow of the sun, with varied architecture and a towering, snow-capped mountain rising majestically in the background'
image_url = 'https://media-cdn.tripadvisor.com/media/photo-s/1b/28/6b/53/lovely-armenia.jpg'
image_url = Image.open(BytesIO(requests.get(image_url).content))

image_data = processor_image(image)
text_data = processor_text(text)
image_features, image_embedding = model_image.encode(image_data, return_features=True)
text_features, text_embedding = model_text.encode(text_data, return_features=True)