w11wo commited on
Commit
209bc6a
1 Parent(s): 46f85d7

Add new SentenceTransformer model.

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
1_Pooling/config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 384,
3
+ "pooling_mode_cls_token": false,
4
+ "pooling_mode_mean_tokens": true,
5
+ "pooling_mode_max_tokens": false,
6
+ "pooling_mode_mean_sqrt_len_tokens": false,
7
+ "pooling_mode_weightedmean_tokens": false,
8
+ "pooling_mode_lasttoken": false
9
+ }
README.md ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: sentence-transformers
3
+ pipeline_tag: sentence-similarity
4
+ tags:
5
+ - sentence-transformers
6
+ - feature-extraction
7
+ - sentence-similarity
8
+ - transformers
9
+ datasets:
10
+ - indonli
11
+ - indolem/indo_story_cloze
12
+ - unicamp-dl/mmarco
13
+ - miracl/miracl
14
+ - LazarusNLP/multilingual-NLI-26lang-2mil7-id
15
+ - SEACrowd/wrete
16
+ - SEACrowd/indolem_ntp
17
+ - khalidalt/tydiqa-goldp
18
+ - SEACrowd/facqa
19
+ - indonesian-nlp/lfqa_id
20
+ - jakartaresearch/indoqa
21
+ - jakartaresearch/id-paraphrase-detection
22
+ ---
23
+
24
+ # LazarusNLP/all-indo-e5-small-v3
25
+
26
+ This is a [sentence-transformers](https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic search.
27
+
28
+ <!--- Describe your model here -->
29
+
30
+ ## Usage (Sentence-Transformers)
31
+
32
+ Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
33
+
34
+ ```
35
+ pip install -U sentence-transformers
36
+ ```
37
+
38
+ Then you can use the model like this:
39
+
40
+ ```python
41
+ from sentence_transformers import SentenceTransformer
42
+ sentences = ["This is an example sentence", "Each sentence is converted"]
43
+
44
+ model = SentenceTransformer('LazarusNLP/all-indo-e5-small-v3')
45
+ embeddings = model.encode(sentences)
46
+ print(embeddings)
47
+ ```
48
+
49
+
50
+
51
+ ## Usage (HuggingFace Transformers)
52
+ 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.
53
+
54
+ ```python
55
+ from transformers import AutoTokenizer, AutoModel
56
+ import torch
57
+
58
+
59
+ #Mean Pooling - Take attention mask into account for correct averaging
60
+ def mean_pooling(model_output, attention_mask):
61
+ token_embeddings = model_output[0] #First element of model_output contains all token embeddings
62
+ input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
63
+ return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
64
+
65
+
66
+ # Sentences we want sentence embeddings for
67
+ sentences = ['This is an example sentence', 'Each sentence is converted']
68
+
69
+ # Load model from HuggingFace Hub
70
+ tokenizer = AutoTokenizer.from_pretrained('LazarusNLP/all-indo-e5-small-v3')
71
+ model = AutoModel.from_pretrained('LazarusNLP/all-indo-e5-small-v3')
72
+
73
+ # Tokenize sentences
74
+ encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
75
+
76
+ # Compute token embeddings
77
+ with torch.no_grad():
78
+ model_output = model(**encoded_input)
79
+
80
+ # Perform pooling. In this case, mean pooling.
81
+ sentence_embeddings = mean_pooling(model_output, encoded_input['attention_mask'])
82
+
83
+ print("Sentence embeddings:")
84
+ print(sentence_embeddings)
85
+ ```
86
+
87
+
88
+
89
+ ## Evaluation Results
90
+
91
+ <!--- Describe how your model was evaluated -->
92
+
93
+ For an automated evaluation of this model, see the *Sentence Embeddings Benchmark*: [https://seb.sbert.net](https://seb.sbert.net?model_name=LazarusNLP/all-indo-e5-small-v3)
94
+
95
+
96
+ ## Training
97
+ The model was trained with the parameters:
98
+
99
+ **DataLoader**:
100
+
101
+ `MultiDatasetDataLoader.MultiDatasetDataLoader` of length 1077 with parameters:
102
+ ```
103
+ {'batch_size': 'unknown'}
104
+ ```
105
+
106
+ **Loss**:
107
+
108
+ `sentence_transformers.losses.MultipleNegativesRankingLoss.MultipleNegativesRankingLoss` with parameters:
109
+ ```
110
+ {'scale': 20.0, 'similarity_fct': 'cos_sim'}
111
+ ```
112
+
113
+ Parameters of the fit()-Method:
114
+ ```
115
+ {
116
+ "epochs": 5,
117
+ "evaluation_steps": 0,
118
+ "evaluator": "sentence_transformers.evaluation.EmbeddingSimilarityEvaluator.EmbeddingSimilarityEvaluator",
119
+ "max_grad_norm": 1,
120
+ "optimizer_class": "<class 'torch.optim.adamw.AdamW'>",
121
+ "optimizer_params": {
122
+ "eps": 1e-06,
123
+ "lr": 2e-05
124
+ },
125
+ "scheduler": "WarmupLinear",
126
+ "steps_per_epoch": null,
127
+ "warmup_steps": 539,
128
+ "weight_decay": 0.01
129
+ }
130
+ ```
131
+
132
+
133
+ ## Full Model Architecture
134
+ ```
135
+ SentenceTransformer(
136
+ (0): Transformer({'max_seq_length': 128, 'do_lower_case': False}) with Transformer model: BertModel
137
+ (1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False})
138
+ )
139
+ ```
140
+
141
+ ## Citing & Authors
142
+
143
+ <!--- Describe where people can find more information -->
config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "intfloat/multilingual-e5-small",
3
+ "architectures": [
4
+ "BertModel"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "hidden_act": "gelu",
9
+ "hidden_dropout_prob": 0.1,
10
+ "hidden_size": 384,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 1536,
13
+ "layer_norm_eps": 1e-12,
14
+ "max_position_embeddings": 512,
15
+ "model_type": "bert",
16
+ "num_attention_heads": 12,
17
+ "num_hidden_layers": 12,
18
+ "pad_token_id": 0,
19
+ "position_embedding_type": "absolute",
20
+ "tokenizer_class": "XLMRobertaTokenizer",
21
+ "torch_dtype": "float32",
22
+ "transformers_version": "4.37.2",
23
+ "type_vocab_size": 2,
24
+ "use_cache": true,
25
+ "vocab_size": 250037
26
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "2.2.2",
4
+ "transformers": "4.37.2",
5
+ "pytorch": "2.2.0+cu118"
6
+ }
7
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:440326c11f9b52c36d24b97b6f5a84acf9ced9734bb056061ea2fc39afccbf4d
3
+ size 470637416
modules.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ]
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 128,
3
+ "do_lower_case": false
4
+ }
sentencepiece.bpe.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cfc8146abe2a0488e9e2a0c56de7952f7c11ab059eca145a0a727afce0db2865
3
+ size 5069051
special_tokens_map.json ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "cls_token": {
10
+ "content": "<s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "eos_token": {
17
+ "content": "</s>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "mask_token": {
24
+ "content": "<mask>",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "pad_token": {
31
+ "content": "<pad>",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ },
37
+ "sep_token": {
38
+ "content": "</s>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false
43
+ },
44
+ "unk_token": {
45
+ "content": "<unk>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false
50
+ }
51
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1130d2072397032d0b72b52b2ce0638976c2e04d47795ed83348615f39215614
3
+ size 17083075
tokenizer_config.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "<s>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "<pad>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "</s>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "<unk>",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "250001": {
36
+ "content": "<mask>",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "bos_token": "<s>",
45
+ "clean_up_tokenization_spaces": true,
46
+ "cls_token": "<s>",
47
+ "eos_token": "</s>",
48
+ "mask_token": "<mask>",
49
+ "model_max_length": 512,
50
+ "pad_token": "<pad>",
51
+ "sep_token": "</s>",
52
+ "sp_model_kwargs": {},
53
+ "tokenizer_class": "XLMRobertaTokenizer",
54
+ "unk_token": "<unk>"
55
+ }