adapter-transformers xlm-roberta dataset:rajpurkar/squad_v2 dataset:UKPLab/m2qa region:us
---
datasets:
- rajpurkar/squad_v2
- UKPLab/m2qa
tags:
- adapter-transformers
- xlm-roberta
---

# M2QA Adapter: QA Head for MAD-X² Setup
This adapter is part of the M2QA publication to achieve language and domain transfer via adapters.  
📃 Paper: [https://aclanthology.org/2024.findings-emnlp.365/](https://aclanthology.org/2024.findings-emnlp.365/)  
🏗️ GitHub repo: [https://github.com/UKPLab/m2qa](https://github.com/UKPLab/m2qa)  
💾 Hugging Face Dataset: [https://huggingface.co/UKPLab/m2qa](https://huggingface.co/UKPLab/m2qa)  

**Important:** This adapter only works together with the MAD-X-2 language and domain adapters. This QA adapter was trained on the SQuAD v2 dataset.

This [adapter](https://adapterhub.ml) for the `xlm-roberta-base` model that was trained using the **[Adapters](https://github.com/Adapter-Hub/adapters)** library. For detailed training details see our paper or GitHub repository: [https://github.com/UKPLab/m2qa](https://github.com/UKPLab/m2qa). You can find the evaluation results for this adapter on the M2QA dataset in the GitHub repo and in the paper.


## Usage

First, install `adapters`:

```
pip install -U adapters
```

Now, the adapter can be loaded and activated like this:

```python
from adapters import AutoAdapterModel
from adapters.composition import Stack

model = AutoAdapterModel.from_pretrained("xlm-roberta-base")

# 1. Load language adapter
language_adapter_name = model.load_adapter("AdapterHub/m2qa-xlm-roberta-base-mad-x-2-german") 

# 2. Load domain adapter
domain_adapter_name = model.load_adapter("AdapterHub/m2qa-xlm-roberta-base-mad-x-2-product-reviews")

# 3. Load QA head adapter
qa_adapter_name = model.load_adapter("AdapterHub/m2qa-xlm-roberta-base-mad-x-2-qa-head")

# 4. Activate them via the adapter stack
model.active_adapters = Stack(language_adapter_name, domain_adapter_name, qa_adapter_name)
```


See our repository for more information: See https://github.com/UKPLab/m2qa/tree/main/Experiments/mad-x-2


## Contact
Leon Engländer:
- [HuggingFace Profile](https://huggingface.co/lenglaender)
- [GitHub](https://github.com/lenglaender)
- [Twitter](https://x.com/LeonEnglaender)

## Citation

```
@inproceedings{englander-etal-2024-m2qa,
    title = "M2QA: Multi-domain Multilingual Question Answering",
    author = {Engl{\"a}nder, Leon  and
      Sterz, Hannah  and
      Poth, Clifton A  and
      Pfeiffer, Jonas  and
      Kuznetsov, Ilia  and
      Gurevych, Iryna},
    booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2024",
    month = nov,
    year = "2024",
    address = "Miami, Florida, USA",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2024.findings-emnlp.365",
    pages = "6283--6305",
}
```