lj408 commited on
Commit
7b2d0eb
·
verified ·
1 Parent(s): 56570f9

Upload folder using huggingface_hub

Browse files
config.json ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "lj408/PatClaimEval-Quality",
3
+ "architectures": [
4
+ "ContrastiveModel"
5
+ ],
6
+ "auto_map": {
7
+ "AutoModel": "modeling_contrastive.ContrastiveModel"
8
+ },
9
+ "attention_mode": "longformer",
10
+ "attention_probs_dropout_prob": 0.1,
11
+ "attention_window": [
12
+ 512,
13
+ 512,
14
+ 512,
15
+ 512,
16
+ 512,
17
+ 512,
18
+ 512,
19
+ 512,
20
+ 512,
21
+ 512,
22
+ 512,
23
+ 512
24
+ ],
25
+ "bos_token_id": 0,
26
+ "eos_token_id": 2,
27
+ "gradient_checkpointing": false,
28
+ "hidden_act": "gelu",
29
+ "hidden_dropout_prob": 0.1,
30
+ "hidden_size": 768,
31
+ "ignore_attention_mask": false,
32
+ "initializer_range": 0.02,
33
+ "intermediate_size": 3072,
34
+ "layer_norm_eps": 1e-05,
35
+ "max_position_embeddings": 4098,
36
+ "model_type": "longformer",
37
+ "num_attention_heads": 12,
38
+ "num_hidden_layers": 12,
39
+ "onnx_export": false,
40
+ "pad_token_id": 1,
41
+ "sep_token_id": 2,
42
+ "torch_dtype": "float32",
43
+ "transformers_version": "4.46.2",
44
+ "type_vocab_size": 1,
45
+ "vocab_size": 50265,
46
+ "license": "cc-by-nc-4.0"
47
+ }
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:90fe3d9634fa8ac8b91e3f4c27a0479110c10c99046278701418955aace1ae49
3
+ size 594673468
modeling_contrastive.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import PreTrainedModel, LongformerConfig, LongformerModel
2
+ import torch.nn as nn
3
+ import torch
4
+
5
+ class ContrastiveModel(PreTrainedModel):
6
+
7
+ config_class = LongformerConfig
8
+
9
+ def __init__(self, config):
10
+ super().__init__(config)
11
+ self.bert = LongformerModel._from_config(config)
12
+ self.fc = nn.Linear(config.hidden_size, 1)
13
+
14
+ def compute_score(self, input_ids, attention_mask):
15
+ outputs = self.bert(input_ids=input_ids, attention_mask=attention_mask)
16
+ pooled_output = outputs.pooler_output
17
+ score = self.fc(pooled_output).squeeze()
18
+ score = torch.sigmoid(score)
19
+ return score
20
+
21
+ def score_pair(self, sentence_a, sentence_b, tokenizer, device, max_length=2048):
22
+
23
+ inputs = tokenizer(
24
+ sentence_a, sentence_b,
25
+ return_tensors="pt", padding="max_length", truncation=True,
26
+ max_length=max_length
27
+ ).to(device)
28
+
29
+ with torch.no_grad():
30
+ score = self.compute_score(inputs["input_ids"], inputs["attention_mask"])
31
+ return score.item()
special_tokens_map.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "cls_token": "<s>",
4
+ "eos_token": "</s>",
5
+ "mask_token": {
6
+ "content": "<mask>",
7
+ "lstrip": true,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false
11
+ },
12
+ "pad_token": "<pad>",
13
+ "sep_token": "</s>",
14
+ "unk_token": "<unk>"
15
+ }
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": true,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<pad>",
14
+ "lstrip": false,
15
+ "normalized": true,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "2": {
21
+ "content": "</s>",
22
+ "lstrip": false,
23
+ "normalized": true,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "3": {
29
+ "content": "<unk>",
30
+ "lstrip": false,
31
+ "normalized": true,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "50264": {
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": false,
47
+ "cls_token": "<s>",
48
+ "eos_token": "</s>",
49
+ "errors": "replace",
50
+ "mask_token": "<mask>",
51
+ "model_max_length": 1000000000000000019884624838656,
52
+ "pad_token": "<pad>",
53
+ "sep_token": "</s>",
54
+ "tokenizer_class": "LongformerTokenizer",
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