File size: 9,454 Bytes
4b06344
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dcff419
 
 
 
 
 
 
 
 
 
 
4b06344
 
 
 
 
 
 
 
 
 
bf19dcf
4b06344
 
bf19dcf
4b06344
 
 
 
 
 
 
 
 
 
bf19dcf
4b06344
 
bf19dcf
4b06344
 
 
 
 
 
 
 
 
 
bf19dcf
4b06344
 
bf19dcf
4b06344
 
 
 
 
 
 
 
 
 
bf19dcf
4b06344
 
bf19dcf
4b06344
 
 
 
 
 
 
 
 
 
bf19dcf
4b06344
 
bf19dcf
4b06344
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dcff419
4b06344
bf19dcf
 
 
 
 
4b06344
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
---
datasets:
- relbert/semeval2012_relational_similarity
model-index:
- name: relbert/relbert-roberta-large-nce-b-semeval2012
  results:
  - task:
      name: Relation Mapping
      type: sorting-task
    dataset:
      name: Relation Mapping
      args: relbert/relation_mapping
      type: relation-mapping
    metrics:
    - name: Accuracy
      type: accuracy
      value: 0.844047619047619
  - task:
      name: Analogy Questions (SAT full)
      type: multiple-choice-qa
    dataset:
      name: SAT full
      args: relbert/analogy_questions
      type: analogy-questions
    metrics:
    - name: Accuracy
      type: accuracy
      value: 0.5962566844919787
  - task:
      name: Analogy Questions (SAT)
      type: multiple-choice-qa
    dataset:
      name: SAT
      args: relbert/analogy_questions
      type: analogy-questions
    metrics:
    - name: Accuracy
      type: accuracy
      value: 0.5964391691394659
  - task:
      name: Analogy Questions (BATS)
      type: multiple-choice-qa
    dataset:
      name: BATS
      args: relbert/analogy_questions
      type: analogy-questions
    metrics:
    - name: Accuracy
      type: accuracy
      value: 0.7759866592551418
  - task:
      name: Analogy Questions (Google)
      type: multiple-choice-qa
    dataset:
      name: Google
      args: relbert/analogy_questions
      type: analogy-questions
    metrics:
    - name: Accuracy
      type: accuracy
      value: 0.902
  - task:
      name: Analogy Questions (U2)
      type: multiple-choice-qa
    dataset:
      name: U2
      args: relbert/analogy_questions
      type: analogy-questions
    metrics:
    - name: Accuracy
      type: accuracy
      value: 0.5526315789473685
  - task:
      name: Analogy Questions (U4)
      type: multiple-choice-qa
    dataset:
      name: U4
      args: relbert/analogy_questions
      type: analogy-questions
    metrics:
    - name: Accuracy
      type: accuracy
      value: 0.5717592592592593
  - task:
      name: Analogy Questions (ConceptNet Analogy)
      type: multiple-choice-qa
    dataset:
      name: ConceptNet Analogy
      args: relbert/analogy_questions
      type: analogy-questions
    metrics:
    - name: Accuracy
      type: accuracy
      value: 0.3850671140939597
  - task:
      name: Analogy Questions (TREX Analogy)
      type: multiple-choice-qa
    dataset:
      name: TREX Analogy
      args: relbert/analogy_questions
      type: analogy-questions
    metrics:
    - name: Accuracy
      type: accuracy
      value: 0.5901639344262295
  - task:
      name: Analogy Questions (NELL-ONE Analogy)
      type: multiple-choice-qa
    dataset:
      name: NELL-ONE Analogy
      args: relbert/analogy_questions
      type: analogy-questions
    metrics:
    - name: Accuracy
      type: accuracy
      value: 0.685
  - task:
      name: Lexical Relation Classification (BLESS)
      type: classification
    dataset:
      name: BLESS
      args: relbert/lexical_relation_classification
      type: relation-classification
    metrics:
    - name: F1
      type: f1
      value: 0.9053789362663854
    - name: F1 (macro)
      type: f1_macro
      value: 0.9019924211071858
  - task:
      name: Lexical Relation Classification (CogALexV)
      type: classification
    dataset:
      name: CogALexV
      args: relbert/lexical_relation_classification
      type: relation-classification
    metrics:
    - name: F1
      type: f1
      value: 0.8535211267605634
    - name: F1 (macro)
      type: f1_macro
      value: 0.6927368248535282
  - task:
      name: Lexical Relation Classification (EVALution)
      type: classification
    dataset:
      name: BLESS
      args: relbert/lexical_relation_classification
      type: relation-classification
    metrics:
    - name: F1
      type: f1
      value: 0.6695557963163596
    - name: F1 (macro)
      type: f1_macro
      value: 0.6579478074948211
  - task:
      name: Lexical Relation Classification (K&H+N)
      type: classification
    dataset:
      name: K&H+N
      args: relbert/lexical_relation_classification
      type: relation-classification
    metrics:
    - name: F1
      type: f1
      value: 0.9561800097377756
    - name: F1 (macro)
      type: f1_macro
      value: 0.8710404103873111
  - task:
      name: Lexical Relation Classification (ROOT09)
      type: classification
    dataset:
      name: ROOT09
      args: relbert/lexical_relation_classification
      type: relation-classification
    metrics:
    - name: F1
      type: f1
      value: 0.8815418364149169
    - name: F1 (macro)
      type: f1_macro
      value: 0.8777604477980864

