TheoDB commited on
Commit
4c56fc6
·
0 Parent(s):

BidirLM embedding model (transformers 5.x)

Browse files
.gitattributes ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz 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
+ final_results.png filter=lfs diff=lfs merge=lfs -text
37
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
1_Pooling/config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 2048,
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
+ "include_prompt": true
10
+ }
README.md ADDED
@@ -0,0 +1,254 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - mteb
4
+ - sentence-transformers
5
+ - transformers
6
+ - embedding
7
+ - bidirectional
8
+ - multilingual
9
+ pipeline_tag: sentence-similarity
10
+ license: apache-2.0
11
+ base_model: BidirLM/BidirLM-1.7B-Base
12
+ language:
13
+ - multilingual
14
+ - af
15
+ - am
16
+ - ar
17
+ - az
18
+ - be
19
+ - bg
20
+ - bn
21
+ - bs
22
+ - ca
23
+ - ceb
24
+ - cs
25
+ - cy
26
+ - da
27
+ - de
28
+ - el
29
+ - en
30
+ - es
31
+ - et
32
+ - eu
33
+ - fa
34
+ - fi
35
+ - fr
36
+ - ga
37
+ - gl
38
+ - gu
39
+ - ha
40
+ - he
41
+ - hi
42
+ - hr
43
+ - ht
44
+ - hu
45
+ - hy
46
+ - id
47
+ - ig
48
+ - is
49
+ - it
50
+ - ja
51
+ - jv
52
+ - ka
53
+ - kk
54
+ - kn
55
+ - ko
56
+ - ky
57
+ - lt
58
+ - lv
59
+ - mg
60
+ - mk
61
+ - ml
62
+ - mr
63
+ - ms
64
+ - mt
65
+ - my
66
+ - nb
67
+ - ne
68
+ - nl
69
+ - nso
70
+ - ny
71
+ - pa
72
+ - pl
73
+ - ps
74
+ - pt
75
+ - ro
76
+ - ru
77
+ - sd
78
+ - si
79
+ - sk
80
+ - sl
81
+ - sn
82
+ - so
83
+ - sq
84
+ - sr
85
+ - su
86
+ - sv
87
+ - sw
88
+ - ta
89
+ - te
90
+ - th
91
+ - tl
92
+ - tr
93
+ - uk
94
+ - ur
95
+ - vi
96
+ - wo
97
+ - xh
98
+ - yo
99
+ - zh
100
+ - zu
101
+ ---
102
+
103
+ # BidirLM-1.7B
104
+
105
+ BidirLM is a family of 5 frontier bidirectional encoders, including an omnimodal variant at 2.5B, adapted from causal decoder LLMs. Contrary to contrastive-only models, BidirLM relies on a prior masking phase (MNTP) that enables state-of-the-art results on task-specific fine-tuning (NER, classification, NLI) while achieving frontier performance on embedding benchmarks (MTEB) against open-source alternatives.
106
+
107
+ ![Multilingual model performance by size on XTREME-Benchmark Augmented and MTEB Multilingual V2](final_results.png)
108
+
109
+ > *From the paper. MTEB(Multilingual, v2) below matches the paper; the LongEmbed table reports additional long-context results.*
110
+
111
+ | Model | Base LLM | Parameters | Embedding Dim | Max Tokens | MTEB Multi. V2 (Mean Task) |
112
+ |---|---|---|---|---|---|
113
+ | BidirLM-270M | Gemma3-270M | 268M | 640 | 512 | 56.3 |
114
+ | BidirLM-0.6B | Qwen3-0.6B | 596M | 1024 | 512 | 60.0 |
115
+ | BidirLM-1B | Gemma3-1B | 1001M | 1152 | 512 | 62.7 |
116
+ | **BidirLM-1.7B** | **Qwen3-1.7B** | **1721M** | **2048** | **512** (\*) | **63.1** |
117
+ | BidirLM-Omni-2.5B | Qwen3-1.7B | 2.5B | 2048 | 512 | 63.1 |
118
+
119
+ (\*) Evaluated at `max_seq_length=512`, matching the paper. The architecture supports much longer context (see the LongEmbed table below); on the MTEB leaderboard the shared LEMBPasskeyRetrieval task is scored at long context, making the leaderboard MTEB(Multilingual, v2) ~0.4 higher than this table.
120
+
121
+ ## LongEmbed (Long-Context Retrieval)
122
+
123
+ Mean nDCG@10 over the 6 [LongEmbed](https://huggingface.co/datasets/dwzhu/LongEmbed) retrieval tasks. Each model is reported at the context length (8k or 32k) that maximizes its average; the architecture supports the base model's full context.
124
+
125
+ | Model | LongEmbed (Mean nDCG@10) | Eval Context |
126
+ |---|---|---|
127
+ | BidirLM-270M | 71.8 | 32k |
128
+ | BidirLM-0.6B | 71.9 | 8k |
129
+ | BidirLM-1B | 76.4 | 32k |
130
+ | **BidirLM-1.7B** | **73.4** | **8k** |
131
+
132
+ > **Note:** Extending the evaluation context from 8k to 32k helped the Gemma-based models (270M, 1B) but not the Qwen-based models (0.6B, 1.7B), which scored best at 8k.
133
+
134
+ ## Supported Tasks
135
+
136
+ **General embeddings** (via Sentence Transformers): retrieval, semantic similarity (STS), clustering, classification, pair classification, reranking, bitext mining, multilabel classification
137
+
138
+ **Downstream fine-tuning** (via Transformers): sequence classification (e.g. MNLI, XNLI, PAWS-X, MathShepherd), token classification (e.g. PAN-X, POS), information retrieval (e.g. MIRACL, CodeSearchNet), sequence regression (e.g. Seahorse)
139
+
140
+ ## Usage
141
+
142
+ ### Sentence Transformers
143
+
144
+ Use Sentence Transformers to compute embeddings for any text representation task.
145
+
146
+ ```python
147
+ from sentence_transformers import SentenceTransformer
148
+
149
+ model = SentenceTransformer("BidirLM/BidirLM-1.7B-Embedding", trust_remote_code=True)
150
+
151
+ queries = [
152
+ "What is the capital of France?",
153
+ "How does photosynthesis work?",
154
+ ]
155
+ documents = [
156
+ "Paris is the capital and largest city of France, situated on the river Seine.",
157
+ "Photosynthesis is the process by which plants convert sunlight, water, and CO2 into glucose and oxygen.",
158
+ ]
159
+
160
+ query_embeddings = model.encode(queries)
161
+ document_embeddings = model.encode(documents)
162
+
163
+ similarities = model.similarity(query_embeddings, document_embeddings)
164
+ print(similarities)
165
+ ```
166
+
167
+ ### Fine-tuning for Downstream Tasks
168
+
169
+ BidirLM can be directly fine-tuned for downstream tasks:
170
+
171
+ ```python
172
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoModelForTokenClassification
173
+
174
+ tokenizer = AutoTokenizer.from_pretrained("BidirLM/BidirLM-1.7B-Embedding", trust_remote_code=True)
175
+
176
+ # Sequence classification (e.g., NLI: entailment, neutral, contradiction)
177
+ seq_model = AutoModelForSequenceClassification.from_pretrained(
178
+ "BidirLM/BidirLM-1.7B-Embedding",
179
+ trust_remote_code=True,
180
+ num_labels=3,
181
+ )
182
+
183
+ # Token classification (e.g., NER)
184
+ tok_model = AutoModelForTokenClassification.from_pretrained(
185
+ "BidirLM/BidirLM-1.7B-Embedding",
186
+ trust_remote_code=True,
187
+ num_labels=7,
188
+ )
189
+
190
+ # Fine-tune with HuggingFace Trainer
191
+ ```
192
+
193
+ ## Evaluation
194
+
195
+ Please follow the [mteb repository](https://github.com/embeddings-benchmark/mteb) on how to reproduce our scores. The evaluation prompts used for each task are also available at [mteb_v2_eval_prompts.json](mteb_v2_eval_prompts.json).
196
+
197
+ ## Supported Languages
198
+
199
+ Multilingual support across over 119 languages, inherited from the Qwen3 base model and reinforced through contrastive training with 87 languages.
200
+
201
+ ## Requirements
202
+
203
+ This model requires `trust_remote_code=True` as it uses a custom bidirectional architecture.
204
+
205
+ ```
206
+ transformers>=5.0
207
+ sentence-transformers>=5.0.0
208
+ ```
209
+
210
+ > **Note:** This model was trained with `transformers==4.57.6` (transformers 4.x). The version on `main` was patched to work with `transformers>=5.0`. For the original (pre-patch) version, which is compatible with `transformers>=4.57.6,<5.0.0`, use the `transformers-v4` branch:
211
+ > ```python
212
+ > from sentence_transformers import SentenceTransformer
213
+ > model = SentenceTransformer(
214
+ > "BidirLM/BidirLM-1.7B-Embedding",
215
+ > trust_remote_code=True,
216
+ > revision="transformers-v4",
217
+ > )
218
+ > ```
219
+
220
+ ## FAQ
221
+
222
+ ### 1. What pooling strategy does this model use?
223
+
224
+ The model uses **mean pooling**. This is handled automatically when using Sentence Transformers.
225
+
226
+ ### 2. Do I need `trust_remote_code=True`?
227
+
228
+ Yes. BidirLM uses a custom bidirectional architecture (`BidirLMModel`) that requires loading custom code from the repository.
229
+
230
+ ### 3. Why are my reproduced results slightly different from those reported in the model card?
231
+
232
+ Different versions of `transformers` and `pytorch` could cause negligible but non-zero performance differences. This model should be used with `transformers>=5.0` (evaluated with `transformers==5.5.4` and `pytorch==2.6.0`).
233
+
234
+ ### 4. What is the relationship between BidirLM-1.7B and BidirLM-1.7B-Base?
235
+
236
+ [BidirLM/BidirLM-1.7B-Base](https://huggingface.co/BidirLM/BidirLM-1.7B-Base) is the intermediate MNTP-adapted checkpoint (bidirectional pretraining stage). BidirLM-1.7B is the final contrastive fine-tuned version optimized for both sentence embeddings and downstream fine-tuning.
237
+
238
+ ### 5. How is BidirLM different from other embedding models?
239
+
240
+ Most embedding models (BGE-M3, KaLM, EmbedGemma, Qwen3-Embedding) use contrastive-only training, which optimizes embeddings but sacrifices fine-tuning ability. BidirLM restores a prior MNTP phase, advancing the Pareto frontier on both MTEB and XTREME simultaneously.
241
+
242
+ ## Citation
243
+
244
+ ```bibtex
245
+ @misc{boizard2026bidirlmtextomnimodalbidirectional,
246
+ title={BidirLM: From Text to Omnimodal Bidirectional Encoders by Adapting and Composing Causal LLMs},
247
+ author={Nicolas Boizard and Théo Deschamps-Berger and Hippolyte Gisserot-Boukhlef and Céline Hudelot and Pierre Colombo},
248
+ year={2026},
249
+ eprint={2604.02045},
250
+ archivePrefix={arXiv},
251
+ primaryClass={cs.CL},
252
+ url={https://arxiv.org/abs/2604.02045},
253
+ }
254
+ ```
added_tokens.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</think>": 151668,
3
+ "</tool_call>": 151658,
4
+ "</tool_response>": 151666,
5
+ "<think>": 151667,
6
+ "<tool_call>": 151657,
7
+ "<tool_response>": 151665,
8
+ "<|box_end|>": 151649,
9
+ "<|box_start|>": 151648,
10
+ "<|endoftext|>": 151643,
11
+ "<|file_sep|>": 151664,
12
+ "<|fim_middle|>": 151660,
13
+ "<|fim_pad|>": 151662,
14
+ "<|fim_prefix|>": 151659,
15
+ "<|fim_suffix|>": 151661,
16
+ "<|im_end|>": 151645,
17
+ "<|im_start|>": 151644,
18
+ "<|image_pad|>": 151655,
19
+ "<|mask|>": 151663,
20
+ "<|object_ref_end|>": 151647,
21
+ "<|object_ref_start|>": 151646,
22
+ "<|quad_end|>": 151651,
23
+ "<|quad_start|>": 151650,
24
+ "<|video_pad|>": 151656,
25
+ "<|vision_end|>": 151653,
26
+ "<|vision_pad|>": 151654,
27
+ "<|vision_start|>": 151652
28
+ }
config.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BidirLMModel"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_bidirlm.BidirLMConfig",
9
+ "AutoModel": "modeling_bidirlm.BidirLMModel",
10
+ "AutoModelForMaskedLM": "modeling_bidirlm.BidirLMForMaskedLM",
11
+ "AutoModelForSequenceClassification": "modeling_bidirlm.BidirLMForSequenceClassification",
12
+ "AutoModelForTokenClassification": "modeling_bidirlm.BidirLMForTokenClassification"
13
+ },
14
+ "bos_token_id": 151644,
15
+ "clf_pooling": "late",
16
+ "dtype": "bfloat16",
17
+ "eos_token_id": 151645,
18
+ "head_dim": 128,
19
+ "hidden_act": "silu",
20
+ "hidden_size": 2048,
21
+ "initializer_range": 0.02,
22
+ "intermediate_size": 6144,
23
+ "mask_token": "<|mask|>",
24
+ "mask_token_id": 151663,
25
+ "max_position_embeddings": 32768,
26
+ "max_window_layers": 28,
27
+ "model_type": "bidirlm",
28
+ "num_attention_heads": 16,
29
+ "num_hidden_layers": 28,
30
+ "num_key_value_heads": 8,
31
+ "rms_norm_eps": 1e-06,
32
+ "rope_scaling": null,
33
+ "rope_theta": 1000000,
34
+ "tie_word_embeddings": true,
35
+ "transformers_version": "5.9.0",
36
+ "vocab_size": 151936
37
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "SentenceTransformer",
3
+ "__version__": {
4
+ "sentence_transformers": "5.2.3",
5
+ "transformers": "4.57.6",
6
+ "pytorch": "2.6.0"
7
+ },
8
+ "prompts": {
9
+ "query": "",
10
+ "document": ""
11
+ },
12
+ "default_prompt_name": null,
13
+ "similarity_fn_name": "cosine"
14
+ }
configuration_bidirlm.py ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2024 The Qwen team, Alibaba Group and the HuggingFace Inc. team. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """BidirLM model configuration"""
16
+
17
+ import transformers
18
+ _v = transformers.__version__
19
+ if _v < "5.0.0":
20
+ raise ImportError(
21
+ f"BidirLM requires transformers>=5.0.0 on this branch (found {_v}). "
22
+ f"Install a compatible version: pip install 'transformers>=5.0.0'. "
23
+ f"For transformers 4.x, use the `transformers-v4` branch instead."
24
+ )
25
+
26
+ from transformers.configuration_utils import PretrainedConfig
27
+ from transformers.modeling_rope_utils import rope_config_validation
28
+ from transformers.utils import logging
29
+
30
+
31
+ logger = logging.get_logger(__name__)
32
+
33
+
34
+ class BidirLMConfig(PretrainedConfig):
35
+ r"""
36
+ This is the configuration class to store the configuration of a [`BidirLMModel`]. It is used to instantiate a
37
+ BidirLM model according to the specified arguments, defining the model architecture. Instantiating a configuration
38
+ with the defaults will yield a similar configuration to that of
39
+ Qwen3-8B [Qwen/Qwen3-8B](https://huggingface.co/Qwen/Qwen3-8B) WITH BIDIRECTIONAL ATTENTION MECHANISM.
40
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
41
+ documentation from [`PretrainedConfig`] for more information.
42
+ Args:
43
+ vocab_size (`int`, *optional*, defaults to 151936):
44
+ Vocabulary size of the Qwen3 model. Defines the number of different tokens that can be represented by the
45
+ `inputs_ids` passed when calling [`Qwen3Model`]
46
+ hidden_size (`int`, *optional*, defaults to 4096):
47
+ Dimension of the hidden representations.
48
+ intermediate_size (`int`, *optional*, defaults to 22016):
49
+ Dimension of the MLP representations.
50
+ num_hidden_layers (`int`, *optional*, defaults to 32):
51
+ Number of hidden layers in the Transformer encoder.
52
+ num_attention_heads (`int`, *optional*, defaults to 32):
53
+ Number of attention heads for each attention layer in the Transformer encoder.
54
+ num_key_value_heads (`int`, *optional*, defaults to 32):
55
+ This is the number of key_value heads that should be used to implement Grouped Query Attention. If
56
+ `num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
57
+ `num_key_value_heads=1` the model will use Multi Query Attention (MQA) otherwise GQA is used. When
58
+ converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
59
+ by meanpooling all the original heads within that group. For more details, check out [this
60
+ paper](https://huggingface.co/papers/2305.13245). If it is not specified, will default to `32`.
61
+ head_dim (`int`, *optional*, defaults to 128):
62
+ The attention head dimension.
63
+ hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
64
+ The non-linear activation function (function or string) in the decoder.
65
+ max_position_embeddings (`int`, *optional*, defaults to 32768):
66
+ The maximum sequence length that this model might ever be used with.
67
+ initializer_range (`float`, *optional*, defaults to 0.02):
68
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
69
+ rms_norm_eps (`float`, *optional*, defaults to 1e-06):
70
+ The epsilon used by the rms normalization layers.
71
+ tie_word_embeddings (`bool`, *optional*, defaults to `False`):
72
+ Whether the model's input and output word embeddings should be tied.
73
+ rope_theta (`float`, *optional*, defaults to 10000.0):
74
+ The base period of the RoPE embeddings.
75
+ rope_scaling (`Dict`, *optional*):
76
+ Dictionary containing the scaling configuration for the RoPE embeddings. NOTE: if you apply new rope type
77
+ and you expect the model to work on longer `max_position_embeddings`, we recommend you to update this value
78
+ accordingly.
79
+ Expected contents:
80
+ `rope_type` (`str`):
81
+ The sub-variant of RoPE to use. Can be one of ['default', 'linear', 'dynamic', 'yarn', 'longrope',
82
+ 'llama3'], with 'default' being the original RoPE implementation.
83
+ `factor` (`float`, *optional*):
84
+ Used with all rope types except 'default'. The scaling factor to apply to the RoPE embeddings. In
85
+ most scaling types, a `factor` of x will enable the model to handle sequences of length x *
86
+ original maximum pre-trained length.
87
+ `original_max_position_embeddings` (`int`, *optional*):
88
+ Used with 'dynamic', 'longrope' and 'llama3'. The original max position embeddings used during
89
+ pretraining.
90
+ `attention_factor` (`float`, *optional*):
91
+ Used with 'yarn' and 'longrope'. The scaling factor to be applied on the attention
92
+ computation. If unspecified, it defaults to value recommended by the implementation, using the
93
+ `factor` field to infer the suggested value.
94
+ `beta_fast` (`float`, *optional*):
95
+ Only used with 'yarn'. Parameter to set the boundary for extrapolation (only) in the linear
96
+ ramp function. If unspecified, it defaults to 32.
97
+ `beta_slow` (`float`, *optional*):
98
+ Only used with 'yarn'. Parameter to set the boundary for interpolation (only) in the linear
99
+ ramp function. If unspecified, it defaults to 1.
100
+ `short_factor` (`list[float]`, *optional*):
101
+ Only used with 'longrope'. The scaling factor to be applied to short contexts (<
102
+ `original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
103
+ size divided by the number of attention heads divided by 2
104
+ `long_factor` (`list[float]`, *optional*):
105
+ Only used with 'longrope'. The scaling factor to be applied to long contexts (<
106
+ `original_max_position_embeddings`). Must be a list of numbers with the same length as the hidden
107
+ size divided by the number of attention heads divided by 2
108
+ `low_freq_factor` (`float`, *optional*):
109
+ Only used with 'llama3'. Scaling factor applied to low frequency components of the RoPE
110
+ `high_freq_factor` (`float`, *optional*):
111
+ Only used with 'llama3'. Scaling factor applied to high frequency components of the RoPE
112
+ attention_bias (`bool`, defaults to `False`, *optional*, defaults to `False`):
113
+ Whether to use a bias in the query, key, value and output projection layers during self-attention.
114
+ layer_types (`list`, *optional*):
115
+ Attention pattern for each layer.
116
+ attention_dropout (`float`, *optional*, defaults to 0.0):
117
+ The dropout ratio for the attention probabilities.
118
+ ```python
119
+ >>> from transformers import Qwen3Model, Qwen3Config
120
+ >>> # Initializing a Qwen3 style configuration
121
+ >>> configuration = Qwen3Config()
122
+ >>> # Initializing a model from the Qwen3-8B style configuration
123
+ >>> model = Qwen3Model(configuration)
124
+ >>> # Accessing the model configuration
125
+ >>> configuration = model.config
126
+ ```"""
127
+
128
+ model_type = "bidirlm"
129
+ keys_to_ignore_at_inference = ["past_key_values"]
130
+
131
+ # Default tensor parallel plan for base model, same than `Qwen3`
132
+ base_model_tp_plan = {
133
+ "layers.*.self_attn.q_proj": "colwise",
134
+ "layers.*.self_attn.k_proj": "colwise",
135
+ "layers.*.self_attn.v_proj": "colwise",
136
+ "layers.*.self_attn.o_proj": "rowwise",
137
+ "layers.*.mlp.gate_proj": "colwise",
138
+ "layers.*.mlp.up_proj": "colwise",
139
+ "layers.*.mlp.down_proj": "rowwise",
140
+ }
141
+ base_model_pp_plan = {
142
+ "embed_tokens": (["input_ids"], ["inputs_embeds"]),
143
+ "layers": (["hidden_states", "attention_mask"], ["hidden_states"]),
144
+ "norm": (["hidden_states"], ["hidden_states"]),
145
+ }
146
+
147
+ @property
148
+ def effective_sliding_window(self):
149
+ # Per-side sliding window used at attention time. For bidirectional
150
+ # models the configured (total) window is split symmetrically, so
151
+ # each side is half. Derived at runtime so the full `sliding_window`
152
+ # is what gets persisted (no halving on every save/load).
153
+ sw = getattr(self, "sliding_window", None)
154
+ if sw is None:
155
+ return None
156
+ if getattr(self, "use_bidirectional_attention", False):
157
+ return sw // 2
158
+ return sw
159
+
160
+
161
+ def __init__(
162
+ self,
163
+ vocab_size=151936,
164
+ hidden_size=4096,
165
+ intermediate_size=22016,
166
+ num_hidden_layers=32,
167
+ num_attention_heads=32,
168
+ num_key_value_heads=32,
169
+ head_dim=128,
170
+ hidden_act="silu",
171
+ max_position_embeddings=32768,
172
+ initializer_range=0.02,
173
+ rms_norm_eps=1e-6,
174
+ tie_word_embeddings=False,
175
+ rope_theta=10000.0,
176
+ rope_scaling=None,
177
+ attention_bias=False,
178
+ attention_dropout=0.0,
179
+ pad_token_id=None,
180
+ bos_token_id=None,
181
+ eos_token_id=None,
182
+ classifier_pooling="late",
183
+ **kwargs,
184
+ ):
185
+ self.vocab_size = vocab_size
186
+ self.max_position_embeddings = max_position_embeddings
187
+ self.hidden_size = hidden_size
188
+ self.intermediate_size = intermediate_size
189
+ self.num_hidden_layers = num_hidden_layers
190
+ self.num_attention_heads = num_attention_heads
191
+
192
+ # for backward compatibility
193
+ if num_key_value_heads is None:
194
+ num_key_value_heads = num_attention_heads
195
+
196
+ self.num_key_value_heads = num_key_value_heads
197
+ self.head_dim = head_dim
198
+ self.hidden_act = hidden_act
199
+ self.initializer_range = initializer_range
200
+ self.rms_norm_eps = rms_norm_eps
201
+ self.rope_theta = rope_theta
202
+ self.rope_scaling = rope_scaling
203
+ self.attention_bias = attention_bias
204
+ self.attention_dropout = attention_dropout
205
+ self.clf_pooling = classifier_pooling
206
+ # Validate the correctness of rotary position embeddings parameters
207
+ # BC: if there is a 'type' field, move it to 'rope_type'.
208
+ if self.rope_scaling is not None and "type" in self.rope_scaling:
209
+ self.rope_scaling["rope_type"] = self.rope_scaling["type"]
210
+ rope_config_validation(self)
211
+
212
+ super().__init__(
213
+ pad_token_id=pad_token_id,
214
+ bos_token_id=bos_token_id,
215
+ eos_token_id=eos_token_id,
216
+ tie_word_embeddings=tie_word_embeddings,
217
+ **kwargs,
218
+ )
219
+
220
+
221
+ __all__ = ["BidirLMConfig"]
final_results.png ADDED

