cointegrated commited on
Commit
ea03f7c
1 Parent(s): 83dcef3

the first commit

Browse files
README.md ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - feature-extraction
4
+ - embeddings
5
+ ---
6
+ # LaBSE for English and Russian
7
+ This is a truncated version of [sentence-transformers/LaBSE](https://huggingface.co/sentence-transformers/LaBSE), which is, in turn, a port of [LaBSE](https://tfhub.dev/google/LaBSE/1) by Google.
8
+
9
+ The current model has only English and Russian tokens left in the vocabulary.
10
+ Thus, the vocabulary is 10% of the original, and number of parameters in the whole model is 27% of the original, without any loss in the quality of English and Russian embeddings.
11
+
12
+ To get the sentence embeddings, you can use the following code:
13
+ ```python
14
+ from transformers import AutoTokenizer, AutoModel
15
+ tokenizer = AutoTokenizer.from_pretrained("sentence-transformers/LaBSE")
16
+ model = AutoModel.from_pretrained("sentence-transformers/LaBSE")
17
+ sentences = ["Hello World", "Hallo Welt"]
18
+ encoded_input = tokenizer(sentences, padding=True, truncation=True, max_length=64, return_tensors='pt')
19
+ with torch.no_grad():
20
+ model_output = model(**encoded_input)
21
+ embeddings = model_output.pooler_output
22
+ embeddings = torch.nn.functional.normalize(embeddings)
23
+ print(embeddings)
24
+
25
+ ## Reference:
26
+ Fangxiaoyu Feng, Yinfei Yang, Daniel Cer, Narveen Ari, Wei Wang. [Language-agnostic BERT Sentence Embedding](https://arxiv.org/abs/2007.01852). July 2020
27
+ License: [https://tfhub.dev/google/LaBSE/1](https://tfhub.dev/google/LaBSE/1)
config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "cointegrated/LaBSE-en-ru",
3
+ "architectures": [
4
+ "BertForPreTraining"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "directionality": "bidi",
8
+ "gradient_checkpointing": false,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 768,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 3072,
14
+ "layer_norm_eps": 1e-12,
15
+ "max_position_embeddings": 512,
16
+ "model_type": "bert",
17
+ "num_attention_heads": 12,
18
+ "num_hidden_layers": 12,
19
+ "pad_token_id": 0,
20
+ "pooler_fc_size": 768,
21
+ "pooler_num_attention_heads": 12,
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.5.1",
27
+ "type_vocab_size": 2,
28
+ "use_cache": true,
29
+ "vocab_size": 55083
30
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d929e16c4cc9b40cdd96219e8ce3c1084129798435b3c67212efd68fa018673b
3
+ size 516063655
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"do_lower_case": false, "model_max_length": 512}
vocab.txt ADDED
The diff for this file is too large to render. See raw diff