Blog AI

UForm v2: now in 21 languages

Releasing UForm v2 with support for 21 languages, delivering state-of-the-art efficiency in AI-based text-to-image search and multimodal embeddings.

By
Ash Vardanian
Published
Aug 17, 2023

A few months ago, we launched the inaugural version of UForm, the efficient Vision-Language Transformer AI model designed for search applications. It was uniquely trained on a balanced multi-lingual dataset spanning 12 languages to empower a wider range of applications all across the globe. Since then, weโ€™ve innovated with new techniques to cram even more learning capacity into our compact, cost-effective retrieval-oriented models. Hereโ€™s what UForm v2 brings to the table:

  • ๐ŸŒ Global Reach: UForm v2 speaks Armenian ๐Ÿ‡ฆ๐Ÿ‡ฒ and 20 popular languages: English ๐Ÿ‡บ๐Ÿ‡ธ, German ๐Ÿ‡ฉ๐Ÿ‡ช, French ๐Ÿ‡ซ๐Ÿ‡ท, Spanish ๐Ÿ‡ช๐Ÿ‡ธ, Portuguese ๐Ÿ‡ต๐Ÿ‡น, Italian ๐Ÿ‡ฎ๐Ÿ‡น, Polish ๐Ÿ‡ต๐Ÿ‡ฑ, Ukrainian ๐Ÿ‡บ๐Ÿ‡ฆ, Russian ๐Ÿ‡ท๐Ÿ‡บ, Turkish ๐Ÿ‡น๐Ÿ‡ท, Persian ๐Ÿ‡ฎ๐Ÿ‡ท, Hebrew ๐Ÿ‡ฎ๐Ÿ‡ฑ, Chinese ๐Ÿ‡จ๐Ÿ‡ณ, Vietnamese ๐Ÿ‡ป๐Ÿ‡ณ, Thai ๐Ÿ‡น๐Ÿ‡ญ, Indonesian ๐Ÿ‡ฎ๐Ÿ‡ฉ, Korean ๐Ÿ‡ฐ๐Ÿ‡ท, Japanese ๐Ÿ‡ฏ๐Ÿ‡ต, with some of the biggest gains in Arabic ๐Ÿ‡ธ๐Ÿ‡ฆ and Hindi ๐Ÿ‡ฎ๐Ÿ‡ณ.
  • ๐Ÿš€ Peak Performance: While the default OpenCLIP achieves a 73.5% recall (at 10) for English text-to-image search, UForm v2 hits 75.9% in English and exceeds 70% in 10 other languages.
  • โšก Streamlined Efficiency: Our model crafts embeddings that are half the size (256 dimensions vs. 512), doubling the speed of searches and recommendations. This boost is especially noticeable when paired with our USearch vector-search engine.
  • ๐Ÿ’ต Cost-Effective: UForm is open-source and optimized for cheaper and faster inference. In partnership with Graphcore, weโ€™ve fine-tuned UForm for model-parallelism, achieving 6x larger batch sizes and unparalleled throughput compared to conventional CLIP models.

Animation showcasing search bar input in different languages

Whatโ€™s a release without a demo to showcase it? Weโ€™ve melded StreamLit, USearch, and the latest UForm checkpoints with UCall for remote procedure calls. All of those projects are open-source, and free for commercial use, including the demo itself. Check them out on GitHub, jump to the evaluation results, or continue reading for more details.

ยง Training Methodology

  1. We amalgamated several mid-sized, high-quality datasets: MSCOCO, VG, SBU, CC.
  2. Captions were translated using NLLB, ensuring each image was paired with 21 distinct captions.
  3. We expanded on the contrastive pre-training concepts from our previous post, introducing new techniques to maintain cross-lingual attributes.

ยง Evaluation Dataset

MSCOCO stands out as the premier multi-modal retrieval evaluation dataset. However, sourcing its manual translations for popular languages is a challenge, and for many languages we target, itโ€™s an impossibility. Thus, we augmented the evaluation dataset synthetically. This time, we diversified our tools to minimize bias:

  • Google Translate API: $20 / 1 Million characters.
  • Microsoft Translator API: $10 / 1 Million characters.
  • Meta NLLB: Free, provided you have the hardware.

