Files changed (1) hide show
  1. README.md +46 -1
README.md CHANGED
@@ -72,7 +72,17 @@ should probably proofread and complete it, then remove this comment. -->
72
 
73
  # bert-base-uncased-mrpc
74
 
75
- This model is a fine-tuned version of [bert-base-uncased](https://huggingface.co/bert-base-uncased) on the GLUE MRPC dataset.
 
 
 
 
 
 
 
 
 
 
76
  It achieves the following results on the evaluation set:
77
  - Loss: 0.6978
78
  - Accuracy: 0.8603
@@ -96,3 +106,38 @@ The following hyperparameters were used during training:
96
  - Pytorch 1.10.0+cu102
97
  - Datasets 1.14.0
98
  - Tokenizers 0.11.6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  # bert-base-uncased-mrpc
74
 
75
+ This model is a fine-tuned version of [bert-base-uncased](https://huggingface.co/bert-base-uncased) on the **GLUE MRPC dataset**.
76
+
77
+ It is a pretrained model on English language using a masked language modeling (MLM) objective. It was introduced in this paper and first released in this repository.
78
+ This model is uncased: it does not make a difference between **"english"** and **"English"**.
79
+ BERT base model (uncased)
80
+
81
+ It provides:
82
+ - Masked language modeling (MLM): taking a sentence, the model randomly masks 15% of the words in the input then run the entire masked sentence through the model and has to predict the masked words. This is different from traditional recurrent neural networks (RNNs) that usually see the words one after the other, or from autoregressive models like GPT which internally masks the future tokens. It allows the model to learn a bidirectional representation of the sentence.
83
+ - Next sentence prediction (NSP): the models concatenates two masked sentences as inputs during pretraining. Sometimes they correspond to sentences that were next to each other in the original text, sometimes not. The model then has to predict if the two sentences were following each other or not.
84
+
85
+ # Results
86
  It achieves the following results on the evaluation set:
87
  - Loss: 0.6978
88
  - Accuracy: 0.8603
 
106
  - Pytorch 1.10.0+cu102
107
  - Datasets 1.14.0
108
  - Tokenizers 0.11.6
109
+
110
+ - # To use:
111
+ ```python
112
+ from transformers import BertTokenizer, BertModel
113
+ tokenizer = BertTokenizer.from_pretrained('Intel/bert-base-uncased-mrpc')
114
+ model = BertModel.from_pretrained("Intel/bert-base-uncased-mrpc")
115
+ # text = "according to the theory of aerodynamics and wind tunnel experiments the bumble bee is unable to fly. This is bcause the size, weight, and shape of his body in relation to total wingspread makes flying impossible. But, the bumble bee being ignorant of these pround scientific truths goes ahead and flies anyway, and manages to make a little honey everyday."
116
+ text = "The inspector analyzed the soundness in the building."
117
+ encoded_input = tokenizer(text, return_tensors='pt')
118
+ output = model(**encoded_input)
119
+ # print BaseModelOutputWithPoolingAndCrossAttentions and pooler_output
120
+ # output similar to:
121
+ ```
122
+ BaseModelOutputWithPoolingAndCrossAttentions(last_hidden_state=tensor([[[ 0.0219, 0.1258, -0.8529, ..., 0.6416, 0.6275, 0.5583],
123
+ [ 0.3125, -0.1921, -0.9895, ..., 0.6069, 1.8431, -0.5939],
124
+ [ 0.6147, -0.6098, -0.3517, ..., -0.1145, 1.1748, -0.7104],
125
+ ...,
126
+ [ 0.8959, -0.2324, -0.6311, ..., 0.2424, 0.1025, 0.2101],
127
+ [ 0.2484, -0.3004, -0.9474, ..., 1.0401, 0.5493, -0.4170],
128
+ [ 0.8206, 0.2023, -0.7929, ..., 0.7073, 0.0779, -0.2781]]],
129
+ grad_fn=<NativeLayerNormBackward0>), pooler_output=tensor([[-0.7867, 0.1878, -0.8186, 0.8494, 0.4263, 0.5157, 0.9564, 0.1514,
130
+ -0.9176, -0.9994, 0.2962, 0.2891, -0.3301, 0.8786, 0.9234, -0.7643,
131
+ 0.2487, -0.5245, -0.0649, -0.6722, 0.8550, 1.0000, -0.7785, 0.5322,
132
+ 0.6056, 0.4622, 0.2838, 0.5501, 0.6981, 0.2597, -0.7896, -0.1189,
133
+
134
+ ```python
135
+ # Print tokens * ids in of inmput string below
136
+ print('Tokenized Text: ', tokenizer.tokenize(text), '\n')
137
+ print('Token IDs: ', tokenizer.convert_tokens_to_ids(tokenizer.tokenize(text)))
138
+
139
+ #Print tokens in text
140
+ encoded_input['input_ids'][0]
141
+ tokenizer.convert_ids_to_tokens(encoded_input['input_ids'][0])
142
+ ```
143
+