---
# relbert/relbert-roberta-large-nce-b-semeval2012

RelBERT based on [roberta-large](https://huggingface.co/roberta-large) fine-tuned on [relbert/semeval2012_relational_similarity](https://huggingface.co/datasets/relbert/semeval2012_relational_similarity) (see the [`relbert`](https://github.com/asahi417/relbert) for more detail of fine-tuning).
This model achieves the following results on the relation understanding tasks:
- Analogy Question ([dataset](https://huggingface.co/datasets/relbert/analogy_questions), [full result](https://huggingface.co/relbert/relbert-roberta-large-nce-b-semeval2012/raw/main/analogy.forward.json)):
    - Accuracy on SAT (full): 0.5962566844919787 
    - Accuracy on SAT: 0.5964391691394659
    - Accuracy on BATS: 0.7759866592551418
    - Accuracy on U2: 0.5526315789473685
    - Accuracy on U4: 0.5717592592592593
    - Accuracy on Google: 0.902
    - Accuracy on ConceptNet Analogy: 0.3850671140939597
    - Accuracy on T-Rex Analogy: 0.5901639344262295
    - Accuracy on NELL-ONE Analogy: 0.685
- Lexical Relation Classification ([dataset](https://huggingface.co/datasets/relbert/lexical_relation_classification), [full result](https://huggingface.co/relbert/relbert-roberta-large-nce-b-semeval2012/raw/main/classification.json)):
    - Micro F1 score on BLESS: 0.9053789362663854
    - Micro F1 score on CogALexV: 0.8535211267605634
    - Micro F1 score on EVALution: 0.6695557963163596
    - Micro F1 score on K&H+N: 0.9561800097377756
    - Micro F1 score on ROOT09: 0.8815418364149169
- Relation Mapping ([dataset](https://huggingface.co/datasets/relbert/relation_mapping), [full result](https://huggingface.co/relbert/relbert-roberta-large-nce-b-semeval2012/raw/main/relation_mapping.json)):
    - Accuracy on Relation Mapping: 0.844047619047619 


### Usage
This model can be used through the [relbert library](https://github.com/asahi417/relbert). Install the library via pip   
```shell
pip install relbert
```
and activate model as below.
```python
from relbert import RelBERT
model = RelBERT("relbert/relbert-roberta-large-nce-b-semeval2012")
vector = model.get_embedding(['Tokyo', 'Japan'])  # shape of (n_dim, )
```

### Training hyperparameters

 - model: roberta-large
 - max_length: 64
 - epoch: 10
 - batch: 32
 - random_seed: 0
 - lr: 5e-06
 - lr_warmup: 10
 - aggregation_mode: average_no_mask
 - data: relbert/semeval2012_relational_similarity
 - data_name: None
 - exclude_relation: None
 - split: train
 - split_valid: validation
 - loss_function: nce
 - classification_loss: False
 - loss_function_config: {'temperature': 0.05, 'num_negative': 400, 'num_positive': 10}
 - augment_negative_by_positive: True

See the full configuration at [config file](https://huggingface.co/relbert/relbert-roberta-large-nce-b-semeval2012/raw/main/finetuning_config.json).

### Reference
If you use any resource from RelBERT, please consider to cite our [paper](https://aclanthology.org/2021.emnlp-main.712/).

```

@inproceedings{ushio-etal-2021-distilling,
    title = "Distilling Relation Embeddings from Pretrained Language Models",
    author = "Ushio, Asahi  and
      Camacho-Collados, Jose  and
      Schockaert, Steven",
    booktitle = "Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing",
    month = nov,
    year = "2021",
    address = "Online and Punta Cana, Dominican Republic",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2021.emnlp-main.712",
    doi = "10.18653/v1/2021.emnlp-main.712",
    pages = "9044--9062",
    abstract = "Pre-trained language models have been found to capture a surprisingly rich amount of lexical knowledge, ranging from commonsense properties of everyday concepts to detailed factual knowledge about named entities. Among others, this makes it possible to distill high-quality word vectors from pre-trained language models. However, it is currently unclear to what extent it is possible to distill relation embeddings, i.e. vectors that characterize the relationship between two words. Such relation embeddings are appealing because they can, in principle, encode relational knowledge in a more fine-grained way than is possible with knowledge graphs. To obtain relation embeddings from a pre-trained language model, we encode word pairs using a (manually or automatically generated) prompt, and we fine-tune the language model such that relationally similar word pairs yield similar output vectors. We find that the resulting relation embeddings are highly competitive on analogy (unsupervised) and relation classification (supervised) benchmarks, even without any task-specific fine-tuning. Source code to reproduce our experimental results and the model checkpoints are available in the following repository: https://github.com/asahi417/relbert",
}

```