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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
---
configs:
- config_name: default
  data_files:
  - split: train
    path: data/train-*
  - split: val
    path: data/val-*
  - split: test
    path: data/test-*
dataset_info:
  features:
  - name: image
    dtype: image
  - name: image_url
    dtype: string
  - name: item_idx
    dtype: int64
  - name: wit_features
    struct:
    - name: attribution_passes_lang_id
      sequence: bool
    - name: caption_alt_text_description
      sequence: string
    - name: caption_reference_description
      sequence: string
    - name: caption_title_and_reference_description
      sequence: string
    - name: context_page_description
      sequence: string
    - name: context_section_description
      sequence: string
    - name: hierarchical_section_title
      sequence: string
    - name: is_main_image
      sequence: bool
    - name: language
      sequence: string
    - name: page_changed_recently
      sequence: bool
    - name: page_title
      sequence: string
    - name: page_url
      sequence: string
    - name: section_title
      sequence: string
  - name: wit_idx
    dtype: int64
  - name: youtube_title_text
    dtype: string
  - name: youtube_description_text
    dtype: string
  - name: youtube_video_content
    dtype: binary
  - name: youtube_video_starting_time
    dtype: string
  - name: youtube_subtitle_text
    dtype: string
  - name: youtube_video_size
    dtype: int64
  - name: youtube_video_file_path
    dtype: string
  splits:
  - name: train
    num_bytes: 1902638101655.625
    num_examples: 1052915
  - name: val
    num_bytes: 104485442867.25
    num_examples: 57958
  - name: test
    num_bytes: 111107332347.375
    num_examples: 61389
  download_size: 2058391040534
  dataset_size: 2118230876870.25
license: cc-by-4.0
task_categories:
- zero-shot-classification
tags:
- video
- audio
- text
- image
- tetramodal
- multimodal
- youtube
- wikipedia
pretty_name: TALI
size_categories:
- 1M<n<10M
---
# Dataset Card for "TALI"

## Table of Contents
1. Dataset Description
  1. Abstract
  2. Brief Description
2. Dataset Information
  1. Modalities
  2. Dataset Variants
  3. Dataset Statistics
  4. Data Fields
  5. Data Splits
3. Dataset Creation
4. Dataset Use
5. Additional Information

## Dataset Description

### Abstract
TALI is a large-scale, tetramodal dataset designed to facilitate a shift from unimodal and duomodal to tetramodal research in deep learning. It aligns text, video, images, and audio, providing a rich resource for innovative self-supervised learning tasks and multimodal research. TALI enables exploration of how different modalities and data/model scaling affect downstream performance, with the aim of inspiring diverse research ideas and enhancing understanding of model capabilities and robustness in deep learning.

### Brief Description
TALI (Temporally and semantically Aligned Audio, Language and Images) is a dataset that uses the Wikipedia Image Text (WIT) captions and article titles to search Youtube for videos that match the captions. It then downloads the video, audio, and subtitles from these videos. The result is a rich multimodal dataset that has multiple caption types related to both the WiT Images, and the Youtube videos. This enables learning to take place between either temporally or semantically aligned text, images, audio and video.

## Dataset Information
### Modalities
The TALI dataset consists of the following modalities:

1. Image:
  1. Wikipedia caption image
  2. Randomly sampled image from youtube video
2. Text
  1. Wikipedia Caption Text
  2. Wikipedia Title Text
  3. Wikipedia Main Body Text
  4. YouTube Subtitle Text
  5. YouTube Description Text
  6. YouTube Title Text
3. Audio
  1. YouTube Content Audio
4. Video
  1. YouTube Content Video
     
## Usage:
To get started with TALI, you can load the dataset via Hugging Face's `datasets` library through our helper functions. The reason we don't use `datasets` directly is because we found huggingface_hub downloads much faster and reliable. For a full set of possible configurations look at [examples.py](examples.py). Here's a basic usage example:

First install the tali package:

### Installation

For the default install use:

```bash
pip install git+https://github.com/AntreasAntoniou/TALI
```

For the dev install use:

```bash
pip install git+https://github.com/AntreasAntoniou/TALI[dev]
```

Then use the dataset using:

### Examples
Import relevant helper functions
```python
  import pathlib
  from enum import Enum
  
  import torch
  from tqdm.auto import tqdm
  
  from tali.data import (
      SubModalityTypes,
      TALIBaseTransform,
      TALIBaseTransformConfig,
      VideoFramesFormat,
      default_transforms,
      load_dataset_via_hub,
  )
```