Git LFS Details

  • SHA256: 165257135cb40c3b9e7dcec94d225a0cce3a5c12f9ef0d152972eec048d0493a
  • Pointer size: 131 Bytes
  • Size of remote file: 738 kB
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a2a2a2eeaaa73e3e29716d1fef24ef78e3428b383020964db570ad0169cf9dbb
3
+ size 3441183752
modeling_bidirlm.py ADDED
@@ -0,0 +1,676 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Optional
2
+
3
+ import transformers
4
+ _v = transformers.__version__
5
+ if _v < "5.0.0":
6
+ raise ImportError(
7
+ f"BidirLM requires transformers>=5.0.0 on this branch (found {_v}). "
8
+ f"Install a compatible version: pip install 'transformers>=5.0.0'. "
9
+ f"For transformers 4.x, use the `transformers-v4` branch instead."
10
+ )
11
+
12
+ import torch
13
+ from torch import nn
14
+ from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
15
+
16
+ from transformers.activations import ACT2FN
17
+ from transformers.modeling_attn_mask_utils import AttentionMaskConverter
18
+ from transformers.modeling_layers import (
19
+ GradientCheckpointingLayer,
20
+ )
21
+ from transformers.modeling_rope_utils import ROPE_INIT_FUNCTIONS, dynamic_rope_update
22
+ from transformers.modeling_utils import PreTrainedModel
23
+ from .configuration_bidirlm import BidirLMConfig
24
+
25
+ from transformers.modeling_outputs import BaseModelOutput, MaskedLMOutput, SequenceClassifierOutput, TokenClassifierOutput
26
+
27
+ try:
28
+ import flash_attn
29
+ FLASH_ATTN_AVAILABLE = True
30
+ except ImportError:
31
+ FLASH_ATTN_AVAILABLE = False
32
+
33
+ class Qwen3RMSNorm(nn.Module):
34
+ def __init__(self, hidden_size, eps=1e-6):
35
+ """
36
+ Qwen3RMSNorm is equivalent to T5LayerNorm
37
+ """
38
+ super().__init__()
39
+ self.weight = nn.Parameter(torch.ones(hidden_size))
40
+ self.variance_epsilon = eps
41
+
42
+ def forward(self, hidden_states):
43
+ input_dtype = hidden_states.dtype
44
+ hidden_states = hidden_states.to(torch.float32)
45
+ variance = hidden_states.pow(2).mean(-1, keepdim=True)
46
+ hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
47
+ return self.weight * hidden_states.to(input_dtype)
48
+
49
+ def extra_repr(self):
50
+ return f"{tuple(self.weight.shape)}, eps={self.variance_epsilon}"
51
+
52
+
53
+ class Qwen3MLP(nn.Module):
54
+ def __init__(self, config):
55
+ super().__init__()
56
+ self.config = config
57
+ self.hidden_size = config.hidden_size
58
+ self.intermediate_size = config.intermediate_size
59
+ self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
60
+ self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
61
+ self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
62
+ self.act_fn = ACT2FN[config.hidden_act]
63
+
64
+ def forward(self, x):
65
+ down_proj = self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
66
+ return down_proj
67
+
68
+
69
+ def rotate_half(x):
70
+ """Rotates half the hidden dims of the input."""
71
+ x1 = x[..., : x.shape[-1] // 2]
72
+ x2 = x[..., x.shape[-1] // 2 :]
73
+ return torch.cat((-x2, x1), dim=-1)
74
+
75
+
76
+ def apply_rotary_pos_emb(q, k, cos, sin, position_ids=None, unsqueeze_dim=1):
77
+ """Applies Rotary Position Embedding to the query and key tensors.
78
+
79
+ Args:
80
+ q (`torch.Tensor`): The query tensor.
81
+ k (`torch.Tensor`): The key tensor.
82
+ cos (`torch.Tensor`): The cosine part of the rotary embedding.
83
+ sin (`torch.Tensor`): The sine part of the rotary embedding.
84
+ position_ids (`torch.Tensor`, *optional*):
85
+ Deprecated and unused.
86
+ unsqueeze_dim (`int`, *optional*, defaults to 1):
87
+ The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and
88
+ sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note
89
+ that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and
90
+ k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes
91
+ cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have
92
+ the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2.
93
+ Returns:
94
+ `tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding.
95
+ """
96
+ cos = cos.unsqueeze(unsqueeze_dim)
97
+ sin = sin.unsqueeze(unsqueeze_dim)
98
+ q_embed = (q * cos) + (rotate_half(q) * sin)
99
+ k_embed = (k * cos) + (rotate_half(k) * sin)
100
+ return q_embed, k_embed
101
+
102
+
103
+ def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
104
+ """
105
+ This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
106
+ num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
107
+ """
108
+ num_key_value_heads, slen, head_dim = hidden_states.shape
109
+ if n_rep == 1:
110
+ return hidden_states
111
+ hidden_states = hidden_states[:, None, :, :].expand(num_key_value_heads, n_rep, slen, head_dim)
112
+ return hidden_states.reshape(num_key_value_heads * n_rep, slen, head_dim)
113
+
114
+ def batch_input_to_cu_seqlens(x: torch.Tensor, attention_mask: torch.Tensor):
115
+ lengths = attention_mask.sum(dim=1)
116
+ max_seqlen = int(lengths.max().item())
117
+ cu_seqlens = torch.zeros(lengths.size(0) + 1, dtype=torch.int32, device=x.device)
118
+ cu_seqlens[1:] = torch.cumsum(lengths, dim=0)
119
+ x = x[attention_mask.bool()]
120
+ return x, cu_seqlens, max_seqlen
121
+
122
+ def cu_seqlens_to_batch_input(x: torch.Tensor, cu_seqlens: torch.Tensor, max_seqlen: int):
123
+ B = cu_seqlens.size(0) - 1
124
+ D = x.size(1)
125
+ idx = torch.arange(max_seqlen, device=x.device).expand(B, max_seqlen)
126
+ lens = (cu_seqlens[1:] - cu_seqlens[:-1]).unsqueeze(1)
127
+ mask = idx < lens
128
+ base = cu_seqlens[:-1].unsqueeze(1)
129
+ gather_idx = (idx + base) * mask
130
+ out = torch.zeros(B, max_seqlen, D, device=x.device, dtype=x.dtype)
131
+ out[mask] = x[gather_idx[mask]]
132
+ return out
133
+
134
+ def cu_attention_weight_to_batch(hidden_states, cu_seqlens, max_seqlen):
135
+ H, T, _ = hidden_states.shape
136
+ device = hidden_states.device
137
+ cu_seqlens = cu_seqlens.to(device, dtype=torch.long)
138
+
139
+ B = cu_seqlens.numel() - 1
140
+ start = cu_seqlens[:-1]
141
+ end = cu_seqlens[1:]
142
+ L = end - start
143
+
144
+ p = torch.arange(max_seqlen, device=device)
145
+ valid = p.unsqueeze(0) < L.unsqueeze(1)
146
+
147
+ rel = p.unsqueeze(0)
148
+ abs_idx = start.unsqueeze(1) + rel
149
+ abs_idx = torch.where(valid, abs_idx, torch.zeros_like(abs_idx))
150
+
151
+ attn = hidden_states.unsqueeze(0).expand(B, -1, -1, -1)
152
+
153
+ row_index = abs_idx[:, None, :, None].expand(B, H, max_seqlen, T)
154
+ attn_rows = torch.gather(attn, dim=2, index=row_index)
155
+
156
+ col_index = abs_idx[:, None, None, :].expand(B, H, max_seqlen, max_seqlen)
157
+ attn_padded = torch.gather(attn_rows, dim=3, index=col_index)
158
+
159
+ mask = valid.to(attn_padded.dtype)
160
+ attn_padded = attn_padded * mask[:, None, :, None] * mask[:, None, None, :]
161
+
162
+ return attn_padded
163
+
164
+ def create_packed_seqs_mask(
165
+ cu_seqlens: torch.Tensor,
166
+ causal: bool = True,
167
+ device: torch.device = torch.device("cpu"),
168
+ ) -> torch.Tensor:
169
+ """
170
+ Create a causal or non-causal attention mask for packed sequences.
171
+
172
+ Args:
173
+ cu_seqlens (torch.Tensor): Cumulative sequence lengths of shape [batch + 1].
174
+ is_causal (bool): If True, create a causal (lower triangular) mask within
175
+ each sequence. If False, a full attention mask is created within each sequence.
176
+ device (torch.device): Target device for the mask.
177
+
178
+ Returns:
179
+ torch.Tensor: Attention mask of shape [total_len, total_len] with 0.0 (allowed)
180
+ and -inf (masked).
181
+ """
182
+ total_len = cu_seqlens[-1].item()
183
+ seq_lengths = cu_seqlens[1:] - cu_seqlens[:-1]
184
+
185
+ seq_indices = torch.repeat_interleave(
186
+ torch.arange(len(seq_lengths), device=device),
187
+ seq_lengths
188
+ )
189
+
190
+ seq_mask = seq_indices.unsqueeze(0) == seq_indices.unsqueeze(1)
191
+
192
+ if causal:
193
+ causal_mask = torch.tril(torch.ones(total_len, total_len, device=device, dtype=torch.bool))
194
+ combined_mask = seq_mask & causal_mask
195
+ else:
196
+ combined_mask = seq_mask
197
+
198
+ attention_mask = torch.full((total_len, total_len), float('-inf'), device=device)
199
+ attention_mask.masked_fill_(combined_mask, 0.0)
200
+
201
+ return attention_mask
202
+
203
+ def sdpa_attention_forward(
204
+ q, k, v,
205
+ cu_seqlens,
206
+ scaling,
207
+ dropout: float = 0.0,
208
+ causal: bool = True
209
+ ):
210
+ """Compute scaled dot-product attention for packed sequences."""
211
+ attn_weights = torch.matmul(q, k.transpose(1, 2)) * scaling
212
+
213
+ mask = create_packed_seqs_mask(cu_seqlens, causal, q.device)
214
+ attn_weights = attn_weights + mask
215
+
216
+ attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(q.dtype)
217
+ attn_weights = nn.functional.dropout(attn_weights, p=dropout)
218
+ attn_output = torch.matmul(attn_weights, v)
219
+ attn_output = attn_output.transpose(0, 1).contiguous()
220
+
221
+ return attn_output, attn_weights
222
+
223
+ class Qwen3Attention(nn.Module):
224
+ """Multi-headed attention from 'Attention Is All You Need' paper"""
225
+
226
+ def __init__(self, config: BidirLMConfig):
227
+ super().__init__()
228
+ self.config = config
229
+ self.head_dim = getattr(config, "head_dim", config.hidden_size // config.num_attention_heads)
230
+ self.num_key_value_groups = config.num_attention_heads // config.num_key_value_heads
231
+ self.scaling = self.head_dim**-0.5
232
+ self.attention_dropout = config.attention_dropout
233
+
234
+ self.q_proj = nn.Linear(
235
+ config.hidden_size, config.num_attention_heads * self.head_dim, bias=config.attention_bias
236
+ )
237
+ self.k_proj = nn.Linear(
238
+ config.hidden_size, config.num_key_value_heads * self.head_dim, bias=config.attention_bias
239
+ )
240
+ self.v_proj = nn.Linear(
241
+ config.hidden_size, config.num_key_value_heads * self.head_dim, bias=config.attention_bias
242
+ )
243
+ self.o_proj = nn.Linear(
244
+ config.num_attention_heads * self.head_dim, config.hidden_size, bias=config.attention_bias
245
+ )
246
+ self.q_norm = Qwen3RMSNorm(self.head_dim, eps=config.rms_norm_eps) # unlike olmo, only on the head dim!
247
+ self.k_norm = Qwen3RMSNorm(self.head_dim, eps=config.rms_norm_eps) # thus post q_norm does not need reshape
248
+
249
+ def forward(
250
+ self,
251
+ hidden_states: torch.Tensor,
252
+ position_embeddings: tuple[torch.Tensor, torch.Tensor],
253
+ cu_seqlens: Optional[torch.Tensor],
254
+ max_seqlen: Optional[int],
255
+ ) -> tuple[torch.Tensor, Optional[torch.Tensor], Optional[tuple[torch.Tensor]]]:
256
+ input_shape = hidden_states.shape[:-1]
257
+ hidden_shape = (*input_shape, -1, self.head_dim)
258
+
259
+ query_states = self.q_norm(self.q_proj(hidden_states).view(hidden_shape)).transpose(0, 1)
260
+ key_states = self.k_norm(self.k_proj(hidden_states).view(hidden_shape)).transpose(0, 1)
261
+ value_states = self.v_proj(hidden_states).view(hidden_shape).transpose(0, 1)
262
+
263
+ query_states, key_states = query_states.unsqueeze(0), key_states.unsqueeze(0),
264
+ cos, sin = position_embeddings
265
+ query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
266
+ query_states, key_states = query_states.squeeze(0), key_states.squeeze(0),
267
+
268
+ key_states = repeat_kv(key_states, self.num_key_value_groups)
269
+ value_states = repeat_kv(value_states, self.num_key_value_groups)
270
+
271
+ if self.config._attn_implementation == "flash_attention_2":
272
+ attn_weights = None
273
+ attn_output = flash_attn.flash_attn_varlen_func(
274
+ query_states.transpose(0, 1),
275
+ key_states.transpose(0, 1),
276
+ value_states.transpose(0, 1),
277
+ cu_seqlens,
278
+ cu_seqlens,
279
+ max_seqlen_q=max_seqlen,
280
+ max_seqlen_k=max_seqlen,
281
+ dropout_p=self.attention_dropout if self.training else 0.0,
282
+ softmax_scale=self.scaling,
283
+ causal=False,
284
+ ).contiguous()
285
+ else:
286
+ attn_output, attn_weights = sdpa_attention_forward(
287
+ query_states,
288
+ key_states,
289
+ value_states,
290
+ cu_seqlens=cu_seqlens,
291
+ dropout=self.attention_dropout if self.training else 0.0,
292
+ scaling=self.scaling,
293
+ causal=False,
294
+ )
295
+ attn_output = attn_output.reshape(*input_shape, -1).contiguous()
296
+ attn_output = self.o_proj(attn_output)
297
+
298
+ return attn_output, attn_weights
299
+
300
+
301
+ class Qwen3EncoderLayer(GradientCheckpointingLayer):
302
+ def __init__(self, config: BidirLMConfig):
303
+ super().__init__()
304
+ self.hidden_size = config.hidden_size
305
+
306
+ self.self_attn = Qwen3Attention(config=config)
307
+
308
+ self.mlp = Qwen3MLP(config)
309
+ self.input_layernorm = Qwen3RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
310
+ self.post_attention_layernorm = Qwen3RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
311
+
312
+ def forward(
313
+ self,
314
+ hidden_states: torch.Tensor,
315
+ cu_seqlens: Optional[torch.Tensor] = None,
316
+ max_seqlen: Optional[int] = None,
317
+ position_embeddings: Optional[tuple[torch.Tensor, torch.Tensor]] = None, # necessary, but kept here for BC
318
+ output_attentions: Optional[bool] = False,
319
+ ) -> tuple[torch.FloatTensor, Optional[tuple[torch.FloatTensor, torch.FloatTensor]]]:
320
+ residual = hidden_states
321
+ hidden_states = self.input_layernorm(hidden_states)
322
+
323
+ hidden_states, self_attn_weights = self.self_attn(
324
+ hidden_states=hidden_states,
325
+ cu_seqlens=cu_seqlens,
326
+ max_seqlen=max_seqlen,
327
+ position_embeddings=position_embeddings,
328
+ )
329
+ hidden_states = residual + hidden_states
330
+
331
+ residual = hidden_states
332
+ hidden_states = self.post_attention_layernorm(hidden_states)
333
+ hidden_states = self.mlp(hidden_states)
334
+ hidden_states = residual + hidden_states
335
+
336
+ outputs = (hidden_states,)
337
+ if output_attentions:
338
+ outputs += (self_attn_weights,)
339
+
340
+ return outputs
341
+
342
+
343
+ class BidirLMPreTrainedModel(PreTrainedModel):
344
+ config: BidirLMConfig
345
+ base_model_prefix = "model"
346
+ _supports_flash_attn = True
347
+ _supports_sdpa = True
348
+ _can_record_outputs = {}
349
+
350
+
351
+ class Qwen3RotaryEmbedding(nn.Module):
352
+ def __init__(self, config: BidirLMConfig, device=None):
353
+ super().__init__()
354
+ # BC: "rope_type" was originally "type"
355
+ if hasattr(config, "rope_scaling") and isinstance(config.rope_scaling, dict):
356
+ self.rope_type = config.rope_scaling.get("rope_type", config.rope_scaling.get("type"))
357
+ else:
358
+ self.rope_type = "default"
359
+ self.max_seqlen_cached = config.max_position_embeddings
360
+ self.original_max_seqlen = config.max_position_embeddings
361
+
362
+ self.config = config
363
+ # transformers 5.x removed 'default' from ROPE_INIT_FUNCTIONS
364
+ rope_init_fn = self.compute_default_rope_parameters if self.rope_type == "default" else ROPE_INIT_FUNCTIONS[self.rope_type]
365
+
366
+ inv_freq, self.attention_scaling = rope_init_fn(self.config, device)
367
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
368
+ self.original_inv_freq = self.inv_freq
369
+
370
+ @staticmethod
371
+ def compute_default_rope_parameters(config, device=None, **kwargs):
372
+ base = config.rope_theta
373
+ head_dim = getattr(config, "head_dim", None) or config.hidden_size // config.num_attention_heads
374
+ dim = int(head_dim * getattr(config, "partial_rotary_factor", 1.0))
375
+ inv_freq = 1.0 / (base ** (torch.arange(0, dim, 2, dtype=torch.int64).to(device=device, dtype=torch.float) / dim))
376
+ return inv_freq, 1.0
377
+
378
+ @torch.no_grad()
379
+ @dynamic_rope_update # power user: used with advanced RoPE types (e.g. dynamic rope)
380
+ def forward(self, x, position_ids):
381
+ inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1).to(x.device)
382
+ position_ids_expanded = position_ids[:, None, :].float()
383
+
384
+ device_type = x.device.type if isinstance(x.device.type, str) and x.device.type != "mps" else "cpu"
385
+ with torch.autocast(device_type=device_type, enabled=False): # Force float32
386
+ freqs = (inv_freq_expanded.float() @ position_ids_expanded.float()).transpose(1, 2)
387
+ emb = torch.cat((freqs, freqs), dim=-1)
388
+ cos = emb.cos() * self.attention_scaling
389
+ sin = emb.sin() * self.attention_scaling
390
+
391
+ return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype)
392
+
393
+
394
+ class BidirLMModel(BidirLMPreTrainedModel):
395
+ def __init__(self, config: BidirLMConfig):
396
+ super().__init__(config)
397
+ self.padding_idx = config.pad_token_id
398
+ self.vocab_size = config.vocab_size
399
+
400
+ self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
401
+ self.layers = nn.ModuleList([Qwen3EncoderLayer(config) for _ in range(config.num_hidden_layers)])
402
+ self.norm = Qwen3RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
403
+ self.rotary_emb = Qwen3RotaryEmbedding(config=config)
404
+ self.gradient_checkpointing = False
405
+
406
+ self.mask_converter = AttentionMaskConverter(True)
407
+ self.post_init()
408
+
409
+ def forward(
410
+ self,
411
+ input_ids: torch.LongTensor,
412
+ attention_mask: Optional[torch.Tensor] = None,
413
+ *,
414
+ output_attentions: Optional[bool] = None,
415
+ output_hidden_states: Optional[bool] = None,
416
+ return_dict: Optional[bool] = None,
417
+ **kwargs
418
+ ) -> tuple[torch.Tensor] | BaseModelOutput:
419
+ output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
420
+ output_hidden_states = (
421
+ output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
422
+ )
423
+ return_dict = return_dict if return_dict is not None else True
424
+ all_hidden_states = () if output_hidden_states else None
425
+ all_self_attns = () if output_attentions else None
426
+
427
+ # For MNTP XP
428
+ batch_size, seq_len = input_ids.size()
429
+ new_input_ids = torch.empty((batch_size, seq_len + 1), dtype=input_ids.dtype, device=input_ids.device)
430
+ new_input_ids[:, 0] = 151644
431
+ new_input_ids[:, 1:] = input_ids
432
+
433
+ if attention_mask is not None:
434
+ new_attention_mask = torch.empty((batch_size, seq_len + 1), dtype=attention_mask.dtype, device=attention_mask.device)
435
+ new_attention_mask[:, 0] = 1
436
+ new_attention_mask[:, 1:] = attention_mask
437
+ attention_mask = new_attention_mask
438
+ input_ids, cu_seqlens, max_seqlen = batch_input_to_cu_seqlens(new_input_ids, attention_mask)
439
+ else:
440
+ input_ids = new_input_ids
441
+
442
+ hidden_states = self.embed_tokens(input_ids)
443
+ position_ids = torch.arange(len(input_ids), device=input_ids.device).unsqueeze(0)
444
+ position_embeddings = self.rotary_emb(hidden_states, position_ids)
445
+
446
+ for encoder_layer in self.layers[: self.config.num_hidden_layers]:
447
+ if output_hidden_states:
448
+ if attention_mask is not None:
449
+ all_hidden_states += (cu_seqlens_to_batch_input(hidden_states, cu_seqlens, attention_mask.shape[-1])[0],)
450
+ else:
451
+ all_hidden_states += (hidden_states,)
452
+
453
+ layer_outputs = encoder_layer(
454
+ hidden_states,
455
+ cu_seqlens=cu_seqlens,
456
+ max_seqlen=max_seqlen,
457
+ position_embeddings=position_embeddings,
458
+ output_attentions=output_attentions,
459
+ )
460
+
461
+ hidden_states = layer_outputs[0]
462
+ if output_attentions:
463
+ if attention_mask is not None:
464
+ all_self_attns += (cu_attention_weight_to_batch(layer_outputs[1], cu_seqlens, attention_mask.shape[-1]),)
465
+ else:
466
+ all_self_attns += (layer_outputs[1],)
467
+
468
+ hidden_states = self.norm(hidden_states)
469
+ if attention_mask is not None:
470
+ hidden_states = cu_seqlens_to_batch_input(hidden_states, cu_seqlens, attention_mask.shape[-1])
471
+ if output_hidden_states:
472
+ all_hidden_states += (hidden_states,)
473
+
474
+ # For MNTP XP
475
+ output = BaseModelOutput(
476
+ last_hidden_state=hidden_states[:, :-1, :],
477
+ hidden_states=tuple(h[:, :-1, :] for h in all_hidden_states) if all_hidden_states is not None else None,
478
+ attentions=tuple(a[:, :, :-1, :-1] for a in all_self_attns) if all_self_attns is not None else None,
479
+ )
480
+ return output if return_dict else output.to_tuple()
481
+
482
+ class BidirLMForMaskedLM(BidirLMPreTrainedModel):
483
+ config_class = BidirLMConfig
484
+ _tied_weights_keys = {"lm_head.weight": "model.embed_tokens.weight"}
485
+
486
+ def __init__(self, config):
487
+ super().__init__(config)
488
+ self.model = BidirLMModel(config)
489
+ self.vocab_size = config.vocab_size
490
+ self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
491
+
492
+ self.post_init()
493
+
494
+ def forward(
495
+ self,
496
+ input_ids: torch.LongTensor = None,
497
+ *,
498
+ attention_mask: Optional[torch.Tensor] = None,
499
+ labels: Optional[torch.LongTensor] = None,
500
+ output_attentions: Optional[bool] = None,
501
+ output_hidden_states: Optional[bool] = None,
502
+ return_dict: Optional[bool] = None,
503
+ **kwargs
504
+ ) -> tuple[torch.Tensor] | MaskedLMOutput:
505
+ return_dict = return_dict if return_dict is not None else True
506
+ encoder_output = self.model(
507
+ input_ids=input_ids,
508
+ attention_mask=attention_mask,
509
+ output_attentions=output_attentions,
510
+ output_hidden_states=output_hidden_states,
511
+ return_dict=return_dict,
512
+ )
513
+ logits = self.lm_head(encoder_output[0])
514
+
515
+ loss = None
516
+ if labels is not None:
517
+ loss = self.loss_function(
518
+ logits, labels, vocab_size=self.config.vocab_size
519
+ )
520
+
521
+ output = MaskedLMOutput(
522
+ loss=loss,
523
+ logits=logits,
524
+ hidden_states=encoder_output.hidden_states,
525
+ attentions=encoder_output.attentions,
526
+ )
527
+ return output if return_dict else output.to_tuple()
528
+
529
+ class BidirLMForSequenceClassification(BidirLMPreTrainedModel):
530
+ def __init__(self, config: BidirLMConfig):
531
+ super().__init__(config)
532
+ self.num_labels = config.num_labels
533
+ self.clf_pooling = config.clf_pooling
534
+
535
+ self.model = BidirLMModel(config)
536
+ self.dense = nn.Linear(config.hidden_size, config.hidden_size)
537
+ self.activation = nn.GELU()
538
+ self.classifier = nn.Linear(config.hidden_size, self.num_labels)
539
+ self.post_init()
540
+
541
+ def forward(
542
+ self,
543
+ input_ids: Optional[torch.LongTensor] = None,
544
+ attention_mask: Optional[torch.Tensor] = None,
545
+ labels: Optional[torch.LongTensor] = None,
546
+ output_attentions: Optional[bool] = None,
547
+ output_hidden_states: Optional[bool] = None,
548
+ return_dict: Optional[bool] = None,
549
+ **kwargs
550
+ ) -> tuple[torch.Tensor] | SequenceClassifierOutput:
551
+ return_dict = return_dict if return_dict is not None else True
552
+
553
+ encoder_output = self.model(
554
+ input_ids,
555
+ attention_mask=attention_mask,
556
+ output_attentions=output_attentions,
557
+ output_hidden_states=output_hidden_states,
558
+ return_dict=return_dict,
559
+ )
560
+ last_hidden_state = encoder_output[0]
561
+
562
+ if self.clf_pooling in ["bos", "mean"]:
563
+ if self.clf_pooling == "bos":
564
+ pooled_output = last_hidden_state[:, 0]
565
+
566
+ elif self.clf_pooling == "mean":
567
+ if attention_mask is None:
568
+ pooled_output = last_hidden_state.mean(dim=1)
569
+ else:
570
+ pooled_output = (last_hidden_state * attention_mask.unsqueeze(-1)).sum(dim=1)
571
+ pooled_output /= attention_mask.sum(dim=1, keepdim=True)
572
+
573
+ pooled_output = self.dense(pooled_output)
574
+ pooled_output = self.activation(pooled_output)
575
+ logits = self.classifier(pooled_output)
576
+ elif self.clf_pooling == "late":
577
+ x = self.dense(last_hidden_state)
578
+ x = self.activation(x)
579
+ logits = self.classifier(x)
580
+ if attention_mask is None:
581
+ logits = logits.mean(dim=1)
582
+ else:
583
+ logits = (logits * attention_mask.unsqueeze(-1)).sum(dim=1)
584
+ logits /= attention_mask.sum(dim=1, keepdim=True)
585
+
586
+ loss = None
587
+ if labels is not None:
588
+ labels = labels.to(logits.device)
589
+ if self.config.problem_type is None:
590
+ if self.num_labels == 1:
591
+ self.config.problem_type = "regression"
592
+ elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
593
+ self.config.problem_type = "single_label_classification"
594
+ else:
595
+ self.config.problem_type = "multi_label_classification"
596
+
597
+ if self.config.problem_type == "regression":
598
+ loss_fct = MSELoss()
599
+ if self.num_labels == 1:
600
+ loss = loss_fct(logits.squeeze(), labels.squeeze())
601
+ else:
602
+ loss = loss_fct(logits, labels)
603
+ elif self.config.problem_type == "single_label_classification":
604
+ loss_fct = CrossEntropyLoss()
605
+ loss = loss_fct(logits.view(-1, self.num_labels), labels.view(-1))
606
+ elif self.config.problem_type == "multi_label_classification":
607
+ loss_fct = BCEWithLogitsLoss()
608
+ loss = loss_fct(logits, labels)
609
+
610
+ output = SequenceClassifierOutput(
611
+ loss=loss,
612
+ logits=logits,
613
+ hidden_states=encoder_output.hidden_states,
614
+ attentions=encoder_output.attentions,
615
+ )
616
+ return output if return_dict else output.to_tuple()
617
+
618
+ class BidirLMForTokenClassification(BidirLMPreTrainedModel):
619
+ def __init__(self, config: BidirLMConfig):
620
+ super().__init__(config)
621
+ self.num_labels = config.num_labels
622
+
623
+ self.model = BidirLMModel(config)
624
+ self.classifier = nn.Linear(config.hidden_size, config.num_labels)
625
+ self.post_init()
626
+
627
+ def forward(
628
+ self,
629
+ input_ids: Optional[torch.LongTensor] = None,
630
+ attention_mask: Optional[torch.Tensor] = None,
631
+ position_ids: Optional[torch.LongTensor] = None,
632
+ inputs_embeds: Optional[torch.FloatTensor] = None,
633
+ labels: Optional[torch.LongTensor] = None,
634
+ use_cache: Optional[bool] = None,
635
+ output_attentions: Optional[bool] = None,
636
+ output_hidden_states: Optional[bool] = None,
637
+ return_dict: Optional[bool] = None,
638
+ ) -> tuple[torch.Tensor] | TokenClassifierOutput:
639
+ return_dict = return_dict if return_dict is not None else True
640
+
641
+ outputs = self.model(
642
+ input_ids,
643
+ attention_mask=attention_mask,
644
+ position_ids=position_ids,
645
+ inputs_embeds=inputs_embeds,
646
+ use_cache=use_cache,
647
+ output_attentions=output_attentions,
648
+ output_hidden_states=output_hidden_states,
649
+ return_dict=return_dict,
650
+ )
651
+ sequence_output = outputs[0]
652
+ logits = self.classifier(sequence_output)
653
+
654
+ loss = None
655
+ if labels is not None:
656
+ loss_fct = CrossEntropyLoss()
657
+ loss = loss_fct(logits.view(-1, self.num_labels), labels.view(-1))
658
+
659
+ if not return_dict:
660
+ output = (logits,) + outputs[2:]
661
+ return ((loss,) + output) if loss is not None else output
662
+
663
+ return TokenClassifierOutput(
664
+ loss=loss,
665
+ logits=logits,
666
+ hidden_states=outputs.hidden_states,
667
+ attentions=outputs.attentions,
668
+ )
669
+
670
+ __all__ = [
671
+ "BidirLMPreTrainedModel",
672
+ "BidirLMModel",
673
+ "BidirLMForMaskedLM",
674
+ "BidirLMForSequenceClassification",
675
+ "BidirLMForTokenClassification",
676
+ ]
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
+ ]
mteb_v2_eval_prompts.json ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "BornholmBitextMining": "Retrieve parallel sentences between Danish and Bornholmsk dialect",
3
+ "CEDRClassification": "Classify the emotion expressed in the given text into one of five categories: joy, sadness, surprise, fear, or anger",
4
+ "DalajClassification": "Classify the linguistic acceptability of the given Swedish sentence",
5
+ "NorwegianCourtsBitextMining": "Retrieve parallel sentences between Norwegian Bokmål and Nynorsk",
6
+ "ScalaClassification": "Classify the linguistic acceptability of the given Scandinavian sentence",
7
+ "SpartQA": "Given a spatial reasoning question, retrieve the passage that answers the question",
8
+ "SwednClusteringP2P": "Identify the topic or theme of the given Swedish news articles",
9
+ "TempReasonL1": "Given a temporal reasoning question, retrieve the passage that answers the question",
10
+ "TwitterHjerneRetrieval": "Given a Danish question, retrieve the corresponding answer",
11
+ "WinoGrande": "Given a commonsense reasoning question, retrieve the passage that answers the question",
12
+ "AmazonCounterfactualClassification": "Given an Amazon review, judge whether it is counterfactual.",
13
+ "AmazonPolarityClassification": "Classifying Amazon reviews into positive or negative sentiment",
14
+ "AmazonReviewsClassification": "Classifying the given Amazon review into its appropriate rating category",
15
+ "Banking77Classification": "Given an online banking query, find the corresponding intents",
16
+ "EmotionClassification": "Classify the emotion expressed in the given Twitter message into one of the six emotions: anger, fear, joy, love, sadness, and surprise",
17
+ "ImdbClassification": "Classifying the sentiment expressed in the given movie review text from the IMDB dataset",
18
+ "MassiveIntentClassification": "Given a user utterance as query, find the user intents",
19
+ "MassiveScenarioClassification": "Given a user utterance as query, find the user scenarios",
20
+ "MTOPDomainClassification": "Classifying the intent domain of the given utterance in task-oriented conversation",
21
+ "MTOPIntentClassification": "Classifying the intent of the given utterance in task-oriented conversation",
22
+ "ToxicConversationsClassification": "Classifying the given comments as either toxic or not toxic",
23
+ "TweetSentimentExtractionClassification": "Classifying the sentiment of a given tweet as either positive, negative, or neutral",
24
+ "TNews": "Categorizing the given news title",
25
+ "IFlyTek": "Given an App description text, find the appropriate fine-grained category",
26
+ "MultilingualSentiment": "Classifying sentiment of the customer review into positive, neutral, or negative",
27
+ "JDReview": "Classifying sentiment of the customer review for iPhoneinto positive or negative",
28
+ "OnlineShopping": "Classifying sentiment of the customer reviewinto positive or negative",
29
+ "Waimai": "Classify the customer review from a food takeaway platform into positive or negative",
30
+ "ArxivClusteringP2P": "Identify the main and secondary category of Arxiv papers based on the titles and abstracts",
31
+ "ArxivClusteringS2S": "Identify the main and secondary category of Arxiv papers based on the titles",
32
+ "BiorxivClusteringP2P": "Identify the main category of Biorxiv papers based on the titles and abstracts",
33
+ "BiorxivClusteringS2S": "Identify the main category of Biorxiv papers based on the titles",
34
+ "MedrxivClusteringP2P": "Identify the main category of Medrxiv papers based on the titles and abstracts",
35
+ "MedrxivClusteringS2S": "Identify the main category of Medrxiv papers based on the titles",
36
+ "RedditClustering": "Identify the topic or theme of Reddit posts based on the titles",
37
+ "RedditClusteringP2P": "Identify the topic or theme of Reddit posts based on the titles and posts",
38
+ "StackExchangeClustering": "Identify the topic or theme of StackExchange posts based on the titles",
39
+ "StackExchangeClusteringP2P": "Identify the topic or theme of StackExchange posts based on the given paragraphs",
40
+ "TwentyNewsgroupsClustering": "Identify the topic or theme of the given news articles",
41
+ "CLSClusteringS2S": "Identify the main category of scholar papers based on the titles",
42
+ "CLSClusteringP2P": "Identify the main category of scholar papers based on the titles and abstracts",
43
+ "ThuNewsClusteringS2S": "Identify the topic or theme of the given news articles based on the titles",
44
+ "ThuNewsClusteringP2P": "Identify the topic or theme of the given news articles based on the titles and contents",
45
+ "AskUbuntuDupQuestions": "Given a question, retrieve detailed question descriptions from Stackexchange that are duplicates to the given question",
46
+ "MindSmallReranking": "Given a query, retrieve documents that answer the query.",
47
+ "SciDocsRR": "Given a query, retrieve documents that answer the query.",
48
+ "StackOverflowDupQuestions": "Given a question, retrieve detailed question descriptions from Stackexchange that are duplicates to the given question",
49
+ "SprintDuplicateQuestions": "Given a question, retrieve detailed question descriptions from Stackexchange that are duplicates to the given question",
50
+ "TwitterSemEval2015": "Retrieve semantically similar text.",
51
+ "TwitterURLCorpus": "Retrieve semantically similar text.",
52
+ "T2Reranking": "Given a query, retrieve documents that answer the query.",
53
+ "MmarcoReranking": "Given a query, retrieve documents that answer the query.",
54
+ "CMedQAv1": "Given a query, retrieve documents that answer the query.",
55
+ "CMedQAv2": "Given a query, retrieve documents that answer the query.",
56
+ "Ocnli": "Retrieve semantically similar text.",
57
+ "Cmnli": "Retrieve semantically similar text.",
58
+ "ArguAna": {
59
+ "query": "Given a claim, retrieve documents that support or refute the claim",
60
+ "passage": "Given a claim, retrieve documents that support or refute the claim"
61
+ },
62
+ "ClimateFEVER": "Given a claim, retrieve documents that support or refute the claim",
63
+ "ClimateFEVERHardNegatives": "Given a claim, retrieve documents that support or refute the claim",
64
+ "DBPedia": "Given a query, retrieve documents that answer the query.",
65
+ "FEVER": "Given a claim, retrieve documents that support or refute the claim",
66
+ "FEVERHardNegatives": "Given a claim, retrieve documents that support or refute the claim",
67
+ "FiQA2018": "Given a query, retrieve documents that answer the query.",
68
+ "HotpotQA": "Given a multi-hop question, retrieve documents that can help answer the question",
69
+ "HotpotQAHardNegatives": "Given a multi-hop question, retrieve documents that can help answer the question",
70
+ "MSMARCO": "Given a web search query, retrieve relevant passages that answer the query",
71
+ "NFCorpus": "Given a question, retrieve relevant documents that best answer the question",
72
+ "NQ": "Given a question, retrieve Wikipedia passages that answer the question",
73
+ "QuoraRetrieval": "Given a query, retrieve documents that answer the query.",
74
+ "SCIDOCS": "Given a query, retrieve documents that answer the query.",
75
+ "SciFact": "Given a scientific claim, retrieve documents that support or refute the claim",
76
+ "Touche2020": "Given a query, retrieve documents that answer the query.",
77
+ "Touche2020Retrieval.v3": "Given a query, retrieve documents that answer the query.",
78
+ "TRECCOVID": "Given a query, retrieve documents that answer the query.",
79
+ "T2Retrieval": "Given a question, retrieve passages that answer the question",
80
+ "MMarcoRetrieval": "Given a web search query, retrieve relevant passages that answer the query",
81
+ "DuRetrieval": "Given a question, retrieve passages that answer the question",
82
+ "CovidRetrieval": "Given a query on COVID-19, retrieve documents that answer the query",
83
+ "CmedqaRetrieval": "Given a query, retrieve documents that answer the query.",
84
+ "EcomRetrieval": "Given a query, retrieve documents that answer the query.",
85
+ "MedicalRetrieval": "Given a query, retrieve documents that answer the query.",
86
+ "VideoRetrieval": "Given a query, retrieve documents that answer the query.",
87
+ "STSBenchmarkMultilingualSTS": "Retrieve semantically similar text",
88
+ "SICKFr": "Retrieve semantically similar text",
89
+ "SummEvalFr": "Retrieve semantically similar text.",
90
+ "MasakhaNEWSClassification": "Categorizing the given news title",
91
+ "OpusparcusPC": "Retrieve semantically similar text",
92
+ "PawsX": "Retrieve semantically similar text",
93
+ "AlloProfClusteringP2P": "Identify the main category of scholar papers based on the titles and abstracts",
94
+ "AlloProfClusteringS2S": "Identify the main category of scholar papers based on the titles",
95
+ "HALClusteringS2S": "Identify the main category of scholar papers based on the titles",
96
+ "MasakhaNEWSClusteringP2P": "Identify the topic or theme of the given news articles based on the titles and contents",
97
+ "MasakhaNEWSClusteringS2S": "Identify the topic or theme of the given news articles based on the titles",
98
+ "MLSUMClusteringP2P": "Identify the topic or theme of Reddit posts based on the titles and posts",
99
+ "MLSUMClusteringS2S": "Identify the topic or theme of Reddit posts based on the titles",
100
+ "SyntecReranking": "Given a question, retrieve passages that answer the question",
101
+ "AlloprofReranking": "Given a question, retrieve passages that answer the question",
102
+ "AlloprofRetrieval": "Given a question, retrieve passages that answer the question",
103
+ "BSARDRetrieval": "Given a question, retrieve passages that answer the question",
104
+ "SyntecRetrieval": "Given a question, retrieve passages that answer the question",
105
+ "XPQARetrieval": "Given a question, retrieve passages that answer the question",
106
+ "MintakaRetrieval": "Given a question, retrieve passages that answer the question",
107
+ "CBD": "Classifying the sentiment of a given tweet as either positive, negative, or neutral",
108
+ "PolEmo2.0-IN": "Classifying sentiment of the customer review into positive, neutral, or negative",
109
+ "PolEmo2.0-OUT": "Classifying sentiment of the customer review into positive, neutral, or negative",
110
+ "AllegroReviews": "Classifying sentiment of the customer review into positive, neutral, or negative",
111
+ "PAC": "Classify the sentence into one of the two types: 'BEZPIECZNE_POSTANOWIENIE_UMOWNE' and 'KLAUZULA_ABUZYWNA'",
112
+ "SICK-E-PL": "Retrieve semantically similar text",
113
+ "SICK-R-PL": "Retrieve semantically similar text",
114
+ "STS22": "Retrieve semantically similar text",
115
+ "AFQMC": "Retrieve semantically similar text",
116
+ "BQ": "Retrieve semantically similar text",
117
+ "LCQMC": "Retrieve semantically similar text",
118
+ "PAWSX": "Retrieve semantically similar text",
119
+ "QBQTC": "Retrieve semantically similar text",
120
+ "STS12": "Retrieve semantically similar text",
121
+ "PPC": "Retrieve semantically similar text",
122
+ "CDSC-E": "Retrieve semantically similar text",
123
+ "PSC": "Retrieve semantically similar text",
124
+ "8TagsClustering": "Identify the topic or theme of the given news articles",
125
+ "ArguAna-PL": "Given a claim, retrieve documents that support or refute the claim",
126
+ "DBPedia-PL": "Given a query, retrieve documents that answer the query.",
127
+ "FiQA-PL": "Given a query, retrieve documents that answer the query.",
128
+ "HotpotQA-PL": "Given a multi-hop question, retrieve documents that can help answer the question",
129
+ "MSMARCO-PL": "Given a web search query, retrieve relevant passages that answer the query",
130
+ "NFCorpus-PL": "Given a question, retrieve relevant documents that best answer the question",
131
+ "NQ-PL": "Given a question, retrieve Wikipedia passages that answer the question",
132
+ "Quora-PL": "Given a query, retrieve documents that answer the query.",
133
+ "SCIDOCS-PL": "Given a query, retrieve documents that answer the query.",
134
+ "SciFact-PL": "Given a scientific claim, retrieve documents that support or refute the claim",
135
+ "TRECCOVID-PL": "Given a query, retrieve documents that answer the query.",
136
+ "GeoreviewClassification": "Classifying sentiment of the customer review into positive, neutral, or negative",
137
+ "HeadlineClassification": "Categorizing the given news title",
138
+ "InappropriatenessClassification": "Classifying the given comments as either toxic or not toxic",
139
+ "KinopoiskClassification": "Classifying the sentiment expressed in the given movie review text from the IMDB dataset",
140
+ "RuReviewsClassification": "Classifying sentiment of the customer review into positive, neutral, or negative",
141
+ "RuSciBenchGRNTIClassification": "Categorizing the given news title",
142
+ "RuSciBenchOECDClassification": "Categorizing the given news title",
143
+ "GeoreviewClusteringP2P": "Identify the topic or theme of Reddit posts based on the titles and posts",
144
+ "RuSciBenchGRNTIClusteringP2P": "Identify the main category of scholar papers based on the titles and abstracts",
145
+ "RuSciBenchOECDClusteringP2P": "Identify the main category of scholar papers based on the titles and abstracts",
146
+ "TERRa": "Retrieve semantically similar text.",
147
+ "RuBQReranking": "Given a question, retrieve Wikipedia passages that answer the question",
148
+ "RiaNewsRetrieval": "Given a query, retrieve documents that answer the query.",
149
+ "RuBQRetrieval": "Given a question, retrieve Wikipedia passages that answer the question",
150
+ "RUParaPhraserSTS": "Retrieve semantically similar text",
151
+ "RuSTSBenchmarkSTS": "Retrieve semantically similar text",
152
+ "AppsRetrieval": "Given a query, retrieve documents that answer the query.",
153
+ "COIRCodeSearchNetRetrieval": "Given a query, retrieve documents that answer the query.",
154
+ "CodeEditSearchRetrieval": "Given a query, retrieve documents that answer the query.",
155
+ "CodeFeedbackMT": "Given a query, retrieve documents that answer the query.",
156
+ "CodeFeedbackST": "Given a query, retrieve documents that answer the query.",
157
+ "CodeSearchNetCCRetrieval": "Given a query, retrieve documents that answer the query.",
158
+ "CodeSearchNetRetrieval": "Given a query, retrieve documents that answer the query.",
159
+ "CodeTransOceanContest": "Given a query, retrieve documents that answer the query.",
160
+ "CodeTransOceanDL": "Given a query, retrieve documents that answer the query.",
161
+ "CosQA": "Given a query, retrieve documents that answer the query.",
162
+ "StackOverflowQA": "Given a query, retrieve documents that answer the query.",
163
+ "SyntheticText2SQL": "Given a query, retrieve documents that answer the query.",
164
+ "BibleNLPBitextMining": "Retrieve semantically similar text.",
165
+ "BUCC.v2": "Retrieve semantically similar text.",
166
+ "DiaBlaBitextMining": "Retrieve semantically similar text.",
167
+ "FloresBitextMining": "Retrieve semantically similar text.",
168
+ "IN22GenBitextMining": "Retrieve semantically similar text.",
169
+ "IndicGenBenchFloresBitextMining": "Retrieve semantically similar text.",
170
+ "NollySentiBitextMining": "Retrieve semantically similar text.",
171
+ "NTREXBitextMining": "Retrieve semantically similar text.",
172
+ "NusaTranslationBitextMining": "Retrieve semantically similar text.",
173
+ "NusaXBitextMining": "Retrieve semantically similar text.",
174
+ "Tatoeba": "Retrieve semantically similar text.",
175
+ "BulgarianStoreReviewSentimentClassfication": "Classifying sentiment of the customer review into positive, neutral, or negative",
176
+ "CzechProductReviewSentimentClassification": "Classifying sentiment of the customer review into positive, neutral, or negative",
177
+ "GreekLegalCodeClassification": "Categorizing the given news title",
178
+ "DBpediaClassification": "Given an App description text, find the appropriate fine-grained category",
179
+ "FinancialPhrasebankClassification": "Classifying sentiment of the customer review into positive, neutral, or negative",
180
+ "PoemSentimentClassification": "Classifying sentiment of the customer review into positive, neutral, or negative",
181
+ "TweetTopicSingleClassification": "Categorizing the given news title",
182
+ "EstonianValenceClassification": "Classifying sentiment of the customer review into positive, neutral, or negative",
183
+ "FilipinoShopeeReviewsClassification": "Classifying sentiment of the customer review into positive, neutral, or negative",
184
+ "GujaratiNewsClassification": "Categorizing the given news title",
185
+ "SentimentAnalysisHindi": "Classifying sentiment of the customer review into positive, neutral, or negative",
186
+ "IndonesianIdClickbaitClassification": "Categorizing the given news title",
187
+ "ItaCaseholdClassification": "Categorizing the given news title",
188
+ "KorSarcasmClassification": "Classifying sentiment of the customer review into positive, neutral, or negative",
189
+ "KurdishSentimentClassification": "Classifying sentiment of the customer review into positive, neutral, or negative",
190
+ "MacedonianTweetSentimentClassification": "Classifying the sentiment of a given tweet as either positive, negative, or neutral",
191
+ "AfriSentiClassification": "Classifying sentiment of the customer review into positive, neutral, or negative",
192
+ "CataloniaTweetClassification": "Classifying the sentiment of a given tweet as either positive, negative, or neutral",
193
+ "CyrillicTurkicLangClassification": "Given a text, classify its language",
194
+ "IndicLangClassification": "Given a text, classify its language",
195
+ "MultiHateClassification": "Classifying the given comments as either toxic or not toxic",
196
+ "NusaParagraphEmotionClassification": "Classify the emotion expressed in the given Twitter message into one of the six emotions: anger, fear, joy, love, sadness, and surprise",
197
+ "NusaX-senti": "Classifying sentiment of the customer review into positive, neutral, or negative",
198
+ "SwissJudgementClassification": "Classifying sentiment of the customer review into positive, neutral, or negative",
199
+ "NepaliNewsClassification": "Categorizing the given news title",
200
+ "OdiaNewsClassification": "Categorizing the given news title",
201
+ "PunjabiNewsClassification": "Categorizing the given news title",
202
+ "SinhalaNewsClassification": "Categorizing the given news title",
203
+ "CSFDSKMovieReviewSentimentClassification": "Classifying the sentiment expressed in the given movie review text from the IMDB dataset",
204
+ "SiswatiNewsClassification": "Categorizing the given news title",
205
+ "SlovakMovieReviewSentimentClassification": "Classifying the sentiment expressed in the given movie review text from the IMDB dataset",
206
+ "SwahiliNewsClassification": "Categorizing the given news title",
207
+ "TswanaNewsClassification": "Categorizing the given news title",
208
+ "IsiZuluNewsClassification": "Categorizing the given news title",
209
+ "WikiCitiesClustering": "Identify the topic or theme of the given news articles",
210
+ "RomaniBibleClustering": "Identify the topic or theme of the given news articles",
211
+ "ArXivHierarchicalClusteringP2P": "Identify the main and secondary category of Arxiv papers based on the titles and abstracts",
212
+ "ArXivHierarchicalClusteringS2S": "Identify the main and secondary category of Arxiv papers based on the titles",
213
+ "BigPatentClustering.v2": "Identify the main category of scholar papers based on the titles and abstracts",
214
+ "AlloProfClusteringS2S.v2": "Identify the main category of scholar papers based on the titles",
215
+ "HALClusteringS2S.v2": "Identify the main category of scholar papers based on the titles",
216
+ "SIB200ClusteringS2S": "Identify the topic or theme of the given news articles",
217
+ "WikiClusteringP2P.v2": "Identify the topic or theme of the given news articles",
218
+ "PlscClusteringP2P.v2": "Identify the main category of scholar papers based on the titles and abstracts",
219
+ "KorHateSpeechMLClassification": "Classifying the given comments as either toxic or not toxic",
220
+ "MalteseNewsClassification": "Categorizing the given news title",
221
+ "MultiEURLEXMultilabelClassification": "Categorizing the given news title",
222
+ "BrazilianToxicTweetsClassification": "Classifying the given comments as either toxic or not toxic",
223
+ "CTKFactsNLI": "Retrieve semantically similar text",
224
+ "indonli": "Retrieve semantically similar text",
225
+ "ArmenianParaphrasePC": "Retrieve semantically similar text",
226
+ "PawsXPairClassification": "Retrieve semantically similar text",
227
+ "RTE3": "Retrieve semantically similar text",
228
+ "XNLI": "Retrieve semantically similar text",
229
+ "PpcPC": "Retrieve semantically similar text",
230
+ "GermanSTSBenchmark": "Retrieve semantically similar text",
231
+ "SICK-R": "Retrieve semantically similar text",
232
+ "STS13": "Retrieve semantically similar text",
233
+ "STS14": "Retrieve semantically similar text",
234
+ "STSBenchmark": "Retrieve semantically similar text",
235
+ "FaroeseSTS": "Retrieve semantically similar text",
236
+ "FinParaSTS": "Retrieve semantically similar text",
237
+ "JSICK": "Retrieve semantically similar text",
238
+ "IndicCrosslingualSTS": "Retrieve semantically similar text",
239
+ "SemRel24STS": "Retrieve semantically similar text",
240
+ "STS17": "Retrieve semantically similar text",
241
+ "STS22.v2": "Retrieve semantically similar text",
242
+ "STSES": "Retrieve semantically similar text",
243
+ "STSB": "Retrieve semantically similar text",
244
+ "AILAStatutes": "Given a query, retrieve documents that answer the query.",
245
+ "HagridRetrieval": "Given a query, retrieve documents that answer the query.",
246
+ "LegalBenchCorporateLobbying": "Given a query, retrieve documents that answer the query.",
247
+ "LEMBNarrativeQARetrieval": "Given a query, retrieve documents that answer the query.",
248
+ "LEMBNeedleRetrieval": "Given a query, retrieve documents that answer the query.",
249
+ "LEMBPasskeyRetrieval": "Given a query, retrieve documents that answer the query.",
250
+ "LEMBQMSumRetrieval": "Given a query, retrieve documents that answer the query.",
251
+ "LEMBSummScreenFDRetrieval": "Given a query, retrieve documents that answer the query.",
252
+ "LEMBWikimQARetrieval": "Given a query, retrieve documents that answer the query.",
253
+ "BelebeleRetrieval": "Given a query, retrieve documents that answer the query.",
254
+ "MLQARetrieval": "Given a query, retrieve documents that answer the query.",
255
+ "StatcanDialogueDatasetRetrieval": "Given a query, retrieve documents that answer the query.",
256
+ "WikipediaRetrievalMultilingual": "Given a query, retrieve documents that answer the query.",
257
+ "Core17InstructionRetrieval": "Given a query, retrieve documents that answer the query.",
258
+ "News21InstructionRetrieval": "Given a query, retrieve documents that answer the query.",
259
+ "Robust04InstructionRetrieval": "Given a query, retrieve documents that answer the query.",
260
+ "WebLINXCandidatesReranking": "Given a query, retrieve documents that answer the query.",
261
+ "WikipediaRerankingMultilingual": "Given a query, retrieve documents that answer the query.",
262
+ "STS15": "Retrieve semantically similar text",
263
+ "MIRACLRetrievalHardNegatives": "Given a question, retrieve passages that answer the question",
264
+ "BIOSSES": "Retrieve semantically similar text",
265
+ "CQADupstackRetrieval": "Given a question, retrieve detailed question descriptions from Stackexchange that are duplicates to the given question",
266
+ "CQADupstackGamingRetrieval": {
267
+ "query": "Given a question, retrieve detailed question descriptions from Stackexchange that are duplicates to the given question",
268
+ "passage": "Given a question, retrieve detailed question descriptions from Stackexchange that are duplicates to the given question"
269
+ },
270
+ "CQADupstackUnixRetrieval": {
271
+ "query": "Given a question, retrieve detailed question descriptions from Stackexchange that are duplicates to the given question",
272
+ "passage": "Given a question, retrieve detailed question descriptions from Stackexchange that are duplicates to the given question"
273
+ },
274
+ "STS16": "Retrieve semantically similar text",
275
+ "SummEval": "Retrieve semantically similar text",
276
+ "ATEC": "Retrieve semantically similar text"
277
+ }
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 512,
3
+ "do_lower_case": false
4
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>",
5
+ "<|object_ref_start|>",
6
+ "<|object_ref_end|>",
7
+ "<|box_start|>",
8
+ "<|box_end|>",
9
+ "<|quad_start|>",
10
+ "<|quad_end|>",
11
+ "<|vision_start|>",
12
+ "<|vision_end|>",
13
+ "<|vision_pad|>",
14
+ "<|image_pad|>",
15
+ "<|video_pad|>"
16
+ ],
17
+ "eos_token": {
18
+ "content": "<|endoftext|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ },
24
+ "mask_token": {
25
+ "content": "<|mask|>",
26
+ "lstrip": true,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ },
31
+ "pad_token": {
32
+ "content": "<|endoftext|>",
33
+ "lstrip": false,
34
+ "normalized": false,
35
+ "rstrip": false,
36
+ "single_word": false
37
+ }
38
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8fed6809a51ebca45ce2df9ac10fc3aa4ed7f05c659dc09e96be7d814271c46b
3
+ size 11422913
tokenizer_config.json ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_eos_token": false,
4
+ "add_prefix_space": false,
5
+ "added_tokens_decoder": {
6
+ "151643": {
7
+ "content": "<|endoftext|>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "151644": {
15
+ "content": "<|im_start|>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "151645": {
23
+ "content": "<|im_end|>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": true
29
+ },
30
+ "151646": {
31
+ "content": "<|object_ref_start|>",
32
+ "lstrip": false,
33
+ "normalized": false,
34
+ "rstrip": false,
35
+ "single_word": false,
36
+ "special": true
37
+ },
38
+ "151647": {
39
+ "content": "<|object_ref_end|>",
40
+ "lstrip": false,
41
+ "normalized": false,
42
+ "rstrip": false,
43
+ "single_word": false,
44
+ "special": true
45
+ },
46
+ "151648": {
47
+ "content": "<|box_start|>",
48
+ "lstrip": false,
49
+ "normalized": false,
50
+ "rstrip": false,
51
+ "single_word": false,
52
+ "special": true
53
+ },
54
+ "151649": {
55
+ "content": "<|box_end|>",
56
+ "lstrip": false,
57
+ "normalized": false,
58
+ "rstrip": false,
59
+ "single_word": false,
60
+ "special": true
61
+ },
62
+ "151650": {
63
+ "content": "<|quad_start|>",
64
+ "lstrip": false,
65
+ "normalized": false,
66
+ "rstrip": false,
67
+ "single_word": false,
68
+ "special": true
69
+ },
70
+ "151651": {
71
+ "content": "<|quad_end|>",
72
+ "lstrip": false,
73
+ "normalized": false,
74
+ "rstrip": false,
75
+ "single_word": false,
76
+ "special": true
77
+ },
78
+ "151652": {
79
+ "content": "<|vision_start|>",
80
+ "lstrip": false,
81
+ "normalized": false,
82
+ "rstrip": false,
83
+ "single_word": false,
84
+ "special": true
85
+ },
86
+ "151653": {
87
+ "content": "<|vision_end|>",
88
+ "lstrip": false,
89
+ "normalized": false,
90
+ "rstrip": false,
91
+ "single_word": false,
92
+ "special": true
93
+ },
94
+ "151654": {
95
+ "content": "<|vision_pad|>",
96
+ "lstrip": false,
97
+ "normalized": false,
98
+ "rstrip": false,
99
+ "single_word": false,
100
+ "special": true
101
+ },
102
+ "151655": {
103
+ "content": "<|image_pad|>",
104
+ "lstrip": false,
105
+ "normalized": false,
106
+ "rstrip": false,
107
+ "single_word": false,
108
+ "special": true
109
+ },
110
+ "151656": {
111
+ "content": "<|video_pad|>",
112
+ "lstrip": false,
113
+ "normalized": false,
114
+ "rstrip": false,
115
+ "single_word": false,
116
+ "special": true
117
+ },
118
+ "151657": {
119
+ "content": "<tool_call>",
120
+ "lstrip": false,
121
+ "normalized": false,
122
+ "rstrip": false,
123
+ "single_word": false,
124
+ "special": false
125
+ },
126
+ "151658": {
127
+ "content": "</tool_call>",
128
+ "lstrip": false,
129
+ "normalized": false,
130
+ "rstrip": false,
131
+ "single_word": false,
132
+ "special": false
133
+ },
134
+ "151659": {
135
+ "content": "<|fim_prefix|>",
136
+ "lstrip": false,
137
+ "normalized": false,
138
+ "rstrip": false,
139
+ "single_word": false,
140
+ "special": false
141
+ },
142
+ "151660": {
143
+ "content": "<|fim_middle|>",
144
+ "lstrip": false,
145
+ "normalized": false,
146
+ "rstrip": false,
147
+ "single_word": false,
148
+ "special": false
149
+ },
150
+ "151661": {
151
+ "content": "<|fim_suffix|>",
152
+ "lstrip": false,
153
+ "normalized": false,
154
+ "rstrip": false,
155
+ "single_word": false,
156
+ "special": false
157
+ },
158
+ "151662": {
159
+ "content": "<|fim_pad|>",
160
+ "lstrip": false,
161
+ "normalized": false,
162
+ "rstrip": false,
163
+ "single_word": false,
164
+ "special": false
165
+ },
166
+ "151663": {
167
+ "content": "<|mask|>",
168
+ "lstrip": true,
169
+ "normalized": false,
170
+ "rstrip": false,
171
+ "single_word": false,
172
+ "special": true
173
+ },
174
+ "151664": {
175
+ "content": "<|file_sep|>",
176
+ "lstrip": false,
177
+ "normalized": false,
178
+ "rstrip": false,
179
+ "single_word": false,
180
+ "special": false
181
+ },
182
+ "151665": {
183
+ "content": "<tool_response>",
184
+ "lstrip": false,
185
+ "normalized": false,
186
+ "rstrip": false,
187
+ "single_word": false,
188
+ "special": false
189
+ },
190
+ "151666": {
191
+ "content": "</tool_response>",
192
+ "lstrip": false,
193
+ "normalized": false,
194
+ "rstrip": false,
195
+ "single_word": false,
196
+ "special": false
197
+ },
198
+ "151667": {
199
+ "content": "<think>",
200
+ "lstrip": false,
201
+ "normalized": false,
202
+ "rstrip": false,
203
+ "single_word": false,
204
+ "special": false
205
+ },
206
+ "151668": {
207
+ "content": "</think>",
208
+ "lstrip": false,
209
+ "normalized": false,
210
+ "rstrip": false,
211
+ "single_word": false,
212
+ "special": false
213
+ }
214
+ },
215
+ "additional_special_tokens": [
216
+ "<|im_start|>",
217
+ "<|im_end|>",
218
+ "<|object_ref_start|>",
219
+ "<|object_ref_end|>",
220
+ "<|box_start|>",
221
+ "<|box_end|>",
222
+ "<|quad_start|>",
223
+ "<|quad_end|>",
224
+ "<|vision_start|>",
225
+ "<|vision_end|>",
226
+ "<|vision_pad|>",
227
+ "<|image_pad|>",
228
+ "<|video_pad|>"
229
+ ],
230
+ "bos_token": null,
231
+ "clean_up_tokenization_spaces": false,
232
+ "eos_token": "<|endoftext|>",
233
+ "errors": "replace",
234
+ "extra_special_tokens": {},
235
+ "mask_token": "<|mask|>",
236
+ "model_max_length": 131072,
237
+ "pad_token": "<|endoftext|>",
238
+ "split_special_tokens": false,
239
+ "tokenizer_class": "Qwen2Tokenizer",
240
+ "unk_token": null
241
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff