Adapters
xlm-roberta
lenglaender commited on
Commit
70c3df2
1 Parent(s): 028966a

Upload model

Browse files
README.md ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - xlm-roberta
4
+ - adapter-transformers
5
+ datasets:
6
+ - UKPLab/m2qa
7
+ - rajpurkar/squad_v2
8
+ ---
9
+
10
+ # M2QA Adapter: QA Head for MAD-X+Domain Setup
11
+ This adapter is part of the M2QA publication to achieve language and domain transfer via adapters.
12
+ 📃 Paper: [TODO](TODO)
13
+ 🏗️ GitHub repo: [https://github.com/UKPLab/m2qa](https://github.com/UKPLab/m2qa)
14
+ 💾 Hugging Face Dataset: [https://huggingface.co/UKPLab/m2qa](https://huggingface.co/UKPLab/m2qa)
15
+
16
+ **Important:** This adapter only works together with the MAD-X language adapters and the M2QA MAD-X-Domain adapters. This QA adapter was trained on the SQuAD v2 dataset.
17
+
18
+ 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.
19
+
20
+
21
+ ## Usage
22
+
23
+ First, install `adapters`:
24
+
25
+ ```
26
+ pip install -U adapters
27
+ ```
28
+
29
+ Now, the adapter can be loaded and activated like this:
30
+
31
+ ```python
32
+ from adapters import AutoAdapterModel
33
+ from adapters.composition import Stack
34
+
35
+ model = AutoAdapterModel.from_pretrained("xlm-roberta-base")
36
+
37
+ # 1. Load language adapter
38
+ language_adapter_name = model.load_adapter("de/wiki@ukp") # MAD-X+Domain uses the MAD-X language adapter
39
+
40
+ # 2. Load domain adapter
41
+ domain_adapter_name = model.load_adapter("AdapterHub/m2qa-xlm-roberta-base-mad-x-domain-news")
42
+
43
+ # 3. Load QA head adapter
44
+ qa_adapter_name = model.load_adapter("AdapterHub/m2qa-xlm-roberta-base-mad-x-domain-qa-head")
45
+
46
+ # 4. Activate them via the adapter stack
47
+ model.active_adapters = Stack(language_adapter_name, domain_adapter_name, qa_adapter_name)
48
+ ```
49
+
50
+
51
+ See our repository for more information: See https://github.com/UKPLab/m2qa/tree/main/Experiments/mad-x-domain
52
+
53
+
54
+ ## Contact
55
+ Leon Engländer:
56
+ - [HuggingFace Profile](https://huggingface.co/lenglaender)
57
+ - [GitHub](https://github.com/lenglaender)
58
+ - [Twitter](https://x.com/LeonEnglaender)
59
+
60
+ ## Citation
61
+
62
+ ```
63
+ @article{englaender-etal-2024-m2qa,
64
+ title="M2QA: Multi-domain Multilingual Question Answering",
65
+ author={Engl{"a}nder, Leon and
66
+ Sterz, Hannah and
67
+ Poth, Clifton and
68
+ Pfeiffer, Jonas and
69
+ Kuznetsov, Ilia and
70
+ Gurevych, Iryna},
71
+ journal={arXiv preprint},
72
+ url={TODO}
73
+ year="2024"
74
+ }
75
+ ```
adapter_config.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "config": {
3
+ "adapter_residual_before_ln": false,
4
+ "cross_adapter": false,
5
+ "factorized_phm_W": true,
6
+ "factorized_phm_rule": false,
7
+ "hypercomplex_nonlinearity": "glorot-uniform",
8
+ "init_weights": "bert",
9
+ "inv_adapter": null,
10
+ "inv_adapter_reduction_factor": null,
11
+ "is_parallel": false,
12
+ "learn_phm": true,
13
+ "leave_out": [],
14
+ "ln_after": false,
15
+ "ln_before": false,
16
+ "mh_adapter": false,
17
+ "non_linearity": "relu",
18
+ "original_ln_after": true,
19
+ "original_ln_before": true,
20
+ "output_adapter": true,
21
+ "phm_bias": true,
22
+ "phm_c_init": "normal",
23
+ "phm_dim": 4,
24
+ "phm_init_range": 0.0001,
25
+ "phm_layer": false,
26
+ "phm_rank": 1,
27
+ "reduction_factor": 2,
28
+ "residual_before_ln": true,
29
+ "scaling": 1.0,
30
+ "shared_W_phm": false,
31
+ "shared_phm_rule": true,
32
+ "use_gating": false
33
+ },
34
+ "hidden_size": 768,
35
+ "model_class": "XLMRobertaAdapterModel",
36
+ "model_name": "xlm-roberta-base",
37
+ "model_type": "xlm-roberta",
38
+ "name": "mad-x+domain qa_head",
39
+ "version": "3.2.1"
40
+ }
head_config.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "config": {
3
+ "activation_function": "tanh",
4
+ "head_type": "question_answering",
5
+ "label2id": {
6
+ "LABEL_0": 0,
7
+ "LABEL_1": 1
8
+ },
9
+ "layers": 1,
10
+ "num_labels": 2
11
+ },
12
+ "hidden_size": 768,
13
+ "model_class": "XLMRobertaAdapterModel",
14
+ "model_name": "xlm-roberta-base",
15
+ "model_type": "xlm-roberta",
16
+ "name": "mad-x+domain qa_head",
17
+ "version": "3.2.1"
18
+ }
pytorch_adapter.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2f59d971b562b6856917d30264ed191197096c5ff0cb1a4eee531e6a6c3846f1
3
+ size 28384037
pytorch_model_head.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9b410aa5f809b1db7c02faa3ab056cd00459f5120c70efcd56a750240450a1f0
3
+ size 7251