Update README.md
Browse files
README.md
CHANGED
|
@@ -16,7 +16,6 @@ This a port of the original [SPACE-2 model](https://github.com/AlibabaResearch/D
|
|
| 16 |
|
| 17 |
This 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.
|
| 18 |
|
| 19 |
-
<!--- Describe your model here -->
|
| 20 |
|
| 21 |
## Usage (Sentence-Transformers)
|
| 22 |
|
|
@@ -38,50 +37,6 @@ print(embeddings)
|
|
| 38 |
```
|
| 39 |
|
| 40 |
|
| 41 |
-
|
| 42 |
-
## Usage (HuggingFace Transformers)
|
| 43 |
-
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.
|
| 44 |
-
|
| 45 |
-
```python
|
| 46 |
-
from transformers import AutoTokenizer, AutoModel
|
| 47 |
-
import torch
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
def cls_pooling(model_output, attention_mask):
|
| 51 |
-
return model_output[0][:,0]
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
# Sentences we want sentence embeddings for
|
| 55 |
-
sentences = ['This is an example sentence', 'Each sentence is converted']
|
| 56 |
-
|
| 57 |
-
# Load model from HuggingFace Hub
|
| 58 |
-
tokenizer = AutoTokenizer.from_pretrained('sergioburdisso/space-2')
|
| 59 |
-
model = AutoModel.from_pretrained('sergioburdisso/space-2')
|
| 60 |
-
|
| 61 |
-
# Tokenize sentences
|
| 62 |
-
encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
|
| 63 |
-
|
| 64 |
-
# Compute token embeddings
|
| 65 |
-
with torch.no_grad():
|
| 66 |
-
model_output = model(**encoded_input)
|
| 67 |
-
|
| 68 |
-
# Perform pooling. In this case, cls pooling.
|
| 69 |
-
sentence_embeddings = cls_pooling(model_output, encoded_input['attention_mask'])
|
| 70 |
-
|
| 71 |
-
print("Sentence embeddings:")
|
| 72 |
-
print(sentence_embeddings)
|
| 73 |
-
```
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
## Evaluation Results
|
| 78 |
-
|
| 79 |
-
<!--- Describe how your model was evaluated -->
|
| 80 |
-
|
| 81 |
-
For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name=sergioburdisso/space-2)
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
## Full Model Architecture
|
| 86 |
```
|
| 87 |
SentenceTransformer(
|
|
|
|
| 16 |
|
| 17 |
This 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.
|
| 18 |
|
|
|
|
| 19 |
|
| 20 |
## Usage (Sentence-Transformers)
|
| 21 |
|
|
|
|
| 37 |
```
|
| 38 |
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
## Full Model Architecture
|
| 41 |
```
|
| 42 |
SentenceTransformer(
|