CoolFace
Modelpublic

JihyukKim/RaMDA-R-scidocs

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes14downloads
README.md126 linesDownload Raw Back to root
1---2pipeline_tag: sentence-similarity3tags:4- sentence-transformers5- feature-extraction6- sentence-similarity7- transformers8 9---10 11# JihyukKim/RaMDA-R-scidocs12 13This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 768 dimensional dense vector space and can be used for tasks like clustering or semantic search.14 15<!--- Describe your model here -->16 17## Usage (Sentence-Transformers)18 19Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:20 21```22pip install -U sentence-transformers23```24 25Then you can use the model like this:26 27```python28from sentence_transformers import SentenceTransformer29sentences = ["This is an example sentence", "Each sentence is converted"]30 31model = SentenceTransformer('JihyukKim/RaMDA-R-scidocs')32embeddings = model.encode(sentences)33print(embeddings)34```35 36 37 38## Usage (HuggingFace Transformers)39Without [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.40 41```python42from transformers import AutoTokenizer, AutoModel43import torch44 45 46def cls_pooling(model_output, attention_mask):47    return model_output[0][:,0]48 49 50# Sentences we want sentence embeddings for51sentences = ['This is an example sentence', 'Each sentence is converted']52 53# Load model from HuggingFace Hub54tokenizer = AutoTokenizer.from_pretrained('JihyukKim/RaMDA-R-scidocs')55model = AutoModel.from_pretrained('JihyukKim/RaMDA-R-scidocs')56 57# Tokenize sentences58encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')59 60# Compute token embeddings61with torch.no_grad():62    model_output = model(**encoded_input)63 64# Perform pooling. In this case, cls pooling.65sentence_embeddings = cls_pooling(model_output, encoded_input['attention_mask'])66 67print("Sentence embeddings:")68print(sentence_embeddings)69```70 71 72 73## Evaluation Results74 75<!--- Describe how your model was evaluated -->76 77For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name=JihyukKim/RaMDA-R-scidocs)78 79 80## Training81The model was trained with the parameters:82 83**DataLoader**:84 85`torch.utils.data.dataloader.DataLoader` of length 10000 with parameters:86```87{'batch_size': 256, 'sampler': 'torch.utils.data.sampler.RandomSampler', 'batch_sampler': 'torch.utils.data.sampler.BatchSampler'}88```89 90**Loss**:91 92`__main__.MultipleNegativesRankingLossExtendedAlongwithCached` with parameters:93  ```94  {'scale': 20.0, 'similarity_fct': 'cos_sim'}95  ```96 97Parameters of the fit()-Method:98```99{100    "epochs": 1,101    "evaluation_steps": 0,102    "evaluator": "NoneType",103    "max_grad_norm": 1,104    "optimizer_class": "<class 'torch.optim.adamw.AdamW'>",105    "optimizer_params": {106        "lr": 3e-05107    },108    "scheduler": "constantlr",109    "steps_per_epoch": 10000,110    "warmup_steps": 10000,111    "weight_decay": 0112}113```114 115 116## Full Model Architecture117```118CustomSentenceTransformerForSingleFieldAlongwithCachedD(119  (0): Transformer({'max_seq_length': 64, 'do_lower_case': False}) with Transformer model: BertModel 120  (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})121)122```123 124## Citing & Authors125 126<!--- Describe where people can find more information -->