--- language: - en license: unknown size_categories: - 10K 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, remove_columns=["text", "image"], ) 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.