nreimers commited on
Commit
61966e1
1 Parent(s): f84a947

Add new SentenceTransformer model.

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 768,
3
+ "pooling_mode_cls_token": true,
4
+ "pooling_mode_mean_tokens": false,
5
+ "pooling_mode_max_tokens": false,
6
+ "pooling_mode_mean_sqrt_len_tokens": false
7
+ }
2_Dense/config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"in_features": 768, "out_features": 768, "bias": true, "activation_function": "torch.nn.modules.activation.Tanh"}
2_Dense/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:06fb85120e40adf0ab188c4f0cc7684f702cb2023532947d1b85f325b0a3645c
3
+ size 2363431
README.md CHANGED
@@ -1,42 +1,77 @@
1
  ---
 
2
  tags:
3
  - sentence-transformers
4
  - feature-extraction
 
 
 
 
 
 
 
 
 
5
  ---
6
- # LaBSE Pytorch Version
7
- This is a pytorch port of the tensorflow version of [LaBSE](https://tfhub.dev/google/LaBSE/1).
8
 
9
- To get the sentence embeddings, you can use the following code:
10
- ```python
11
- from transformers import AutoTokenizer, AutoModel
12
 
13
- tokenizer = AutoTokenizer.from_pretrained("sentence-transformers/LaBSE")
14
- model = AutoModel.from_pretrained("sentence-transformers/LaBSE")
15
 
16
- sentences = ["Hello World", "Hallo Welt"]
17
 
18
- encoded_input = tokenizer(sentences, padding=True, truncation=True, max_length=64, return_tensors='pt')
19
 
20
- with torch.no_grad():
21
- model_output = model(**encoded_input)
22
 
23
- embeddings = model_output.pooler_output
24
- embeddings = torch.nn.functional.normalize(embeddings)
25
- print(embeddings)
 
26
  ```
27
 
 
28
 
29
- When you have [sentence-transformers](https://www.sbert.net/) installed, you can use the model like this:
30
  ```python
31
  from sentence_transformers import SentenceTransformer
32
- sentences = ["Hello World", "Hallo Welt"]
33
 
34
- model = SentenceTransformer('LaBSE')
35
  embeddings = model.encode(sentences)
36
  print(embeddings)
37
  ```
38
 
39
- ## Reference:
40
- Fangxiaoyu Feng, Yinfei Yang, Daniel Cer, Narveen Ari, Wei Wang. [Language-agnostic BERT Sentence Embedding](https://arxiv.org/abs/2007.01852). July 2020
41
 
42
- License: [https://tfhub.dev/google/LaBSE/1](https://tfhub.dev/google/LaBSE/1)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ pipeline_tag: sentence-similarity
3
  tags:
4
  - sentence-transformers
5
  - feature-extraction
6
+ - sentence-similarity
7
+ - transformers
8
+ - transformers
9
+ - transformers
10
+ - transformers
11
+ - transformers
12
+ - transformers
13
+ - transformers
14
+ - transformers
15
  ---
 
 
16
 
17
+ # sentence-transformers/LaBSE
 
 
18
 
19
+ 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.
 
20
 
 
21
 
 
22
 
23
+ ## Usage (Sentence-Transformers)
 
24
 
25
+ Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
26
+
27
+ ```
28
+ pip install -U sentence-transformers
29
  ```
30
 
31
+ Then you can use the model like this:
32
 
 
33
  ```python
34
  from sentence_transformers import SentenceTransformer
35
+ sentences = ["This is an example sentence", "Each sentence is converted"]
36
 
37
+ model = SentenceTransformer('sentence-transformers/LaBSE')
38
  embeddings = model.encode(sentences)
39
  print(embeddings)
40
  ```
41
 
 
 
42
 
43
+
44
+ ## Evaluation Results
45
+
46
+
47
+
48
+ For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name=sentence-transformers/LaBSE)
49
+
50
+
51
+
52
+ ## Full Model Architecture
53
+ ```
54
+ SentenceTransformer(
55
+ (0): Transformer({'max_seq_length': 256, 'do_lower_case': False}) with Transformer model: BertModel
56
+ (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})
57
+ (2): Dense({'in_features': 768, 'out_features': 768, 'bias': True, 'activation_function': 'torch.nn.modules.activation.Tanh'})
58
+ (3): Normalize()
59
+ )
60
+ ```
61
+
62
+ ## Citing & Authors
63
+
64
+ This model was trained by [sentence-transformers](https://www.sbert.net/).
65
+
66
+ If you find this model helpful, feel free to cite our publication [Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks](https://arxiv.org/abs/1908.10084):
67
+ ```bibtex
68
+ @inproceedings{reimers-2019-sentence-bert,
69
+ title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
70
+ author = "Reimers, Nils and Gurevych, Iryna",
71
+ booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
72
+ month = "11",
73
+ year = "2019",
74
+ publisher = "Association for Computational Linguistics",
75
+ url = "http://arxiv.org/abs/1908.10084",
76
+ }
77
+ ```
config.json CHANGED
@@ -1,4 +1,5 @@
1
  {
 
2
  "architectures": [
3
  "BertModel"
4
  ],
@@ -21,6 +22,9 @@
21
  "pooler_num_fc_layers": 3,
22
  "pooler_size_per_head": 128,
23
  "pooler_type": "first_token_transform",
 
 
24
  "type_vocab_size": 2,
 
25
  "vocab_size": 501153
26
  }
 
1
  {
2
+ "_name_or_path": "old_models/LaBSE/0_Transformer",
3
  "architectures": [
4
  "BertModel"
5
  ],
 
22
  "pooler_num_fc_layers": 3,
23
  "pooler_size_per_head": 128,
24
  "pooler_type": "first_token_transform",
25
+ "position_embedding_type": "absolute",
26
+ "transformers_version": "4.7.0",
27
  "type_vocab_size": 2,
28
+ "use_cache": true,
29
  "vocab_size": 501153
30
  }
config_sentence_transformers.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.0.0",
4
+ "transformers": "4.7.0",
5
+ "pytorch": "1.9.0+cu102"
6
+ }
7
+ }
modules.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.models.Transformer"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Pooling",
12
+ "type": "sentence_transformers.models.Pooling"
13
+ },
14
+ {
15
+ "idx": 2,
16
+ "name": "2",
17
+ "path": "2_Dense",
18
+ "type": "sentence_transformers.models.Dense"
19
+ },
20
+ {
21
+ "idx": 3,
22
+ "name": "3",
23
+ "path": "3_Normalize",
24
+ "type": "sentence_transformers.models.Normalize"
25
+ }
26
+ ]
pytorch_model.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:c8d3f6a70294b88e8f7d8920f312de9a56fa412c67188f05ca4ebe7a9de17e56
3
- size 1888175414
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c9e7daf739f87c2168a6d1baffdae5782eceb03eb6de61950284a925234c6865
3
+ size 1883785969
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 256,
3
+ "do_lower_case": false
4
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json CHANGED
@@ -1 +1 @@
1
- {"do_lower_case": false, "model_max_length": 512}
 
1
+ {"do_lower_case": false, "unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]", "tokenize_chinese_chars": true, "strip_accents": null, "model_max_length": 512, "special_tokens_map_file": "labse-pytorch/special_tokens_map.json", "full_tokenizer_file": null, "name_or_path": "old_models/LaBSE/0_Transformer", "do_basic_tokenize": true, "never_split": null}