sgugger commited on
Commit
d895845
1 Parent(s): ae6c706

Initial commit

Browse files
config.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "sgugger/finetuned-bert-mrpc",
3
+ "architectures": [
4
+ "BertForSequenceClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "custom_pipelines": {
9
+ "pair-classification": {
10
+ "impl": "pair_classification.PairClassificationPipeline",
11
+ "pt": "AutoModelForSequenceClassification",
12
+ "tf": "TFAutoModelForSequenceClassification"
13
+ }
14
+ },
15
+ "gradient_checkpointing": false,
16
+ "hidden_act": "gelu",
17
+ "hidden_dropout_prob": 0.1,
18
+ "hidden_size": 768,
19
+ "id2label": {
20
+ "0": "not equivalent",
21
+ "1": "equivalent"
22
+ },
23
+ "initializer_range": 0.02,
24
+ "intermediate_size": 3072,
25
+ "label2id": {
26
+ "equivalent": 1,
27
+ "not equivalent": 0
28
+ },
29
+ "layer_norm_eps": 1e-12,
30
+ "max_position_embeddings": 512,
31
+ "model_type": "bert",
32
+ "num_attention_heads": 12,
33
+ "num_hidden_layers": 12,
34
+ "pad_token_id": 0,
35
+ "position_embedding_type": "absolute",
36
+ "problem_type": "single_label_classification",
37
+ "torch_dtype": "float32",
38
+ "transformers_version": "4.21.0.dev0",
39
+ "type_vocab_size": 2,
40
+ "use_cache": true,
41
+ "vocab_size": 28996
42
+ }
pair_classification.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import Pipeline
2
+ import torch
3
+
4
+ class PairClassificationPipeline(Pipeline):
5
+ def _sanitize_parameters(self, **kwargs):
6
+ preprocess_kwargs = {}
7
+ if "text_pair" in kwargs:
8
+ preprocess_kwargs["text_pair"] = kwargs["text_pair"]
9
+ return preprocess_kwargs, {}, {}
10
+
11
+ def preprocess(self, text, text_pair=None):
12
+ return self.tokenizer(text, text_pair=text_pair, return_tensors="pt")
13
+
14
+ def _forward(self, model_inputs):
15
+ return self.model(**model_inputs)
16
+
17
+ def postprocess(self, model_outputs):
18
+ logits = model_outputs.logits
19
+ probabilities = torch.nn.functional.softmax(logits, dim=-1)
20
+
21
+ best_class = probabilities.argmax().item()
22
+ label = self.model.config.id2label[best_class]
23
+ score = probabilities.squeeze()[best_class].item()
24
+ logits = logits.squeeze().tolist()
25
+ return {"label": label, "score": score, "logits": logits}
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fb4ff71c41b993ad8531e00ca325ef3c7938156427dccae355771c026a75d4ad
3
+ size 433315437
special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
tokenizer_config.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "do_lower_case": false,
4
+ "mask_token": "[MASK]",
5
+ "model_max_length": 512,
6
+ "name_or_path": "sgugger/finetuned-bert-mrpc",
7
+ "pad_token": "[PAD]",
8
+ "sep_token": "[SEP]",
9
+ "special_tokens_map_file": null,
10
+ "strip_accents": null,
11
+ "tokenize_chinese_chars": true,
12
+ "tokenizer_class": "BertTokenizer",
13
+ "unk_token": "[UNK]"
14
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff