File size: 3,440 Bytes
9a50435
 
 
 
eb75c57
 
 
 
 
82118a6
 
eb75c57
 
 
 
82118a6
 
 
 
 
 
 
 
 
 
 
eb75c57
 
 
4c25d9e
eb75c57
 
 
 
 
 
 
 
 
 
 
 
 
 
82118a6
eb75c57
 
 
 
 
6fc8df1
 
eb75c57
6fc8df1
82118a6
 
 
 
6fc8df1
82118a6
6fc8df1
 
82118a6
cba2ced
6fc8df1
82118a6
6fc8df1
 
 
 
 
82118a6
6fc8df1
 
 
 
 
 
 
82118a6
 
 
 
eb75c57
3509525
 
 
eb75c57
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
---
language:
- ar
pipeline_tag: text-to-image
---


## Model Details

Arabic CLIP is an adaptation of the Contrastive Language-Image Pre-training (CLIP) for the Arabic language. CLIP is an OpenAI-developed model that learns conceptual concepts from images and relates them with textual descriptions. This work attempts to improve the model's understanding and interpretation of visual information in the context of the Arabic language.


## Model Use


```python

from transformers import VisionTextDualEncoderModel, AutoTokenizer
model = VisionTextDualEncoderModel.from_pretrained("LinaAlhuri/Arabic-clip-bert-lit")
model.save_pretrained("arabic_clip") 

tokenizer = AutoTokenizer.from_pretrained("asafaya/bert-base-arabic", cache_dir=None, use_fast=True)

```



## Data

The aim was to create a comprehensive Arabic image-text dataset by combining various data sources due to the scarcity of Arabic resources. Challenges included limited Arabic data and the quality of translated datasets. The approach involved merging genuine datasets for rich information and using translated datasets to cover diverse domains, scenarios, and objects, striking a balance between their respective pros and cons.

| Dataset name | Images   |
| --- | --- |
|Arabic Conceptual Captions	|1,427,210|
|Arabic COCO 2014	|414,113|
|Arabic WIT	|109,366|
|Arabic Flicker8K	|24,272|
|Proposed (WAP) dataset	|151,252|
|Total	|2,126,213|



## Performance and Limitations

We have tested the efficacy of Arabic CLIP across different benchmarks tailored for tasks like zero-shot learning, image retrieval, localization, and image search.
- Conceptual Captions
- COCO
- ImageNet
- Unsplash

### Zero-shot Learning
###  Performance

| Multilingual CLIP            | Top 1   | Top 5   | Top 10  | Top 100 |
|------------------------------|---------|---------|---------|---------|
| **Short translation**        | 10.10   | 21.99   | 26.70   | 47.57   |
| **Long translation**         | 9.518   | 20.942  | 25.54   | 45.59   |

| LiT Arabic CLIP              | Top 1   | Top 5   | Top 10  | Top 100 |
|------------------------------|---------|---------|---------|---------|
| **Short translation**        | **18.66**   | **39.04**   | **47.38**   | **75.34**  |
| **Long translation**         | 16.43   | 36.36   | 45.09   | 73.96   |

### Image Retrieval
#### Conceptual Captions Evaluation

| Metric  | MCLIP | LiT Arabic CLIP |
|---------|-------|-----------------|
| **MRR@1** | 0.064  | 0.154           |
| **MRR@5** | 0.093 |  0.218           |
| **MRR@10** | 0.100 | 0.231           |

#### COCO Dataset Evaluation

| Metric  | MCLIP | LiT Arabic CLIP |
|---------|-------|-----------------|
| **MRR@1** | 0.043 | 0.063           |
| **MRR@5** | 0.068 | 0.099           |
| **MRR@10** | 0.074 | 0.108           |



## Limitations
To summarize the limitations into points
- Arabic CLIP struggles to count after 3.
- Limited genuine samples for the Arabic language.
- Various noises and biases might be introduced into Arabic CLIP because no studies have been conducted yet to address this issue in the published Arabic dataset or Arabic language models.

### Bias
For gender bias, it is important to note that Arabic uses a two-gender system in which all nouns are classified as masculine or feminine. 
However, this is not the case for English. Translating the text from English to Arabic may result in information loss or even make it prone to gender bias.