Datasets:
Languages:
English
Size:
10K - 100K
Tags:
sarcasm
sarcasm-detection
mulitmodal-sarcasm-detection
sarcasm detection
multimodao sarcasm detection
tweets
License:
language: | |
- en | |
license: unknown | |
size_categories: | |
- 10K<n<100K | |
task_categories: | |
- feature-extraction | |
- text-classification | |
- image-classification | |
- image-feature-extraction | |
- zero-shot-classification | |
- zero-shot-image-classification | |
pretty_name: multimodal-sarcasm-dataset | |
tags: | |
- sarcasm | |
- sarcasm-detection | |
- mulitmodal-sarcasm-detection | |
- sarcasm detection | |
- multimodao sarcasm detection | |
- tweets | |
dataset_info: | |
- config_name: mmsd-original | |
features: | |
- name: image | |
dtype: image | |
- name: text | |
dtype: string | |
- name: label | |
dtype: int64 | |
splits: | |
- name: train | |
num_bytes: 1816409874.384 | |
num_examples: 19816 | |
- name: validation | |
num_bytes: 260024770.0 | |
num_examples: 2410 | |
- name: test | |
num_bytes: 262626922.717 | |
num_examples: 2409 | |
download_size: 2690054686 | |
dataset_size: 2339061567.101 | |
- config_name: mmsd-v1 | |
features: | |
- name: image | |
dtype: image | |
- name: text | |
dtype: string | |
- name: label | |
dtype: int64 | |
splits: | |
- name: train | |
num_bytes: 1797521611.232 | |
num_examples: 19557 | |
- name: validation | |
num_bytes: 259452303.817 | |
num_examples: 2387 | |
- name: test | |
num_bytes: 261557636.749 | |
num_examples: 2373 | |
download_size: 2667548595 | |
dataset_size: 2318531551.798 | |
- config_name: mmsd-v2 | |
features: | |
- name: image | |
dtype: image | |
- name: text | |
dtype: string | |
- name: label | |
dtype: int64 | |
splits: | |
- name: train | |
num_bytes: 1816105257.384 | |
num_examples: 19816 | |
- name: validation | |
num_bytes: 259989983 | |
num_examples: 2410 | |
- name: test | |
num_bytes: 262588464.717 | |
num_examples: 2409 | |
download_size: 2689804711 | |
dataset_size: 2338683705.101 | |
configs: | |
- config_name: mmsd-original | |
data_files: | |
- split: train | |
path: mmsd-original/train-* | |
- split: validation | |
path: mmsd-original/validation-* | |
- split: test | |
path: mmsd-original/test-* | |
- config_name: mmsd-v1 | |
data_files: | |
- split: train | |
path: mmsd-v1/train-* | |
- split: validation | |
path: mmsd-v1/validation-* | |
- split: test | |
path: mmsd-v1/test-* | |
- config_name: mmsd-v2 | |
data_files: | |
- split: train | |
path: mmsd-v2/train-* | |
- split: validation | |
path: mmsd-v2/validation-* | |
- split: test | |
path: mmsd-v2/test-* | |
# MMSD2.0: Towards a Reliable Multi-modal Sarcasm Detection System | |
This is a copy of the dataset uploaded on Hugging Face for easy access. The original data comes from this [work](https://aclanthology.org/2023.findings-acl.689/), which is an improvement upon a [previous study](https://aclanthology.org/P19-1239). | |
## Usage | |
```python | |
from typing import TypedDict, cast | |
import pytorch_lightning as pl | |
from datasets import Dataset, load_dataset | |
from torch import Tensor | |
from torch.utils.data import DataLoader | |
from transformers import CLIPProcessor | |
class MMSDModelInput(TypedDict): | |
pixel_values: Tensor | |
input_ids: Tensor | |
attention_mask: Tensor | |
label: Tensor | |
id: list[str] | |
class MMSDDatasetModule(pl.LightningDataModule): | |
def __init__( | |
self, | |
clip_ckpt_name: str = "openai/clip-vit-base-patch32", | |
dataset_version: str = "mmsd-v2", | |
max_length: int = 77, | |
train_batch_size: int = 32, | |
val_batch_size: int = 32, | |
test_batch_size: int = 32, | |
num_workers: int = 19, | |
) -> None: | |
super().__init__() | |
self.clip_ckpt_name = clip_ckpt_name | |
self.dataset_version = dataset_version | |
self.train_batch_size = train_batch_size | |
self.val_batch_size = val_batch_size | |
self.test_batch_size = test_batch_size | |
self.num_workers = num_workers | |
self.max_length = max_length | |
def setup(self, stage: str) -> None: | |
processor = CLIPProcessor.from_pretrained(self.clip_ckpt_name) | |
def preprocess(example): | |
inputs = processor( | |
text=example["text"], | |
images=example["image"], | |
return_tensors="pt", | |
padding="max_length", | |
truncation=True, | |
max_length=self.max_length, | |
) | |
return { | |
"pixel_values": inputs["pixel_values"], | |
"input_ids": inputs["input_ids"], | |
"attention_mask": inputs["attention_mask"], | |
"label": example["label"], | |
} | |
self.raw_dataset = cast( | |
Dataset, | |
load_dataset("coderchen01/MMSD2.0", name=self.dataset_version), | |
) | |
self.dataset = self.raw_dataset.map( | |
preprocess, | |
batched=True, | |
) | |
def train_dataloader(self) -> DataLoader: | |
return DataLoader( | |
self.dataset["train"], | |
batch_size=self.train_batch_size, | |
shuffle=True, | |
num_workers=self.num_workers, | |
) | |
def val_dataloader(self) -> DataLoader: | |
return DataLoader( | |
self.dataset["validation"], | |
batch_size=self.val_batch_size, | |
num_workers=self.num_workers, | |
) | |
def test_dataloader(self) -> DataLoader: | |
return DataLoader( | |
self.dataset["test"], | |
batch_size=self.test_batch_size, | |
num_workers=self.num_workers, | |
) | |
``` | |
## References | |
[1] Yitao Cai, Huiyu Cai, and Xiaojun Wan. 2019. Multi-Modal Sarcasm Detection in Twitter with Hierarchical Fusion Model. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pages 2506–2515, Florence, Italy. Association for Computational Linguistics. | |
[2] Libo Qin, Shijue Huang, Qiguang Chen, Chenran Cai, Yudi Zhang, Bin Liang, Wanxiang Che, and Ruifeng Xu. 2023. MMSD2.0: Towards a Reliable Multi-modal Sarcasm Detection System. In Findings of the Association for Computational Linguistics: ACL 2023, pages 10834–10845, Toronto, Canada. Association for Computational Linguistics. | |