The variance between these three evaluation datasets was minimal. Access all translations and scripts to replicate our benchmarks on GitHub.

ยง Evaluation Results

When benchmarking models, we prioritize two core metrics. The first is recall. โ€œRecall @ ๐‘ฅโ€ essentially measures the likelihood (percentage) of the ground-truth best search result appearing within the top ๐‘ฅ results of the output. For brevity, for every language and ๐‘ฅ, we have averaged results across all translations. Assuming our training data was also augmented with Metaโ€™s NLLB model, we separately list mean recall for every set of translations in the end of the table.

LanguageOpenCLIP @ 1UForm @ 1OpenCLIP @ 5UForm @ 5OpenCLIP @ 10UForm @ 10Speakers
Arabic ๐Ÿ‡ธ๐Ÿ‡ฆ22.731.744.957.855.869.2274 M
Armenian ๐Ÿ‡ฆ๐Ÿ‡ฒ5.622.014.344.720.256.04 M
Chinese ๐Ÿ‡จ๐Ÿ‡ณ27.332.251.359.062.170.51,118 M
English ๐Ÿ‡บ๐Ÿ‡ธ37.837.763.565.073.575.91,452 M
French ๐Ÿ‡ซ๐Ÿ‡ท31.335.456.562.667.473.3274 M
German ๐Ÿ‡ฉ๐Ÿ‡ช31.735.156.962.267.473.3134 M
Hebrew ๐Ÿ‡ฎ๐Ÿ‡ฑ23.726.746.351.857.063.59 M
Hindi ๐Ÿ‡ฎ๐Ÿ‡ณ20.731.342.557.953.769.6602 M
Indonesian ๐Ÿ‡ฎ๐Ÿ‡ฉ26.930.751.457.062.768.6199 M
Italian ๐Ÿ‡ฎ๐Ÿ‡น31.334.956.762.167.173.167 M
Japanese ๐Ÿ‡ฏ๐Ÿ‡ต27.432.651.559.262.670.6125 M
Korean ๐Ÿ‡ฐ๐Ÿ‡ท24.431.548.157.859.269.281 M
Persian ๐Ÿ‡ฎ๐Ÿ‡ท24.028.847.054.657.866.277 M
Polish ๐Ÿ‡ต๐Ÿ‡ฑ29.233.653.960.164.771.341 M
Portuguese ๐Ÿ‡ต๐Ÿ‡น31.632.757.159.667.971.0257 M
Russian ๐Ÿ‡ท๐Ÿ‡บ29.933.954.860.965.872.0258 M
Spanish ๐Ÿ‡ช๐Ÿ‡ธ32.635.658.062.868.873.7548 M
Thai ๐Ÿ‡น๐Ÿ‡ญ21.528.743.054.653.766.061 M
Turkish ๐Ÿ‡น๐Ÿ‡ท25.533.049.159.660.370.888 M
Ukranian ๐Ÿ‡บ๐Ÿ‡ฆ26.030.649.956.760.968.141 M
Vietnamese ๐Ÿ‡ป๐Ÿ‡ณ25.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-

Summarizing the results:

  1. OpenCLIP slightly edges out with a 0.1% higher โ€œrecall @ 1โ€, but falls behind in all other metrics.
  2. Languages under-represented in CommonCrawl and other common datasets saw significant improvement.
  3. Even the most popular language groups can benefit from data-efficient pre-training techniques.
  4. UForm has natural bias towards NLLB, noticeable during evaluation.

Delving into the third point, both Chinese and Hindi experienced a substantial boost, with Hindiโ€™s โ€œrecall @ 1โ€ jumping from 20.4% to 30.8%, and its โ€œrecall @ 10โ€ soaring from 53.3% to 69.1%. These improvements, however, focus on retrieval tasks, and donโ€™t mean you should expect good results on other multi-modal tasks, such as zero-shot ImageNet classification. That, however, is part of our ongoing effort and will be improved in UForm v3.

