kalpeshk2011
commited on
Commit
•
d00deae
1
Parent(s):
66cb577
add model
Browse files- config.json +34 -0
- modeling_rankgen.py +19 -0
- pytorch_model.bin +3 -0
config.json
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "rankgen-models-hf/rankgen-t5-large-all",
|
3 |
+
"architectures": [
|
4 |
+
"T5EncoderWithProjection"
|
5 |
+
],
|
6 |
+
"auto_map": {
|
7 |
+
"AutoModel": "modeling_rankgen.T5EncoderWithProjection"
|
8 |
+
},
|
9 |
+
"d_ff": 2816,
|
10 |
+
"d_kv": 64,
|
11 |
+
"d_model": 1024,
|
12 |
+
"decoder_start_token_id": 0,
|
13 |
+
"dense_act_fn": "gelu_new",
|
14 |
+
"dropout_rate": 0.1,
|
15 |
+
"eos_token_id": 1,
|
16 |
+
"feed_forward_proj": "gated-gelu",
|
17 |
+
"initializer_factor": 1.0,
|
18 |
+
"is_encoder_decoder": true,
|
19 |
+
"is_gated_act": true,
|
20 |
+
"layer_norm_epsilon": 1e-06,
|
21 |
+
"model_type": "t5",
|
22 |
+
"num_decoder_layers": 24,
|
23 |
+
"num_heads": 16,
|
24 |
+
"num_layers": 24,
|
25 |
+
"output_past": true,
|
26 |
+
"pad_token_id": 0,
|
27 |
+
"relative_attention_max_distance": 128,
|
28 |
+
"relative_attention_num_buckets": 32,
|
29 |
+
"tie_word_embeddings": false,
|
30 |
+
"torch_dtype": "float32",
|
31 |
+
"transformers_version": "4.20.1",
|
32 |
+
"use_cache": true,
|
33 |
+
"vocab_size": 32128
|
34 |
+
}
|
modeling_rankgen.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
import tqdm
|
3 |
+
from torch import nn
|
4 |
+
from transformers import T5PreTrainedModel, T5EncoderModel
|
5 |
+
|
6 |
+
class T5EncoderWithProjection(T5PreTrainedModel):
|
7 |
+
def __init__(self, config):
|
8 |
+
super().__init__(config)
|
9 |
+
self.config = config
|
10 |
+
self.t5_encoder = T5EncoderModel(config)
|
11 |
+
self.projection = nn.Linear(config.d_model, config.d_model, bias=False)
|
12 |
+
# Initialize weights and apply final processing
|
13 |
+
self.post_init()
|
14 |
+
|
15 |
+
def forward(self, **input_args):
|
16 |
+
hidden_states = self.t5_encoder(**input_args).last_hidden_state
|
17 |
+
hidden_states = hidden_states[:, 0, :]
|
18 |
+
batch_embeddings = self.projection(hidden_states)
|
19 |
+
return batch_embeddings
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9e41327687cf94fcf85524b03d585641cd1850ec9b1c176c6a6207bb9f52726a
|
3 |
+
size 1369192009
|