Collab-uniba/github-issues-preprocessed-mpnet-st-e10
1121
1---2pipeline_tag: sentence-similarity3tags:4- sentence-transformers5- feature-extraction6- sentence-similarity7- transformers8 9---10 11# GitHub Issues Preprocessed MPNet Sentence Transformer (10 Epochs)12 13This is a [sentence-transformers](https://www.SBERT.net) model, specific for GitHub Issue data.14 15## Dataset16 17For training, we used the [NLBSE22 dataset](https://nlbse2022.github.io/tools/), after removing issues with empty body and duplicates.18Similarity between title and body was used to train the sentence embedding model.19 20 21## Usage (Sentence-Transformers)22 23Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:24 25```26pip install -U sentence-transformers27```28 29Then you can use the model like this:30 31```python32from sentence_transformers import SentenceTransformer33sentences = ["This is an example sentence", "Each sentence is converted"]34 35model = SentenceTransformer('Collab-uniba/github-issues-preprocessed-mpnet-st-e10')36embeddings = model.encode(sentences)37print(embeddings)38```39 40 41 42## Usage (HuggingFace Transformers)43Without [sentence-transformers](https://www.SBERT.net), you can use the model like this: First, you pass your input through the transformer model, then you have to apply the right pooling-operation on-top of the contextualized word embeddings.44 45```python46from transformers import AutoTokenizer, AutoModel47import torch48 49 50#Mean Pooling - Take attention mask into account for correct averaging51def mean_pooling(model_output, attention_mask):52 token_embeddings = model_output[0] #First element of model_output contains all token embeddings53 input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()54 return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)55 56 57# Sentences we want sentence embeddings for58sentences = ['This is an example sentence', 'Each sentence is converted']59 60# Load model from HuggingFace Hub61tokenizer = AutoTokenizer.from_pretrained('Collab-uniba/github-issues-preprocessed-mpnet-st-e10')62model = AutoModel.from_pretrained('Collab-uniba/github-issues-preprocessed-mpnet-st-e10')63 64# Tokenize sentences65encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')66 67# Compute token embeddings68with torch.no_grad():69 model_output = model(**encoded_input)70 71# Perform pooling. In this case, mean pooling.72sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])73 74print("Sentence embeddings:")75print(sentence_embeddings)76```77 78 79 80## Evaluation Results81 82<!--- Describe how your model was evaluated -->83 84For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name={MODEL_NAME})85 86 87## Training88The model was trained with the parameters:89 90**DataLoader**:91 92`torch.utils.data.dataloader.DataLoader` of length 43709 with parameters:93```94{'batch_size': 16, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}95```96 97**Loss**:98 99`sentence_transformers.losses.MultipleNegativesRankingLoss.MultipleNegativesRankingLoss` with parameters:100 ```101 {'scale': 20.0, 'similarity_fct': 'cos_sim'}102 ```103 104Parameters of the fit()-Method:105```106{107 "epochs": 10,108 "evaluation_steps": 0,109 "evaluator": "NoneType",110 "max_grad_norm": 1,111 "optimizer_class": "<class 'torch.optim.adamw.AdamW'>",112 "optimizer_params": {113 "lr": 2e-05114 },115 "scheduler": "WarmupLinear",116 "steps_per_epoch": null,117 "warmup_steps": 43709,118 "weight_decay": 0.01119}120```121 122 123## Full Model Architecture124```125SentenceTransformer(126 (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: MPNetModel 127 (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})128)129```130 131## Citing & Authors132 133<!--- Describe where people can find more information -->