#### TALI with default transforms (CLIP and Whisper) and no streaming

```python
  def tali_with_transforms_no_streaming(
    dataset_storage_path: pathlib.Path | str,
):
    if isinstance(dataset_storage_path, str):
        dataset_storage_path = pathlib.Path(dataset_storage_path)

    dataset = load_dataset_via_hub(
        dataset_storage_path, dataset_name="Antreas/TALI"
    )["train"]

    (
        image_transforms,
        text_transforms,
        audio_transforms,
        video_transforms,
    ) = default_transforms()

    preprocessing_transform = TALIBaseTransform(
        cache_dir=dataset_storage_path / "cache",
        text_tokenizer=text_transforms,
        image_tokenizer=image_transforms,
        audio_tokenizer=audio_transforms,
        video_tokenizer=video_transforms,
        config=TALIBaseTransformConfig(
            root_filepath=dataset_storage_path,
            modality_list=[
                SubModalityTypes.youtube_content_video,
                SubModalityTypes.youtube_content_audio,
                SubModalityTypes.youtube_random_video_frame,
                SubModalityTypes.youtube_subtitle_text,
                SubModalityTypes.youtube_description_text,
                SubModalityTypes.youtube_title_text,
                SubModalityTypes.wikipedia_caption_image,
                SubModalityTypes.wikipedia_caption_text,
                SubModalityTypes.wikipedia_main_body_text,
                SubModalityTypes.wikipedia_title_text,
            ],
            video_frames_format=VideoFramesFormat.PIL,
        ),
    )

    for sample in tqdm(dataset):
        sample = preprocessing_transform(sample)
        print(list(sample.keys()))
        for key, value in sample.items():
            if hasattr(value, "shape"):
                print(key, value.shape)
            elif isinstance(value, torch.Tensor):
                print(key, value.shape)
            elif hasattr(value, "__len__"):
                print(key, len(value))
            print(key, type(value))

        break

    
```

#### TALI with no transforms and no streaming, returning text as text, images as PIL images, videos as a list of PIL images, and audio as a sequence of floats

```python
def tali_without_transforms_no_streaming(
    dataset_storage_path: pathlib.Path | str,
):
    if isinstance(dataset_storage_path, str):
        dataset_storage_path = pathlib.Path(dataset_storage_path)

    dataset = load_dataset_via_hub(
        dataset_storage_path, dataset_name="Antreas/TALI"
    )["train"]

    preprocessing_transform = TALIBaseTransform(
        cache_dir=dataset_storage_path / "cache",
        text_tokenizer=None,
        image_tokenizer=None,
        audio_tokenizer=None,
        video_tokenizer=None,
        config=TALIBaseTransformConfig(
            root_filepath=dataset_storage_path,
            modality_list=[
                SubModalityTypes.youtube_content_video,
                SubModalityTypes.youtube_content_audio,
                SubModalityTypes.youtube_random_video_frame,
                SubModalityTypes.youtube_subtitle_text,
                SubModalityTypes.youtube_description_text,
                SubModalityTypes.youtube_title_text,
                SubModalityTypes.wikipedia_caption_image,
                SubModalityTypes.wikipedia_caption_text,
                SubModalityTypes.wikipedia_main_body_text,
                SubModalityTypes.wikipedia_title_text,
            ],
            video_frames_format=VideoFramesFormat.PIL,
        ),
    )

    for sample in tqdm(dataset):
        sample = preprocessing_transform(sample)
        print(list(sample.keys()))
        for key, value in sample.items():
            if hasattr(value, "shape"):
                print(key, value.shape)
            elif isinstance(value, torch.Tensor):
                print(key, value.shape)
            elif hasattr(value, "__len__"):
                print(key, len(value))
            print(key, type(value))

        break
```

#### TALI with default transforms and streaming

