phonghoccode commited on
Commit
a725b03
·
verified ·
1 Parent(s): f31e022

Add new CrossEncoder 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
README.md ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - sentence-transformers
4
+ - cross-encoder
5
+ - reranker
6
+ pipeline_tag: text-ranking
7
+ library_name: sentence-transformers
8
+ ---
9
+
10
+ # CrossEncoder
11
+
12
+ This is a [Cross Encoder](https://www.sbert.net/docs/cross_encoder/usage/usage.html) model trained using the [sentence-transformers](https://www.SBERT.net) library. It computes scores for pairs of texts, which can be used for text reranking and semantic search.
13
+
14
+ ## Model Details
15
+
16
+ ### Model Description
17
+ - **Model Type:** Cross Encoder
18
+ <!-- - **Base model:** [Unknown](https://huggingface.co/unknown) -->
19
+ - **Maximum Sequence Length:** 8192 tokens
20
+ - **Number of Output Labels:** 1 label
21
+ <!-- - **Training Dataset:** Unknown -->
22
+ <!-- - **Language:** Unknown -->
23
+ <!-- - **License:** Unknown -->
24
+
25
+ ### Model Sources
26
+
27
+ - **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
28
+ - **Documentation:** [Cross Encoder Documentation](https://www.sbert.net/docs/cross_encoder/usage/usage.html)
29
+ - **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
30
+ - **Hugging Face:** [Cross Encoders on Hugging Face](https://huggingface.co/models?library=sentence-transformers&other=cross-encoder)
31
+
32
+ ## Usage
33
+
34
+ ### Direct Usage (Sentence Transformers)
35
+
36
+ First install the Sentence Transformers library:
37
+
38
+ ```bash
39
+ pip install -U sentence-transformers
40
+ ```
41
+
42
+ Then you can load this model and run inference.
43
+ ```python
44
+ from sentence_transformers import CrossEncoder
45
+
46
+ # Download from the 🤗 Hub
47
+ model = CrossEncoder("phonghoccode/ALQAC_2025_Reranker_top20")
48
+ # Get scores for pairs of texts
49
+ pairs = [
50
+ ['How many calories in an egg', 'There are on average between 55 and 80 calories in an egg depending on its size.'],
51
+ ['How many calories in an egg', 'Egg whites are very low in calories, have no fat, no cholesterol, and are loaded with protein.'],
52
+ ['How many calories in an egg', 'Most of the calories in an egg come from the yellow yolk in the center.'],
53
+ ]
54
+ scores = model.predict(pairs)
55
+ print(scores.shape)
56
+ # (3,)
57
+
58
+ # Or rank different texts based on similarity to a single text
59
+ ranks = model.rank(
60
+ 'How many calories in an egg',
61
+ [
62
+ 'There are on average between 55 and 80 calories in an egg depending on its size.',
63
+ 'Egg whites are very low in calories, have no fat, no cholesterol, and are loaded with protein.',
64
+ 'Most of the calories in an egg come from the yellow yolk in the center.',
65
+ ]
66
+ )
67
+ # [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]
68
+ ```
69
+
70
+ <!--
71
+ ### Direct Usage (Transformers)
72
+
73
+ <details><summary>Click to see the direct usage in Transformers</summary>
74
+
75
+ </details>
76
+ -->
77
+
78
+ <!--
79
+ ### Downstream Usage (Sentence Transformers)
80
+
81
+ You can finetune this model on your own dataset.
82
+
83
+ <details><summary>Click to expand</summary>
84
+
85
+ </details>
86
+ -->
87
+
88
+ <!--
89
+ ### Out-of-Scope Use
90
+
91
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
92
+ -->
93
+
94
+ <!--
95
+ ## Bias, Risks and Limitations
96
+
97
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
98
+ -->
99
+
100
+ <!--
101
+ ### Recommendations
102
+
103
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
104
+ -->
105
+
106
+ ## Training Details
107
+
108
+ ### Framework Versions
109
+ - Python: 3.10.12
110
+ - Sentence Transformers: 5.0.0
111
+ - Transformers: 4.53.2
112
+ - PyTorch: 2.7.0+cu126
113
+ - Accelerate: 1.8.1
114
+ - Datasets: 4.0.0
115
+ - Tokenizers: 0.21.2
116
+
117
+ ## Citation
118
+
119
+ ### BibTeX
120
+
121
+ <!--
122
+ ## Glossary
123
+
124
+ *Clearly define terms in order to be accessible across audiences.*
125
+ -->
126
+
127
+ <!--
128
+ ## Model Card Authors
129
+
130
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
131
+ -->
132
+
133
+ <!--
134
+ ## Model Card Contact
135
+
136
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
137
+ -->
config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "XLMRobertaForSequenceClassification"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "bos_token_id": 0,
7
+ "classifier_dropout": null,
8
+ "eos_token_id": 2,
9
+ "hidden_act": "gelu",
10
+ "hidden_dropout_prob": 0.1,
11
+ "hidden_size": 1024,
12
+ "id2label": {
13
+ "0": "LABEL_0"
14
+ },
15
+ "initializer_range": 0.02,
16
+ "intermediate_size": 4096,
17
+ "label2id": {
18
+ "LABEL_0": 0
19
+ },
20
+ "layer_norm_eps": 1e-05,
21
+ "max_position_embeddings": 8194,
22
+ "model_type": "xlm-roberta",
23
+ "num_attention_heads": 16,
24
+ "num_hidden_layers": 24,
25
+ "output_past": true,
26
+ "pad_token_id": 1,
27
+ "position_embedding_type": "absolute",
28
+ "sentence_transformers": {
29
+ "activation_fn": "torch.nn.modules.activation.Sigmoid",
30
+ "version": "5.0.0"
31
+ },
32
+ "torch_dtype": "float32",
33
+ "transformers_version": "4.53.2",
34
+ "type_vocab_size": 1,
35
+ "use_cache": true,
36
+ "vocab_size": 250002
37
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dbbc728c5da3bf96c632c542cce7adb23727caaa1f633a4d07046c6e3ff54c10
3
+ size 2271071852
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": true,
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:d222292c1bf630704e33d944a1379efe1bb1c5553d07bdd53bda8e0cdd7710fa
3
+ size 17082999
tokenizer_config.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": true,
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
+ "extra_special_tokens": {},
49
+ "mask_token": "<mask>",
50
+ "max_length": 2176,
51
+ "model_max_length": 8192,
52
+ "pad_token": "<pad>",
53
+ "sep_token": "</s>",
54
+ "sp_model_kwargs": {},
55
+ "stride": 0,
56
+ "tokenizer_class": "XLMRobertaTokenizer",
57
+ "truncation_side": "right",
58
+ "truncation_strategy": "longest_first",
59
+ "unk_token": "<unk>"
60
+ }