๐Ÿ‡ธ๐Ÿ‡ฆ๐Ÿ‡ฆ๐Ÿ‡ฒ๐Ÿ‡จ๐Ÿ‡ณ๐Ÿ‡ซ๐Ÿ‡ท๐Ÿ‡ฉ๐Ÿ‡ช๐Ÿ‡ฎ๐Ÿ‡ฑ๐Ÿ‡ฎ๐Ÿ‡ณ๐Ÿ‡ฎ๐Ÿ‡ฉ๐Ÿ‡ฎ๐Ÿ‡น๐Ÿ‡ฏ๐Ÿ‡ต๐Ÿ‡ฐ๐Ÿ‡ท๐Ÿ‡ฎ๐Ÿ‡ท๐Ÿ‡ต๐Ÿ‡ฑ๐Ÿ‡ต๐Ÿ‡น๐Ÿ‡ท๐Ÿ‡บ๐Ÿ‡ช๐Ÿ‡ธ๐Ÿ‡น๐Ÿ‡ญ๐Ÿ‡น๐Ÿ‡ท๐Ÿ‡บ๐Ÿ‡ฆ๐Ÿ‡ป๐Ÿ‡ณ
OpenCLIP NDCG0.6390.2040.7310.8230.8060.6570.6160.7330.8110.7370.6860.6670.7640.8320.7770.8490.6060.7010.7040.697
UForm NDCG0.8680.6910.8800.9320.9270.7910.8790.8700.9300.8850.8690.8310.8970.8970.9060.9390.8220.8980.8510.818

The second metric we emphasize is the Normalized Discounted Cumulative Gain (NDCG), typically used to assess ranking quality. In the absence of a definitive ground-truth multi-lingual ranking, we use English as a benchmark for other languages. A higher NDCG score indicates more consistent model behavior for a particular language. For a comprehensive view, we evaluate the top 20 results across all languages. On average, the NDCG for OpenCLIP is 0.716ยฑ0.149 across 20 languages. For UForm it grows to 0.875ยฑ0.064, with higher than 0.9 scores for Spanish, Italian, French, German, and Russian. These results are important step forward in our quest for better aligned multi-modal representations, which are still horrible, even for 10x larger models trained on 1000x more data.

ยง PyTorch, PopTorch, and Graphcore

In the past, UFormโ€™s inference library was entangled with numerous high-level dependencies, making version transitions unpredictable. Weโ€™ve since refactored the core classes down to pure PyTorch. This not only enhances performance but also ensures UForm deployments are more stable than most high-level AI libraries. But we didnโ€™t stop at PyTorch. Recognizing the surge in specialized high-performance AI hardware, weโ€™ve adapted UForm for PopTorch. This means UForm is ready to run on Graphcore IPUs right out of the box, seamlessly handling model-parallelism.

import uform
import poptorch
import PIL as pil

options = poptorch.Options()

model = uform.get_model_ipu('unum-cloud/uform-vl-english')
model = poptorch.inferenceModel(model, options=options)

text = 'a small red panda in a zoo'
image = pil.Image.open('red_panda.jpg')
image_data = model.preprocess_image(image)
text_data = model.preprocess_text(text)

image_features, text_features = model(image_data, text_data)

Running on IPUs is akin to operating on GPUs. First, ensure the drivers are correctly set up. Next, download the desired model. Lastly, feed in your data. UForm offers flexibility, allowing for both model-parallel and data-parallel operations. The code snippet below demonstrates how to distribute the model across 4 IPUs. Additionally, it replicates this sharded setup fourfold, aiming to utilize a total of 16 IPUs simultaneously.

options = poptorch.Options()
options.replicationFactor(4)
options.deviceIterations(4)

model = uform.get_model_ipu('unum-cloud/uform-vl-english').parallelize()
model = poptorch.inferenceModel(model, options=options)

Similarly, we have ported the model to Appleโ€™s CoreML for mobile inference on iOS, and ONNX for broader adoption. Still, need assistance integrating Semantic Search into your application? Donโ€™t hesitate โ€“ join us on Discord ๐Ÿค—