Skip to content

Commit bd6af50

Browse files
committed
Update README.md
1 parent 229d870 commit bd6af50

File tree

1 file changed

+56
-6
lines changed

1 file changed

+56
-6
lines changed

README.md

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,64 @@ Tensorboard: Aug25_09-53-27_ggpu137shared
313313

314314
### Custom Attention
315315
[Generalisations on Custom Attention](https://gitlab.gwdg.de/lukas.niegsch/language-ninjas/-/milestones/11#tab-issues)
316-
- At this Station we are considering/trying three ideas of Generalisations by hyperparameters on the Bert-Self-Attention (see (https://gitlab.gwdg.de/lukas.niegsch/language-ninjas/-/issues/54))
317-
- Although the idea of envolving more hyperparameters, should improve the result, however because of overfitting we are getting even a bit lower accuracy.
318-
- Sparessmax (paper) : (https://arxiv.org/abs/1602.02068v2).
316+
317+
We tried changing the normal custom attention formula:
318+
319+
1) Generalize $QK^T$ with symmetric linear combination of both $Q, K$ and learn the combination:
320+
321+
$$attention(Q, K, V) = softmax\left(\frac{(\alpha_1 * Q + \alpha_2 * K + \alpha_3I)(\beta_1 * Q + \beta_2 * K + \beta_3I)^T}{\sqrt{d_k}}\right)V$$
322+
323+
2) Replace softmax with sparsemax (see https://arxiv.org/abs/1602.02068v2):
324+
325+
$$attention(Q, K, V) = sparsemax\left(\frac{QK^T}{\sqrt{d_j}}\right)V$$
326+
327+
3) Add an additional learnable center matrix in between:
328+
329+
$$attention(Q, K, V) = softmax\left(\frac{QWK^T}{\sqrt{d_j}}\right)V$$
330+
331+
For ideas 1, 3 we get the original self attention by having specific parameters. We also found a paper that showed the second idea. The goal was that the model uses the original parameters but having more freedom in manipulating them by adding few extra parameters inside all the bert layers. We later realized that all 3 ideas could be combined resulting in 8 different models (1 baseline + 7 extra):
332+
333+
| Model name | SST accuracy | QQP accuracy | STS correlation |
334+
| sBERT-BertSelfAttention (baseline) | 44.6% | 77.2% | 48.3% |
335+
| sBERT-LinearSelfAttention | 40.5% | 75.6% | 37.8% |
336+
| sBERT-NoBiasLinearSelfAttention | 40.5% | 75.6% | 37.8% |
337+
| sBERT-SparsemaxSelfAttention | 39.0% | 70.7% | 56.8% |
338+
| sBERT-CenterMatrixSelfAttention | 39.1% | 76.4% | 43.4% |
339+
| sBERT-LinearSelfAttentionWithSparsemax | 40.1% | 75.3% | 40.8% |
340+
| sBERT-CenterMatrixSelfAttentionWithSparsemax | 39.1% | 75.6% | 40.4% |
341+
| sBERT-CenterMatrixLinearSelfAttention | 42.4% | 76.2% | 42.4% |
342+
| sBERT-CenterMatrixLinearSelfAttentionWithSparsemax | 39.7% | 76.4% | 39.2% |
343+
344+
Our baseline was different because we used other starting parameters (greater batch size, fewer parameters). We did this to reduce the training time for this experiment, see also ``submit_custom_attention.sh``:
345+
346+
```
347+
python -B multitask_classifier.py --use_gpu --epochs=10 --lr=1e-5 --custom_attention=$CUSTOM_ATTENTION
348+
```
349+
350+
Except for the SparsemaxSelfAttention STS correlation, all values declined. The problem is highly due to overfitting. Making the model even more complex makes overfitting worse, thus we get worse performance.
319351

320352
### Splitted and reordered batches
321353
[Splitted and reordererd batches](https://gitlab.gwdg.de/lukas.niegsch/language-ninjas/-/milestones/12#tab-issues)
322-
- At this Step we are considring a specific order of batches by splitting the the datasets and put them in a specific order, (see (https://gitlab.gwdg.de/lukas.niegsch/language-ninjas/-/issues/59)).
323-
- The idea works. We recieve at least 1% more accurcy at each task.
354+
355+
The para dataset is much larger than the other two. Originally, we trained para last and then evaluate all 3 independent from each other. This has the effect that the model is optimized towards para, but forgets information from sst and sts. We moved para first and then did the other two last.
356+
357+
Furthermore, all 3 datasets are learned one after another. This means that the gradiants may point in 3 different directions which we follow one after another. However, our goal is to move in the general direction for all 3 tasks together. We tried splitting the datasets into 6 different chunks (large para), (tiny sst, tiny para), (sts_size sts, sts_size para, sts_size sst). Important here is that the last 3 batches are the same size. Thus we can train all tasks without having para dominate the others.
358+
359+
Lastly, we tried training the batches for the last 3 steps in a round robin way (sts, para, sst, sts, para, sst, ...).
360+
361+
| Model name | SST accuracy | QQP accuracy | STS correlation |
362+
| sBERT-BertSelfAttention (baseline) | 44.6% | 77.2% | 48.3% |
363+
| sBERT-ReorderedTraining (BertSelfAttention) | 45.9% | 79.3% | 49.8% |
364+
| sBERT-RoundRobinTraining (BertSelfAttention) | 45.5% | 77.5% | 50.3% |
365+
366+
We used the same script as for the custom attention, but only used the orignal self attention. The reordered training is enabled by default because it gave the best performance. The round robin training can be enabled using the ``--cyclic_finetuning`` flag.
367+
368+
```
369+
python -B multitask_classifier.py --use_gpu --epochs=10 --lr=1e-5 --cyclic_finetuning=True
370+
```
371+
372+
The reordering improved the performance, most likely just because the para comes first. The round robin did not improve it further, maybe switching after each batch is too much.
373+
324374
### Combined Loss
325375

326376
This could work as a kind of regularization, because it is not training on a single task and overfitting, but it uses all losses to optimize.
@@ -544,4 +594,4 @@ python -u multitask_classifier.py --use_gpu --option finetune --optimizer "soph
544594
Für sophia mit gewichtetem loss und para datenset als erstes ein paar epochen zu trainieren (ohne dropout):
545595
```
546596
python -u multitask_classifier.py --use_gpu --option finetune --optimizer "sophiag" --epochs 5 --weights True --para_sep True --hidden_dropout_prob_para 0 --hidden_dropout_prob_sst 0 --hidden_dropout_prob_sts 0 --lr_para 1e-05 --lr_sst 1e-05 --lr_sts 1e-05 --batch_size 64 --optimizer "sophiag" --weight_decay_para 0.1267 --weight_decay_sst 0.2302 --weight_decay_sts 0.1384 --rho_para 0.0417 --rho_sst 0.0449 --rho_sts 0.0315 --comment weighted_loss_without_dropout
547-
```
597+
```

0 commit comments

Comments
 (0)