Add new SentenceTransformer model
Browse files- 1_Pooling/config.json +10 -0
- README.md +0 -0
- config.json +71 -0
- config_sentence_transformers.json +10 -0
- configuration.py +145 -0
- model.safetensors +3 -0
- modules.json +14 -0
- sentence_bert_config.json +4 -0
- special_tokens_map.json +51 -0
- tokenizer.json +0 -0
- tokenizer_config.json +61 -0
1_Pooling/config.json
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"word_embedding_dimension": 768,
|
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
The diff for this file is too large to render.
See raw diff
|
|
config.json
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "outputs/gte-v1/checkpoint-4100",
|
3 |
+
"architectures": [
|
4 |
+
"NewModel"
|
5 |
+
],
|
6 |
+
"attention_probs_dropout_prob": 0.0,
|
7 |
+
"auto_map": {
|
8 |
+
"AutoConfig": "configuration.NewConfig",
|
9 |
+
"AutoModel": "Alibaba-NLP/new-impl--modeling.NewModel",
|
10 |
+
"AutoModelForMaskedLM": "Alibaba-NLP/new-impl--modeling.NewForMaskedLM",
|
11 |
+
"AutoModelForMultipleChoice": "Alibaba-NLP/new-impl--modeling.NewForMultipleChoice",
|
12 |
+
"AutoModelForQuestionAnswering": "Alibaba-NLP/new-impl--modeling.NewForQuestionAnswering",
|
13 |
+
"AutoModelForSequenceClassification": "Alibaba-NLP/new-impl--modeling.NewForSequenceClassification",
|
14 |
+
"AutoModelForTokenClassification": "Alibaba-NLP/new-impl--modeling.NewForTokenClassification"
|
15 |
+
},
|
16 |
+
"classifier_dropout": 0.0,
|
17 |
+
"hidden_act": "gelu",
|
18 |
+
"hidden_dropout_prob": 0.1,
|
19 |
+
"hidden_size": 768,
|
20 |
+
"id2label": {
|
21 |
+
"0": "LABEL_0"
|
22 |
+
},
|
23 |
+
"initializer_range": 0.02,
|
24 |
+
"intermediate_size": 3072,
|
25 |
+
"label2id": {
|
26 |
+
"LABEL_0": 0
|
27 |
+
},
|
28 |
+
"layer_norm_eps": 1e-12,
|
29 |
+
"layer_norm_type": "layer_norm",
|
30 |
+
"logn_attention_clip1": false,
|
31 |
+
"logn_attention_scale": false,
|
32 |
+
"max_position_embeddings": 8192,
|
33 |
+
"model_type": "new",
|
34 |
+
"num_attention_heads": 12,
|
35 |
+
"num_hidden_layers": 12,
|
36 |
+
"pack_qkv": true,
|
37 |
+
"pad_token_id": 1,
|
38 |
+
"position_embedding_type": "rope",
|
39 |
+
"rope_scaling": {
|
40 |
+
"factor": 8.0,
|
41 |
+
"type": "ntk"
|
42 |
+
},
|
43 |
+
"rope_theta": 20000,
|
44 |
+
"torch_dtype": "float32",
|
45 |
+
"transformers_version": "4.45.2",
|
46 |
+
"type_vocab_size": 1,
|
47 |
+
"unpad_inputs": false,
|
48 |
+
"use_memory_efficient_attention": false,
|
49 |
+
"vocab_size": 16456,
|
50 |
+
"vocabtrimmer": {
|
51 |
+
"mining_config": {
|
52 |
+
"dataset": "Turbo-AI/data-corpus",
|
53 |
+
"dataset_column": "text",
|
54 |
+
"dataset_name": null,
|
55 |
+
"dataset_split": "train",
|
56 |
+
"language": "vi",
|
57 |
+
"min_frequency": 2,
|
58 |
+
"target_vocab_size": null
|
59 |
+
},
|
60 |
+
"stats": {
|
61 |
+
"compression_rate_embedding": 6.581136421807013,
|
62 |
+
"compression_rate_full": 41.25171334079449,
|
63 |
+
"parameter_size_embedding/raw": 192036864,
|
64 |
+
"parameter_size_embedding/trimmed": 12638208,
|
65 |
+
"parameter_size_full/raw": 305368320,
|
66 |
+
"parameter_size_full/trimmed": 125969664,
|
67 |
+
"vocab_size/raw": 250048,
|
68 |
+
"vocab_size/trimmed": 16456
|
69 |
+
}
|
70 |
+
}
|
71 |
+
}
|
config_sentence_transformers.json
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"__version__": {
|
3 |
+
"sentence_transformers": "3.3.0.dev0",
|
4 |
+
"transformers": "4.45.2",
|
5 |
+
"pytorch": "2.4.1+cu118"
|
6 |
+
},
|
7 |
+
"prompts": {},
|
8 |
+
"default_prompt_name": null,
|
9 |
+
"similarity_fn_name": null
|
10 |
+
}
|
configuration.py
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2024 The GTE Team Authors and Alibaba Group.
|
3 |
+
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
4 |
+
#
|
5 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
+
# you may not use this file except in compliance with the License.
|
7 |
+
# You may obtain a copy of the License at
|
8 |
+
#
|
9 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10 |
+
#
|
11 |
+
# Unless required by applicable law or agreed to in writing, software
|
12 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 |
+
# See the License for the specific language governing permissions and
|
15 |
+
# limitations under the License.
|
16 |
+
""" NEW model configuration"""
|
17 |
+
from transformers.configuration_utils import PretrainedConfig
|
18 |
+
from transformers.utils import logging
|
19 |
+
|
20 |
+
logger = logging.get_logger(__name__)
|
21 |
+
|
22 |
+
|
23 |
+
class NewConfig(PretrainedConfig):
|
24 |
+
r"""
|
25 |
+
This is the configuration class to store the configuration of a [`NewModel`] or a [`TFNewModel`]. It is used to
|
26 |
+
instantiate a NEW model according to the specified arguments, defining the model architecture. Instantiating a
|
27 |
+
configuration with the defaults will yield a similar configuration to that of the NEW
|
28 |
+
[izhx/new-base-en](https://huggingface.co/izhx/new-base-en) architecture.
|
29 |
+
|
30 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
31 |
+
documentation from [`PretrainedConfig`] for more information.
|
32 |
+
|
33 |
+
|
34 |
+
Args:
|
35 |
+
vocab_size (`int`, *optional*, defaults to 30522):
|
36 |
+
Vocabulary size of the NEW model. Defines the number of different tokens that can be represented by the
|
37 |
+
`inputs_ids` passed when calling [`NewModel`] or [`TFNewModel`].
|
38 |
+
hidden_size (`int`, *optional*, defaults to 768):
|
39 |
+
Dimensionality of the encoder layers and the pooler layer.
|
40 |
+
num_hidden_layers (`int`, *optional*, defaults to 12):
|
41 |
+
Number of hidden layers in the Transformer encoder.
|
42 |
+
num_attention_heads (`int`, *optional*, defaults to 12):
|
43 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
44 |
+
intermediate_size (`int`, *optional*, defaults to 3072):
|
45 |
+
Dimensionality of the "intermediate" (often named feed-forward) layer in the Transformer encoder.
|
46 |
+
hidden_act (`str` or `Callable`, *optional*, defaults to `"gelu"`):
|
47 |
+
The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
|
48 |
+
`"relu"`, `"silu"` and `"gelu_new"` are supported.
|
49 |
+
hidden_dropout_prob (`float`, *optional*, defaults to 0.1):
|
50 |
+
The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
|
51 |
+
attention_probs_dropout_prob (`float`, *optional*, defaults to 0.1):
|
52 |
+
The dropout ratio for the attention probabilities.
|
53 |
+
max_position_embeddings (`int`, *optional*, defaults to 512):
|
54 |
+
The maximum sequence length that this model might ever be used with. Typically set this to something large
|
55 |
+
just in case (e.g., 512 or 1024 or 2048).
|
56 |
+
type_vocab_size (`int`, *optional*, defaults to 2):
|
57 |
+
The vocabulary size of the `token_type_ids` passed when calling [`NewModel`] or [`TFNewModel`].
|
58 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
59 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
60 |
+
layer_norm_eps (`float`, *optional*, defaults to 1e-12):
|
61 |
+
The epsilon used by the layer normalization layers.
|
62 |
+
position_embedding_type (`str`, *optional*, defaults to `"rope"`):
|
63 |
+
Type of position embedding. Choose one of `"absolute"`, `"rope"`.
|
64 |
+
rope_theta (`float`, *optional*, defaults to 10000.0):
|
65 |
+
The base period of the RoPE embeddings.
|
66 |
+
rope_scaling (`Dict`, *optional*):
|
67 |
+
Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports two scaling
|
68 |
+
strategies: linear and dynamic. Their scaling factor must be a float greater than 1. The expected format is
|
69 |
+
`{"type": strategy name, "factor": scaling factor}`. When using this flag, don't update
|
70 |
+
`max_position_embeddings` to the expected new maximum. See the following thread for more information on how
|
71 |
+
these scaling strategies behave:
|
72 |
+
https://www.reddit.com/r/LocalLLaMA/comments/14mrgpr/dynamically_scaled_rope_further_increases/. This is an
|
73 |
+
experimental feature, subject to breaking API changes in future versions.
|
74 |
+
classifier_dropout (`float`, *optional*):
|
75 |
+
The dropout ratio for the classification head.
|
76 |
+
|
77 |
+
Examples:
|
78 |
+
|
79 |
+
```python
|
80 |
+
>>> from transformers import NewConfig, NewModel
|
81 |
+
|
82 |
+
>>> # Initializing a NEW izhx/new-base-en style configuration
|
83 |
+
>>> configuration = NewConfig()
|
84 |
+
|
85 |
+
>>> # Initializing a model (with random weights) from the izhx/new-base-en style configuration
|
86 |
+
>>> model = NewModel(configuration)
|
87 |
+
|
88 |
+
>>> # Accessing the model configuration
|
89 |
+
>>> configuration = model.config
|
90 |
+
```"""
|
91 |
+
|
92 |
+
model_type = "new"
|
93 |
+
|
94 |
+
def __init__(
|
95 |
+
self,
|
96 |
+
vocab_size=30528,
|
97 |
+
hidden_size=768,
|
98 |
+
num_hidden_layers=12,
|
99 |
+
num_attention_heads=12,
|
100 |
+
intermediate_size=3072,
|
101 |
+
hidden_act="gelu",
|
102 |
+
hidden_dropout_prob=0.1,
|
103 |
+
attention_probs_dropout_prob=0.0,
|
104 |
+
max_position_embeddings=2048,
|
105 |
+
type_vocab_size=1,
|
106 |
+
initializer_range=0.02,
|
107 |
+
layer_norm_type='layer_norm',
|
108 |
+
layer_norm_eps=1e-12,
|
109 |
+
# pad_token_id=0,
|
110 |
+
position_embedding_type="rope",
|
111 |
+
rope_theta=10000.0,
|
112 |
+
rope_scaling=None,
|
113 |
+
classifier_dropout=None,
|
114 |
+
pack_qkv=True,
|
115 |
+
unpad_inputs=False,
|
116 |
+
use_memory_efficient_attention=False,
|
117 |
+
logn_attention_scale=False,
|
118 |
+
logn_attention_clip1=False,
|
119 |
+
**kwargs,
|
120 |
+
):
|
121 |
+
super().__init__(**kwargs)
|
122 |
+
|
123 |
+
self.vocab_size = vocab_size
|
124 |
+
self.hidden_size = hidden_size
|
125 |
+
self.num_hidden_layers = num_hidden_layers
|
126 |
+
self.num_attention_heads = num_attention_heads
|
127 |
+
self.hidden_act = hidden_act
|
128 |
+
self.intermediate_size = intermediate_size
|
129 |
+
self.hidden_dropout_prob = hidden_dropout_prob
|
130 |
+
self.attention_probs_dropout_prob = attention_probs_dropout_prob
|
131 |
+
self.max_position_embeddings = max_position_embeddings
|
132 |
+
self.type_vocab_size = type_vocab_size
|
133 |
+
self.initializer_range = initializer_range
|
134 |
+
self.layer_norm_type = layer_norm_type
|
135 |
+
self.layer_norm_eps = layer_norm_eps
|
136 |
+
self.position_embedding_type = position_embedding_type
|
137 |
+
self.rope_theta = rope_theta
|
138 |
+
self.rope_scaling = rope_scaling
|
139 |
+
self.classifier_dropout = classifier_dropout
|
140 |
+
|
141 |
+
self.pack_qkv = pack_qkv
|
142 |
+
self.unpad_inputs = unpad_inputs
|
143 |
+
self.use_memory_efficient_attention = use_memory_efficient_attention
|
144 |
+
self.logn_attention_scale = logn_attention_scale
|
145 |
+
self.logn_attention_clip1 = logn_attention_clip1
|
model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:962294746aea75116e7f03dd5565d59eba54d0156fc40a185778c97ad07ca525
|
3 |
+
size 503893088
|
modules.json
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[
|
2 |
+
{
|
3 |
+
"idx": 0,
|
4 |
+
"name": "0",
|
5 |
+
"path": "",
|
6 |
+
"type": "sentence_transformers.models.Transformer"
|
7 |
+
},
|
8 |
+
{
|
9 |
+
"idx": 1,
|
10 |
+
"name": "1",
|
11 |
+
"path": "1_Pooling",
|
12 |
+
"type": "sentence_transformers.models.Pooling"
|
13 |
+
}
|
14 |
+
]
|
sentence_bert_config.json
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"max_seq_length": 1024,
|
3 |
+
"do_lower_case": false
|
4 |
+
}
|
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
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
"16455": {
|
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 |
+
"mask_token": "<mask>",
|
49 |
+
"max_length": 1024,
|
50 |
+
"model_max_length": 1024,
|
51 |
+
"pad_to_multiple_of": null,
|
52 |
+
"pad_token": "<pad>",
|
53 |
+
"pad_token_type_id": 0,
|
54 |
+
"padding_side": "right",
|
55 |
+
"sep_token": "</s>",
|
56 |
+
"stride": 0,
|
57 |
+
"tokenizer_class": "XLMRobertaTokenizer",
|
58 |
+
"truncation_side": "right",
|
59 |
+
"truncation_strategy": "longest_first",
|
60 |
+
"unk_token": "<unk>"
|
61 |
+
}
|