TitanML Co commited on
Commit
815399c
·
verified ·
1 Parent(s): b7d7b59

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Jina V2 Embed Model
2
+
3
+ Reupload of the jina embedding model that removes the dependence on onnx and optimum, by recreating it with a custom class in Takeoff.
4
+
config.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "TitanML/jina-v2-code-embed",
3
+ "architectures": [
4
+ "JinaPostQKNormBertModel"
5
+ ],
6
+ "auto_map": {
7
+ "AutoConfig": "configuration_jina.JinaBertConfig"
8
+ },
9
+ "attention_probs_dropout_prob": 0.0,
10
+ "attn_implementation": "torch",
11
+ "classifier_dropout": null,
12
+ "emb_pooler": "mean",
13
+ "feed_forward_type": "geglu",
14
+ "gradient_checkpointing": false,
15
+ "hidden_act": "gelu",
16
+ "hidden_dropout_prob": 0.0,
17
+ "hidden_size": 768,
18
+ "initializer_range": 0.02,
19
+ "intermediate_size": 3072,
20
+ "layer_norm_eps": 1e-12,
21
+ "max_position_embeddings": 8192,
22
+ "model_max_length": 8192,
23
+ "model_type": "bert",
24
+ "num_attention_heads": 12,
25
+ "num_hidden_layers": 12,
26
+ "pad_token_id": 0,
27
+ "position_embedding_type": "alibi",
28
+ "torch_dtype": "float32",
29
+ "transformers_version": "4.37.0",
30
+ "type_vocab_size": 2,
31
+ "use_cache": true,
32
+ "vocab_size": 61056
33
+ }
configuration_jina.py ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers.modeling_utils import PretrainedConfig
2
+
3
+ class JinaBertConfig(PretrainedConfig):
4
+ r"""
5
+ This is the configuration class to store the configuration of a [`JinaBertModel`]. It is used to
6
+ instantiate a BERT model according to the specified arguments, defining the model architecture. Instantiating a
7
+ configuration with the defaults will yield a similar configuration to that of the BERT
8
+ [bert-base-uncased](https://huggingface.co/bert-base-uncased) architecture.
9
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
10
+ documentation from [`PretrainedConfig`] for more information.
11
+ Args:
12
+ vocab_size (`int`, *optional*, defaults to 30522):
13
+ Vocabulary size of the BERT model. Defines the number of different tokens that can be represented by the
14
+ `inputs_ids` passed when calling [`BertModel`] or [`TFBertModel`].
15
+ hidden_size (`int`, *optional*, defaults to 768):
16
+ Dimensionality of the encoder layers and the pooler layer.
17
+ num_hidden_layers (`int`, *optional*, defaults to 12):
18
+ Number of hidden layers in the Transformer encoder.
19
+ num_attention_heads (`int`, *optional*, defaults to 12):
20
+ Number of attention heads for each attention layer in the Transformer encoder.
21
+ intermediate_size (`int`, *optional*, defaults to 3072):
22
+ Dimensionality of the "intermediate" (often named feed-forward) layer in the Transformer encoder.
23
+ hidden_act (`str` or `Callable`, *optional*, defaults to `"gelu"`):
24
+ The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
25
+ `"relu"`, `"silu"` and `"gelu_new"` are supported.
26
+ hidden_dropout_prob (`float`, *optional*, defaults to 0.1):
27
+ The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
28
+ attention_probs_dropout_prob (`float`, *optional*, defaults to 0.1):
29
+ The dropout ratio for the attention probabilities.
30
+ max_position_embeddings (`int`, *optional*, defaults to 512):
31
+ The maximum sequence length that this model might ever be used with. Typically set this to something large
32
+ just in case (e.g., 512 or 1024 or 2048).
33
+ type_vocab_size (`int`, *optional*, defaults to 2):
34
+ The vocabulary size of the `token_type_ids` passed when calling [`BertModel`] or [`TFBertModel`].
35
+ initializer_range (`float`, *optional*, defaults to 0.02):
36
+ The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
37
+ layer_norm_eps (`float`, *optional*, defaults to 1e-12):
38
+ The epsilon used by the layer normalization layers.
39
+ position_embedding_type (`str`, *optional*, defaults to `"absolute"`):
40
+ Type of position embedding. Choose one of `"absolute"`, `"relative_key"`, `"relative_key_query"`. For
41
+ positional embeddings use `"absolute"`. For more information on `"relative_key"`, please refer to
42
+ [Self-Attention with Relative Position Representations (Shaw et al.)](https://arxiv.org/abs/1803.02155).
43
+ For more information on `"relative_key_query"`, please refer to *Method 4* in [Improve Transformer Models
44
+ with Better Relative Position Embeddings (Huang et al.)](https://arxiv.org/abs/2009.13658).
45
+ is_decoder (`bool`, *optional*, defaults to `False`):
46
+ Whether the model is used as a decoder or not. If `False`, the model is used as an encoder.
47
+ use_cache (`bool`, *optional*, defaults to `True`):
48
+ Whether or not the model should return the last key/values attentions (not used by all models). Only
49
+ relevant if `config.is_decoder=True`.
50
+ classifier_dropout (`float`, *optional*):
51
+ The dropout ratio for the classification head.
52
+ feed_forward_type (`str`, *optional*, defaults to `"original"`):
53
+ The type of feed forward layer to use in the bert layers.
54
+ Can be one of GLU variants, e.g. `"reglu"`, `"geglu"`
55
+ emb_pooler (`str`, *optional*, defaults to `None`):
56
+ The function to use for pooling the last layer embeddings to get the sentence embeddings.
57
+ Should be one of `None`, `"mean"`.
58
+ attn_implementation (`str`, *optional*, defaults to `"torch"`):
59
+ The implementation of the self-attention layer. Can be one of:
60
+ - `None` for the original implementation,
61
+ - `torch` for the PyTorch SDPA implementation,
62
+ Examples:
63
+ ```python
64
+ >>> from transformers import JinaBertConfig, JinaBertModel
65
+ >>> # Initializing a JinaBert configuration
66
+ >>> configuration = JinaBertConfig()
67
+ >>> # Initializing a model (with random weights) from the configuration
68
+ >>> model = JinaBertModel(configuration)
69
+ >>> # Accessing the model configuration
70
+ >>> configuration = model.config
71
+ >>> # Encode text inputs
72
+ >>> embeddings = model.encode(text_inputs)
73
+ ```"""
74
+ model_type = "bert"
75
+
76
+ def __init__(
77
+ self,
78
+ vocab_size=30522,
79
+ hidden_size=768,
80
+ num_hidden_layers=12,
81
+ num_attention_heads=12,
82
+ intermediate_size=3072,
83
+ hidden_act="gelu",
84
+ hidden_dropout_prob=0.1,
85
+ attention_probs_dropout_prob=0.1,
86
+ max_position_embeddings=512,
87
+ type_vocab_size=2,
88
+ initializer_range=0.02,
89
+ layer_norm_eps=1e-12,
90
+ pad_token_id=0,
91
+ position_embedding_type="alibi",
92
+ use_cache=True,
93
+ classifier_dropout=None,
94
+ feed_forward_type="original",
95
+ emb_pooler=None,
96
+ attn_implementation=None,
97
+ **kwargs,
98
+ ):
99
+ super().__init__(pad_token_id=pad_token_id, **kwargs)
100
+
101
+ self.vocab_size = vocab_size
102
+ self.hidden_size = hidden_size
103
+ self.num_hidden_layers = num_hidden_layers
104
+ self.num_attention_heads = num_attention_heads
105
+ self.hidden_act = hidden_act
106
+ self.intermediate_size = intermediate_size
107
+ self.hidden_dropout_prob = hidden_dropout_prob
108
+ self.attention_probs_dropout_prob = attention_probs_dropout_prob
109
+ self.max_position_embeddings = max_position_embeddings
110
+ self.type_vocab_size = type_vocab_size
111
+ self.initializer_range = initializer_range
112
+ self.layer_norm_eps = layer_norm_eps
113
+ self.position_embedding_type = position_embedding_type
114
+ self.use_cache = use_cache
115
+ self.classifier_dropout = classifier_dropout
116
+ self.feed_forward_type = feed_forward_type
117
+ self.emb_pooler = emb_pooler
118
+ self.attn_implementation = attn_implementation
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:d1d91ddd6987ad85eb970b885111ef41b0a709f51b8aba4569f212d02e7272b6
3
+ size 641143048
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,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<s>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<pad>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "2": {
21
+ "content": "</s>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "3": {
29
+ "content": "<unk>",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "4": {
37
+ "content": "<mask>",
38
+ "lstrip": true,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ }
44
+ },
45
+ "bos_token": "<s>",
46
+ "clean_up_tokenization_spaces": true,
47
+ "cls_token": "<s>",
48
+ "eos_token": "</s>",
49
+ "errors": "replace",
50
+ "mask_token": "<mask>",
51
+ "model_max_length": 8192,
52
+ "pad_token": "<pad>",
53
+ "sep_token": "</s>",
54
+ "tokenizer_class": "RobertaTokenizer",
55
+ "trim_offsets": true,
56
+ "unk_token": "<unk>"
57
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff