readme: ---
  language:
  - de
  - en
  pipeline_tag: sentence-similarity
  tags:
  - semantic textual similarity
  - sts
  - semantic search
  - sentence similarity
  - paraphrasing
  - sentence-transformer
  - feature-extraction
  - transformers
  ---
  
  # Model card for PM-AI/sts_paraphrase_xlm-roberta-base_de-en
  
  ## Model summary
  Transformer model for **Semantic Textual Similarity (STS)** for _German_ and _Englisch_ sentences/texts.
  The embeddings output can be used for **semantic search**, **paraphrasing** and **retrieval** with _cosine similarity_.
  The Model is applicable to _Englisch-German-Mixed_ sentences/texts but also for _Englisch only_ and _German only_.
  
  The model can be easily used with [Sentence Transformer](https://github.com/UKPLab/sentence-transformers) library.
  
  ## Training
  This model is based on a training approach from 2020 by Philip May, who published the [T-Systems-onsite/cross-en-de-roberta-sentence-transformer](https://huggingface.co/T-Systems-onsite/cross-en-de-roberta-sentence-transformer) model.
  We updated this approach by a new base model for fine-tuning and some extensions to the training data.
  These changes are discussed in the next sections.
  
  ### Training Data
  The model is based on training with samples from [STSb](https://huggingface.co/datasets/stsb_multi_mt), [SICK](https://huggingface.co/datasets/mteb/sickr-sts) and [Priya22 semantic textual relatedness](https://github.com/Priya22/semantic-textual-relatedness) datasets.
  They contain about 76.000 sentence pairs in total.
  These sentence pairs are based on _German-German_, _English-English_ and _German-English mixed_.
  The training object is to optimize for _cosine similarity loss_ based on a human annoted sentence similarity score.
  In terms of content, the samples are based on rather simple sentences.
  
  When the TSystems model was published, only the STSb dataset was used for STS training.
  Therefore it is included in our model, but expanded to include SICK and Priya22 semantic textual relatedness:
   - SICK was partly used in STSb, but our custom translation using [DeepL](https://www.deepl.com/) leads to slightly different phrases. This approach allows more examples to be included in the training.
   - The Priya22 semantic textual relatedness dataset published in 2022 was also translated into German via DeepL and added to the training data. Since it does not have a train-test-split, it was created independently at a ratio of 80:20.
  
  All training and test data (STSb, Sick, Priya22) were checked for duplicates within and with each other and removed if found.
  Because the test data is prioritized, duplicated entries between test-train are exclusively removed from train split.
  The final used datasets can be viewed here: [datasets_sts_paraphrase_xlm-roberta-base_de-en](https://gitlab.com/sense.ai.tion-public/datasets_sts_paraphrase_xlm-roberta-base_de-en)
  
  ### Training
  Befor fine-tuning for STS we made the English paraphrasing model [paraphrase-distilroberta-base-v1](https://huggingface.co/sentence-transformers/paraphrase-distilroberta-base-v1) usable for German by applying **[Knowledge Distillation](https://arxiv.org/abs/2004.09813)** (_Teacher-Student_ approach).
  The TSystems model used version 1, which is based on 7 different datasets and contains around 24.6 million samples.
  We are using version 2 with 12 datasets and about 83.3 million examples.
  Details for this process here: [PM-AI/paraphrase-distilroberta-base-v2_de-en](https://huggingface.co/PM-AI/paraphrase-distilroberta-base-v2_de-en)
  
  For fine-tuning we are using SBERT's [training_stsbenchmark_continue_training.py](https://github.com/UKPLab/sentence-transformers/blob/b86eec31cf0a102ad786ba1ff31bfeb4998d3ca5/examples/training/sts/training_stsbenchmark_continue_training.py) training script.
  One thing has been changed in this training script: when a sentence pair consists of identical utterances the score is set to 5.0 (maximum).
  It makes no sense to say identical sentences have a score of 4.8 or 4.9.
  
  #### Parameterization of training
  - **Script:** [training_stsbenchmark_continue_training.py](https://github.com/UKPLab/sentence-transformers/blob/b86eec31cf0a102ad786ba1ff31bfeb4998d3ca5/examples/training/sts/training_stsbenchmark_continue_training.py)
  - **Datasets:** [datasets_sts_paraphrase_xlm-roberta-base_de-en/all_cross_train_unique.csv](https://gitlab.com/sense.ai.tion-public/datasets_sts_paraphrase_xlm-roberta-base_de-en)
  - **GPU:** NVIDIA A40 (Driver Version: 515.48.07; CUDA Version: 11.7)
  - **Batch Size:** 32
  - **Base Model:** [PM-AI/paraphrase-distilroberta-base-v2_de-en](PM-AI/paraphrase-distilroberta-base-v2_de-en)
  - **Loss Function:** Cosine Similarity
  - **Learning Rate:** 2e-5
  - **Epochs:** 3
  - **Evaluation Samples:** 500
  - **Evaluation Steps:** 1000
  - **Warmup Steps:** 10%
  
  ### Evaluation <a name="evaluation"></a>
  
  Now the performance is measured cross-lingually as well as for German and English only.
  In addition, the test samples used are evaluated individually for each data set (STSb, SICK, Priya22)