kalpeshk2011 commited on
Commit
496f727
1 Parent(s): 2f3d3a7
Files changed (3) hide show
  1. config.json +34 -0
  2. modeling_rankgen.py +19 -0
  3. pytorch_model.bin +3 -0
config.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "rankgen-models-hf/rankgen-t5-base-all",
3
+ "architectures": [
4
+ "T5EncoderWithProjection"
5
+ ],
6
+ "auto_map": {
7
+ "AutoModel": "modeling_rankgen.T5EncoderWithProjection"
8
+ },
9
+ "d_ff": 2048,
10
+ "d_kv": 64,
11
+ "d_model": 768,
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": 12,
23
+ "num_heads": 12,
24
+ "num_layers": 12,
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:0050b2c1fcdba84d9e0bdb3f06d869187868e9fece579ac0840eb2e6315b5ab5
3
+ size 440910241