# Domain adaptation with MLM and NSP

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdomain-adaptation-with-mlm-and-nsp%2F17733%3E%5C
**Category:** 🤗Transformers\
**Created:** [May 9, 2022, 9:25pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdomain-adaptation-with-mlm-and-nsp%2F17733 "2022-05-09T21:25:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![monilouise](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@monilouise](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmonilouise)%5C
**Post date:** [May 9, 2022, 9:25pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdomain-adaptation-with-mlm-and-nsp%2F17733%2F1 "2022-05-09T21:25:50Z")

</div>

Hi,

I’ve coded a domain adapter for further pretraining a BERT model (Portuguese language) in a specific domain. I used the article [Fine-tuning a masked language model - Hugging Face Course](https://huggingface.co/course/chapter7/3?fw=tf) as a guide, but it doesn’t focus on next sentence prediction, only masked language model.

I’d like to know what is necessary to change the code to add support for next sentence prediction. I know I should use BertForPreTraining instead of AutoModelForMaskedLM, but my question is how to add the data and abels for NSP.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![ablam](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ablam/32/4668_2.png) [@ablam](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fablam)%5C
**Post date:** [June 24, 2022, 8:01pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdomain-adaptation-with-mlm-and-nsp%2F17733%2F2 "2022-06-24T20:01:45Z")

</div>

Hi. Same question here. Followed the tutorial and was wondering how to go about domain adaption for generation tasks, which would be CLM and not MLM. Were you able to figure things out?

---

<div class="post-metadata">

**Author:** ![rishabhstha](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@rishabhstha](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Frishabhstha)%5C
**Post date:** [January 4, 2023, 6:21am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdomain-adaptation-with-mlm-and-nsp%2F17733%2F3 "2023-01-04T06:21:13Z")

</div>

I have a similar question. Were you able to figure it out?

---

<div class="post-metadata">

**Author:** ![pantroluna](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@pantroluna](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fpantroluna)%5C
**Post date:** [January 18, 2024, 4:08am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fdomain-adaptation-with-mlm-and-nsp%2F17733%2F4 "2024-01-18T04:08:43Z")

</div>

I have a same question.
