Tom Aarsen commited on
Commit
ab4fb73
·
1 Parent(s): 22398f8

Revert inadvertent config, tokenizer updates

Browse files

This reverts commit 6ce56a2fc83f1232232b444b2c08ce6c8108f991.

Files changed (4) hide show
  1. README.md +66 -66
  2. config.json +46 -46
  3. special_tokens_map.json +37 -37
  4. tokenizer_config.json +57 -58
README.md CHANGED
@@ -1,67 +1,67 @@
1
- ---
2
- license: apache-2.0
3
- pipeline_tag: text-ranking
4
- language:
5
- - en
6
- library_name: sentence-transformers
7
- base_model:
8
- - google/electra-base-discriminator
9
- tags:
10
- - transformers
11
- ---
12
-
13
- ## Cross-Encoder for Text Ranking
14
-
15
- This model is a port of the [webis/monoelectra-base](https://huggingface.co/webis/monoelectra-base) model from [lightning-ir](https://github.com/webis-de/lightning-ir) to [Sentence Transformers](https://sbert.net/) and [Transformers](https://huggingface.co/docs/transformers).
16
-
17
- The original model was introduced in the paper [A Systematic Investigation of Distilling Large Language Models into Cross-Encoders for Passage Re-ranking](https://arxiv.org/abs/2405.07920). See https://github.com/webis-de/rank-distillm for code used to train the original model.
18
-
19
- The model can be used as a reranker in a 2-stage "retrieve-rerank" pipeline, where it reorders passages returned by a retriever model (e.g. an embedding model or BM25) given some query. See [SBERT.net Retrieve & Re-rank](https://www.sbert.net/examples/applications/retrieve_rerank/README.html) for more details.
20
-
21
- ## Usage with Sentence Transformers
22
-
23
- The usage is easy when you have [SentenceTransformers](https://www.sbert.net/) installed.
24
-
25
- ```bash
26
- pip install sentence-transformers
27
- ```
28
-
29
- Then you can use the pre-trained model like this:
30
-
31
- ```python
32
- from sentence_transformers import CrossEncoder
33
-
34
- model = CrossEncoder("cross-encoder/monoelectra-base", trust_remote_code=True)
35
- scores = model.predict([
36
- ("How many people live in Berlin?", "Berlin had a population of 3,520,031 registered inhabitants in an area of 891.82 square kilometers."),
37
- ("How many people live in Berlin?", "Berlin is well known for its museums."),
38
- ])
39
- print(scores)
40
- # [ 8.122868 -4.292924]
41
- ```
42
-
43
- ## Usage with Transformers
44
-
45
- ```python
46
- from transformers import AutoTokenizer, AutoModelForSequenceClassification
47
- import torch
48
-
49
- model = AutoModelForSequenceClassification.from_pretrained("cross-encoder/monoelectra-base", trust_remote_code=True)
50
- tokenizer = AutoTokenizer.from_pretrained("cross-encoder/monoelectra-base")
51
-
52
- features = tokenizer(
53
- [
54
- ("How many people live in Berlin?", "Berlin had a population of 3,520,031 registered inhabitants in an area of 891.82 square kilometers."),
55
- ("How many people live in Berlin?", "Berlin is well known for its museums."),
56
- ],
57
- padding=True,
58
- truncation=True,
59
- return_tensors="pt",
60
- )
61
-
62
- model.eval()
63
- with torch.no_grad():
64
- scores = model(**features).logits.view(-1)
65
- print(scores)
66
- # tensor([ 8.1229, -4.2929])
67
  ```
 
1
+ ---
2
+ license: apache-2.0
3
+ pipeline_tag: text-ranking
4
+ language:
5
+ - en
6
+ library_name: sentence-transformers
7
+ base_model:
8
+ - google/electra-base-discriminator
9
+ tags:
10
+ - transformers
11
+ ---
12
+
13
+ ## Cross-Encoder for Text Ranking
14
+
15
+ This model is a port of the [webis/monoelectra-base](https://huggingface.co/webis/monoelectra-base) model from [lightning-ir](https://github.com/webis-de/lightning-ir) to [Sentence Transformers](https://sbert.net/) and [Transformers](https://huggingface.co/docs/transformers).
16
+
17
+ The original model was introduced in the paper [A Systematic Investigation of Distilling Large Language Models into Cross-Encoders for Passage Re-ranking](https://arxiv.org/abs/2405.07920). See https://github.com/webis-de/rank-distillm for code used to train the original model.
18
+
19
+ The model can be used as a reranker in a 2-stage "retrieve-rerank" pipeline, where it reorders passages returned by a retriever model (e.g. an embedding model or BM25) given some query. See [SBERT.net Retrieve & Re-rank](https://www.sbert.net/examples/applications/retrieve_rerank/README.html) for more details.
20
+
21
+ ## Usage with Sentence Transformers
22
+
23
+ The usage is easy when you have [SentenceTransformers](https://www.sbert.net/) installed.
24
+
25
+ ```bash
26
+ pip install sentence-transformers
27
+ ```
28
+
29
+ Then you can use the pre-trained model like this:
30
+
31
+ ```python
32
+ from sentence_transformers import CrossEncoder
33
+
34
+ model = CrossEncoder("cross-encoder/monoelectra-base", trust_remote_code=True)
35
+ scores = model.predict([
36
+ ("How many people live in Berlin?", "Berlin had a population of 3,520,031 registered inhabitants in an area of 891.82 square kilometers."),
37
+ ("How many people live in Berlin?", "Berlin is well known for its museums."),
38
+ ])
39
+ print(scores)
40
+ # [ 8.122868 -4.292924]
41
+ ```
42
+
43
+ ## Usage with Transformers
44
+
45
+ ```python
46
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
47
+ import torch
48
+
49
+ model = AutoModelForSequenceClassification.from_pretrained("cross-encoder/monoelectra-base", trust_remote_code=True)
50
+ tokenizer = AutoTokenizer.from_pretrained("cross-encoder/monoelectra-base")
51
+
52
+ features = tokenizer(
53
+ [
54
+ ("How many people live in Berlin?", "Berlin had a population of 3,520,031 registered inhabitants in an area of 891.82 square kilometers."),
55
+ ("How many people live in Berlin?", "Berlin is well known for its museums."),
56
+ ],
57
+ padding=True,
58
+ truncation=True,
59
+ return_tensors="pt",
60
+ )
61
+
62
+ model.eval()
63
+ with torch.no_grad():
64
+ scores = model(**features).logits.view(-1)
65
+ print(scores)
66
+ # tensor([ 8.1229, -4.2929])
67
  ```
config.json CHANGED
@@ -1,46 +1,46 @@
1
- {
2
- "architectures": [
3
- "WebisCrossEncoderForSequenceClassification"
4
- ],
5
- "attention_probs_dropout_prob": 0.1,
6
- "auto_map": {
7
- "AutoModelForSequenceClassification": "cross-encoder/monoelectra-base--modeling.WebisCrossEncoderForSequenceClassification"
8
- },
9
- "backbone_model_type": "electra",
10
- "classifier_dropout": null,
11
- "doc_length": 256,
12
- "embedding_size": 768,
13
- "hidden_act": "gelu",
14
- "hidden_dropout_prob": 0.1,
15
- "hidden_size": 768,
16
- "id2label": {
17
- "0": "LABEL_0"
18
- },
19
- "initializer_range": 0.02,
20
- "intermediate_size": 3072,
21
- "label2id": {
22
- "LABEL_0": 0
23
- },
24
- "layer_norm_eps": 1e-12,
25
- "max_position_embeddings": 512,
26
- "model_type": "electra",
27
- "num_attention_heads": 12,
28
- "num_hidden_layers": 12,
29
- "pad_token_id": 0,
30
- "pooling_strategy": "first",
31
- "position_embedding_type": "absolute",
32
- "query_length": 32,
33
- "sentence_transformers": {
34
- "activation_fn": "torch.nn.modules.linear.Identity",
35
- "version": "4.1.0.dev0"
36
- },
37
- "summary_activation": "gelu",
38
- "summary_last_dropout": 0.1,
39
- "summary_type": "first",
40
- "summary_use_proj": true,
41
- "torch_dtype": "float32",
42
- "transformers_version": "4.52.0.dev0",
43
- "type_vocab_size": 2,
44
- "use_cache": true,
45
- "vocab_size": 30522
46
- }
 
1
+ {
2
+ "architectures": [
3
+ "WebisCrossEncoderForSequenceClassification"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "auto_map": {
7
+ "AutoModelForSequenceClassification": "modeling.WebisCrossEncoderForSequenceClassification"
8
+ },
9
+ "backbone_model_type": "electra",
10
+ "classifier_dropout": null,
11
+ "doc_length": 256,
12
+ "embedding_size": 768,
13
+ "hidden_act": "gelu",
14
+ "hidden_dropout_prob": 0.1,
15
+ "hidden_size": 768,
16
+ "id2label": {
17
+ "0": "LABEL_0"
18
+ },
19
+ "initializer_range": 0.02,
20
+ "intermediate_size": 3072,
21
+ "label2id": {
22
+ "LABEL_0": 0
23
+ },
24
+ "layer_norm_eps": 1e-12,
25
+ "max_position_embeddings": 512,
26
+ "model_type": "electra",
27
+ "num_attention_heads": 12,
28
+ "num_hidden_layers": 12,
29
+ "pad_token_id": 0,
30
+ "pooling_strategy": "first",
31
+ "position_embedding_type": "absolute",
32
+ "query_length": 32,
33
+ "sentence_transformers": {
34
+ "activation_fn": "torch.nn.modules.linear.Identity",
35
+ "version": "4.0.1"
36
+ },
37
+ "summary_activation": "gelu",
38
+ "summary_last_dropout": 0.1,
39
+ "summary_type": "first",
40
+ "summary_use_proj": true,
41
+ "torch_dtype": "float32",
42
+ "transformers_version": "4.49.0",
43
+ "type_vocab_size": 2,
44
+ "use_cache": true,
45
+ "vocab_size": 30522
46
+ }
special_tokens_map.json CHANGED
@@ -1,37 +1,37 @@
1
- {
2
- "cls_token": {
3
- "content": "[CLS]",
4
- "lstrip": false,
5
- "normalized": false,
6
- "rstrip": false,
7
- "single_word": false
8
- },
9
- "mask_token": {
10
- "content": "[MASK]",
11
- "lstrip": false,
12
- "normalized": false,
13
- "rstrip": false,
14
- "single_word": false
15
- },
16
- "pad_token": {
17
- "content": "[PAD]",
18
- "lstrip": false,
19
- "normalized": false,
20
- "rstrip": false,
21
- "single_word": false
22
- },
23
- "sep_token": {
24
- "content": "[SEP]",
25
- "lstrip": false,
26
- "normalized": false,
27
- "rstrip": false,
28
- "single_word": false
29
- },
30
- "unk_token": {
31
- "content": "[UNK]",
32
- "lstrip": false,
33
- "normalized": false,
34
- "rstrip": false,
35
- "single_word": false
36
- }
37
- }
 
1
+ {
2
+ "cls_token": {
3
+ "content": "[CLS]",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "mask_token": {
10
+ "content": "[MASK]",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "[PAD]",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "sep_token": {
24
+ "content": "[SEP]",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ },
30
+ "unk_token": {
31
+ "content": "[UNK]",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false
36
+ }
37
+ }
tokenizer_config.json CHANGED
@@ -1,58 +1,57 @@
1
- {
2
- "added_tokens_decoder": {
3
- "0": {
4
- "content": "[PAD]",
5
- "lstrip": false,
6
- "normalized": false,
7
- "rstrip": false,
8
- "single_word": false,
9
- "special": true
10
- },
11
- "100": {
12
- "content": "[UNK]",
13
- "lstrip": false,
14
- "normalized": false,
15
- "rstrip": false,
16
- "single_word": false,
17
- "special": true
18
- },
19
- "101": {
20
- "content": "[CLS]",
21
- "lstrip": false,
22
- "normalized": false,
23
- "rstrip": false,
24
- "single_word": false,
25
- "special": true
26
- },
27
- "102": {
28
- "content": "[SEP]",
29
- "lstrip": false,
30
- "normalized": false,
31
- "rstrip": false,
32
- "single_word": false,
33
- "special": true
34
- },
35
- "103": {
36
- "content": "[MASK]",
37
- "lstrip": false,
38
- "normalized": false,
39
- "rstrip": false,
40
- "single_word": false,
41
- "special": true
42
- }
43
- },
44
- "clean_up_tokenization_spaces": true,
45
- "cls_token": "[CLS]",
46
- "do_lower_case": true,
47
- "doc_length": 256,
48
- "extra_special_tokens": {},
49
- "mask_token": "[MASK]",
50
- "model_max_length": 512,
51
- "pad_token": "[PAD]",
52
- "query_length": 32,
53
- "sep_token": "[SEP]",
54
- "strip_accents": null,
55
- "tokenize_chinese_chars": true,
56
- "tokenizer_class": "ElectraTokenizer",
57
- "unk_token": "[UNK]"
58
- }
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": true,
45
+ "cls_token": "[CLS]",
46
+ "do_lower_case": true,
47
+ "doc_length": 256,
48
+ "mask_token": "[MASK]",
49
+ "model_max_length": 512,
50
+ "pad_token": "[PAD]",
51
+ "query_length": 32,
52
+ "sep_token": "[SEP]",
53
+ "strip_accents": null,
54
+ "tokenize_chinese_chars": true,
55
+ "tokenizer_class": "ElectraTokenizer",
56
+ "unk_token": "[UNK]"
57
+ }