```python
  def tali_with_transforms_streaming(
    dataset_storage_path: pathlib.Path | str,
):
    if isinstance(dataset_storage_path, str):
        dataset_storage_path = pathlib.Path(dataset_storage_path)

    dataset = load_dataset_via_hub(
        dataset_storage_path, dataset_name="Antreas/TALI", streaming=True
    )["train"]

    (
        image_transforms,
        text_transforms,
        audio_transforms,
        video_transforms,
    ) = default_transforms()

    preprocessing_transform = TALIBaseTransform(
        cache_dir=dataset_storage_path / "cache",
        text_tokenizer=text_transforms,
        image_tokenizer=image_transforms,
        audio_tokenizer=audio_transforms,
        video_tokenizer=video_transforms,
        config=TALIBaseTransformConfig(
            root_filepath=dataset_storage_path,
            modality_list=[
                SubModalityTypes.youtube_content_video,
                SubModalityTypes.youtube_content_audio,
                SubModalityTypes.youtube_random_video_frame,
                SubModalityTypes.youtube_subtitle_text,
                SubModalityTypes.youtube_description_text,
                SubModalityTypes.youtube_title_text,
                SubModalityTypes.wikipedia_caption_image,
                SubModalityTypes.wikipedia_caption_text,
                SubModalityTypes.wikipedia_main_body_text,
                SubModalityTypes.wikipedia_title_text,
            ],
            video_frames_format=VideoFramesFormat.PIL,
        ),
    )

    for sample in tqdm(dataset):
        sample = preprocessing_transform(sample)
        print(list(sample.keys()))
        for key, value in sample.items():
            if hasattr(value, "shape"):
                print(key, value.shape)
            elif isinstance(value, torch.Tensor):
                print(key, value.shape)
            elif hasattr(value, "__len__"):
                print(key, len(value))
            print(key, type(value))

        break

```

#### TALI with no transforms and streaming, returning text as text, images as PIL images, videos as a list of PIL images, and audio as a sequence of floats
```python
  def tali_without_transforms_streaming(
    dataset_storage_path: pathlib.Path | str,
):
    if isinstance(dataset_storage_path, str):
        dataset_storage_path = pathlib.Path(dataset_storage_path)

    dataset = load_dataset_via_hub(
        dataset_storage_path, dataset_name="Antreas/TALI", streaming=True
    )["train"]

    preprocessing_transform = TALIBaseTransform(
        cache_dir=dataset_storage_path / "cache",
        text_tokenizer=None,
        image_tokenizer=None,
        audio_tokenizer=None,
        video_tokenizer=None,
        config=TALIBaseTransformConfig(
            root_filepath=dataset_storage_path,
            modality_list=[
                SubModalityTypes.youtube_content_video,
                SubModalityTypes.youtube_content_audio,
                SubModalityTypes.youtube_random_video_frame,
                SubModalityTypes.youtube_subtitle_text,
                SubModalityTypes.youtube_description_text,
                SubModalityTypes.youtube_title_text,
                SubModalityTypes.wikipedia_caption_image,
                SubModalityTypes.wikipedia_caption_text,
                SubModalityTypes.wikipedia_main_body_text,
                SubModalityTypes.wikipedia_title_text,
            ],
            video_frames_format=VideoFramesFormat.PIL,
        ),
    )

    for sample in tqdm(dataset):
        sample = preprocessing_transform(sample)
        print(list(sample.keys()))
        for key, value in sample.items():
            if hasattr(value, "shape"):
                print(key, value.shape)
            elif isinstance(value, torch.Tensor):
                print(key, value.shape)
            elif hasattr(value, "__len__"):
                print(key, len(value))
            print(key, type(value))

        break
```


### Dataset Statistics
TBA


## Dataset Creation
The TALI dataset was created by starting from the WiT dataset and using either the context_page_description or page_title as a source-query to search YouTube for video that were creative commons opted-in, and, not age restricted. The top 100 result titles were returned and compared with the source-query using the CLIP text embeddings of the largest CLIP model available. The top-1 title’s video based on the CLIP ranking was chosen and downloaded. The video was broken into 30-second segments and the top-10 segments for eachvideo were chosen based on the distance between the CLIP image embedding of the first image of each segment and the video’s title text. The image, audio, and subtitle frames were extracted from these segments. At sampling time, one of these 10 segments is randomly selected, and a 10-second segment is chosen out of the 30-second clip. The result is 200 video frames (spread throughout the 10-second segment), and 160000 audio frames (10 seconds).

## Dataset Use
TALI is designed for use in a wide range of multimodal research tasks, including but not limited to:

- Multimodal understanding and reasoning
- Self-supervised learning
- Multimodal alignment and translation
- Multimodal summarization
- Multimodal question answering

## Dataset Curators: Antreas Antoniou
Citation Information: TBA
Contributions: Thanks to all contributors including data curators, annotators, and software developers.

[More Information needed](https://github.com/huggingface/datasets/blob/main/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)