Integrating Contrastive Learning into a Multitask Transformer Model for Effective Domain Adaptation