File size: 3,985 Bytes
31e9a1d 73092e0 1d77df9 73092e0 31e9a1d 73092e0 31e9a1d 73092e0 31e9a1d 73092e0 31e9a1d 73092e0 b0f4473 73092e0 b0f4473 73092e0 31e9a1d 73092e0 b0f4473 31e9a1d 773cc65 31e9a1d |
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 |
---
pipeline_tag: sentence-similarity
tags:
- sentence-transformers
- feature-extraction
- sentence-similarity
- transformers
---
# svalabs/german-gpl-adapted-covid
This is a german on covid adapted [sentence-transformers](https://www.SBERT.net) model:
It is adapted on covid related documents using the [GPL](https://github.com/UKPLab/gpl) integration of [Haystack](https://github.com/deepset-ai/haystack). We used the [svalabs/cross-electra-ms-marco-german-uncased](https://huggingface.co./svalabs/cross-electra-ms-marco-german-uncased) as CrossEncoder and [svalabs/mt5-large-german-query-gen-v1](https://huggingface.co./svalabs/mt5-large-german-query-gen-v1) for query generation.
<!--- Describe your model here -->
## Usage (Sentence-Transformers)
Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
```
pip install -U sentence-transformers
```
Then you can use the model like this:
```python
from sentence_transformers import SentenceTransformer, util
from transformers import AutoTokenizer, AutoModel
org_model = SentenceTransformer("sentence-transformers/msmarco-distilbert-multilingual-en-de-v2-tmp-trained-scratch")
org_model.max_seq_length = max_seq_length
model = SentenceTransformer('svalabs/german-gpl-adapted-covid')
def show_examples(model):
query = "Wie wird Covid-19 übermittelt"
docs = [
"Corona ist sehr ansteckend",
"Corona wird über die Luft verbreitet",
"Ebola wird durch direkten Kontakt mit Blut übertragen",
"HIV wird durch Sex oder den Austausch von Nadeln übertragen",
"Polio wird durch kontaminiertes Wasser oder Lebensmittel übertragen",
]
query_emb = model.encode(query)
docs_emb = model.encode(docs)
scores = util.dot_score(query_emb, docs_emb)[0]
doc_scores = sorted(zip(docs, scores), key=lambda x: x[1], reverse=True)
print("Query:", query)
for doc, score in doc_scores:
# print(doc, score)
print(f"{score:0.02f}\t{doc}")
print("Original Model")
show_examples(org_model)
print("\n\nAdapted Model")
show_examples(model)
```
## Evaluation Results
```
Original Model
Query: Wie wird Covid-19 übermittelt
33.01 HIV wird durch Sex oder den Austausch von Nadeln übertragen
32.78 Polio wird durch kontaminiertes Wasser oder Lebensmittel übertragen
29.10 Corona wird über die Luft verbreitet
24.41 Ebola wird durch direkten Kontakt mit Blut übertragen
10.85 Corona ist sehr ansteckend
Adapted Model
Query: Wie wird Covid-19 übermittelt
29.82 Corona wird über die Luft verbreitet
27.44 Polio wird durch kontaminiertes Wasser oder Lebensmittel übertragen
24.89 Ebola wird durch direkten Kontakt mit Blut übertragen
23.81 HIV wird durch Sex oder den Austausch von Nadeln übertragen
20.03 Corona ist sehr ansteckend
```
## Training
The model was trained with the parameters:
**DataLoader**:
`torch.utils.data.dataloader.DataLoader` of length 125 with parameters:
```
{'batch_size': 16, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}
```
**Loss**:
`sentence_transformers.losses.MarginMSELoss.MarginMSELoss`
Parameters of the fit()-Method:
```
{
"epochs": 1,
"evaluation_steps": 0,
"evaluator": "NoneType",
"max_grad_norm": 1,
"optimizer_class": "<class 'torch.optim.adamw.AdamW'>",
"optimizer_params": {
"lr": 2e-05
},
"scheduler": "WarmupLinear",
"steps_per_epoch": null,
"warmup_steps": 12,
"weight_decay": 0.01
}
```
## Full Model Architecture
```
SentenceTransformer(
(0): Transformer({'max_seq_length': 200, 'do_lower_case': False}) with Transformer model: DistilBertModel
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})
)
```
<!--- Describe where people can find more information --> |