Sentence Similarity
sentence-transformers
PyTorch
Transformers
bert
feature-extraction
text-embeddings-inference
Run this model with HF Jobs
Run nthakur/RetroMAE_BEIR on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/nthakur/RetroMAE_BEIR. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/nthakur/RetroMAE_BEIR on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use nthakur/RetroMAE_BEIR with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use nthakur/RetroMAE_BEIR with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("nthakur/RetroMAE_BEIR") sentences = [ "That is a happy person", "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Transformers
How to use nthakur/RetroMAE_BEIR with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("nthakur/RetroMAE_BEIR") model = AutoModel.from_pretrained("nthakur/RetroMAE_BEIR", device_map="auto") - Notebooks
- Google Colab
- Kaggle
initial model add and README.
Browse filesFiles changed (11)
- 1_Pooling/config.jsonAdded+7
- README.mdAdded+107
- config.jsonAdded+26
- config_sentence_transformers.jsonAdded+7
- modules.jsonAdded+14
- pytorch_model.binAdded+3
- sentence_bert_config.jsonAdded+4
- special_tokens_map.jsonAdded+7
- tokenizer.jsonAdded
- tokenizer_config.jsonAdded+15
- vocab.txtAdded
1234567{ "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}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107---pipeline_tag: sentence-similaritytags:- sentence-transformers- feature-extraction- sentence-similarity- transformersdatasets:- wikipedia- bookcorpus- ms_marco- BeIR/fiqa- BeIR/trec-covid- BeIR/scifact- BeIR/nfcorpus- BeIR/nq- BeIR/hotpotqa- BeIR/arguana- BeIR/webis-touche2020- BeIR/quora- BeIR/dbpedia-entity- BeIR/scidocs- BeIR/fever- BeIR/climate-fever---
# nthakur/RetroMAE_BEIR
This is a port of the [RetroMAE_BEIR](https://huggingface.co/Shitao/RetroMAE_BEIR) Model to [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.
<!--- 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:
```pythonfrom sentence_transformers import SentenceTransformersentences = ["This is an example sentence", "Each sentence is converted"]
model = SentenceTransformer('nthakur/RetroMAE_BEIR')embeddings = model.encode(sentences)print(embeddings)```
## Usage (HuggingFace Transformers)Without [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.
```pythonfrom transformers import AutoTokenizer, AutoModelimport torch
def cls_pooling(model_output, attention_mask): return model_output[0][:,0]
# Sentences we want sentence embeddings forsentences = ['This is an example sentence', 'Each sentence is converted']
# Load model from HuggingFace Hubtokenizer = AutoTokenizer.from_pretrained('nthakur/RetroMAE_BEIR')model = AutoModel.from_pretrained('nthakur/RetroMAE_BEIR')
# Tokenize sentencesencoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
# Compute token embeddingswith torch.no_grad(): model_output = model(**encoded_input)
# Perform pooling. In this case, cls pooling.sentence_embeddings = cls_pooling(model_output, encoded_input['attention_mask'])
print("Sentence embeddings:")print(sentence_embeddings)```
## Evaluation Results
<!--- Describe how your model was evaluated -->
For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name=nthakur/RetroMAE_BEIR)
## Full Model Architecture```SentenceTransformer( (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: BertModel (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}))```
## Citing & AuthorsHave a look at [RetroMAE](https://github.com/staoxiao/RetroMAE/).<!--- Describe where people can find more information -->1234567891011121314151617181920212223242526{ "_name_or_path": "Shitao/RetroMAE_BEIR", "architectures": [ "BertModel" ], "attention_probs_dropout_prob": 0.1, "classifier_dropout": null, "gradient_checkpointing": false, "hidden_act": "gelu", "hidden_dropout_prob": 0.1, "hidden_size": 768, "initializer_range": 0.02, "intermediate_size": 3072, "layer_norm_eps": 1e-12, "max_position_embeddings": 512, "model_type": "bert", "num_attention_heads": 12, "num_hidden_layers": 12, "pad_token_id": 0, "position_embedding_type": "absolute", "torch_dtype": "float32", "transformers_version": "4.30.2", "type_vocab_size": 2, "use_cache": true, "vocab_size": 30522}1234567{ "__version__": { "sentence_transformers": "2.2.2", "transformers": "4.30.2", "pytorch": "2.0.1+cu117" }}1234567891011121314[ { "idx": 0, "name": "0", "path": "", "type": "sentence_transformers.models.Transformer" }, { "idx": 1, "name": "1", "path": "1_Pooling", "type": "sentence_transformers.models.Pooling" }]123version https://git-lfs.github.com/spec/v1oid sha256:f6a720644cfe4f41c317b73af9afb3aa837c7b3dbda0f54182a849fc3b36da1bsize 4380001731234{ "max_seq_length": 512, "do_lower_case": false}1234567{ "cls_token": "[CLS]", "mask_token": "[MASK]", "pad_token": "[PAD]", "sep_token": "[SEP]", "unk_token": "[UNK]"}123456789101112131415{ "clean_up_tokenization_spaces": true, "cls_token": "[CLS]", "do_basic_tokenize": true, "do_lower_case": true, "mask_token": "[MASK]", "model_max_length": 512, "never_split": null, "pad_token": "[PAD]", "sep_token": "[SEP]", "strip_accents": null, "tokenize_chinese_chars": true, "tokenizer_class": "BertTokenizer", "unk_token": "[UNK]"}1_Pooling/config.jsonAdded+7
README.mdAdded+107
config.jsonAdded+26
config_sentence_transformers.jsonAdded+7
modules.jsonAdded+14
pytorch_model.binAdded+3
sentence_bert_config.jsonAdded+4
special_tokens_map.jsonAdded+7
tokenizer.jsonAdded
tokenizer_config.jsonAdded+15
vocab.txtAdded