Performing MRPC task after Fine Tuning
## ❓ Questions & Help

Sorry if this is really basic; I'm new to BERT and machine learning in general. I want to perform the MRPC task. I went ahead and did the fine-tuning and got the files/model okay. But now that I have this fine-tuned model, I'm confused how to do the actual MRPC task (i.e. given two sentences, produce a 1 if they are paraphrases or a 0 if they are not).

I think that I generally have the setup correct (see the code below), but my main problem is what to do with the tuple that is produced from the model. How do you turn that tuple output into the desired 0 or 1?

Thank you in advance for the help!

Code:

```
import torch
from pytorch_transformers import (BertForSequenceClassification, BertTokenizer)

#Creating two sentences to compare
sen1 = "I made a discovery."
sen2 = "I discovered something."

#Creating the tokenizer and model
fine_tuned_model_loc = '../pytorch-transformers/tmp/MRPC'
tokenizer = BertTokenizer.from_pretrained(fine_tuned_model_loc)
model = BertForSequenceClassification.from_pretrained(fine_tuned_model_loc)

#Prepare tokenized input
sen1_tokens = ["[CLS]"] + tokenizer.tokenize(sen1) + ["[SEP]"]
sen2_tokens = tokenizer.tokenize(sen2) + ["[SEP]"]

indexed_tokens = tokenizer.convert_tokens_to_ids(sen1_tokens + sen2_tokens)
token_type_ids = [0]*len(sen1_tokens) + [1]*len(sen2_tokens)
attention_mask = [1]*len(sen1_tokens + sen2_tokens)

#Turning things into a tensor
tokens_tensor = torch.tensor([indexed_tokens])
ids_tensor = torch.tensor([token_type_ids])
attention_tensor = torch.tensor([attention_mask])

#Run the model on the given info
model.eval()
with torch.no_grad():
    output = model(input_ids=tokens_tensor, token_type_ids=ids_tensor, \
                         attention_mask=attention_tensor)
```
You can refer the code to run inference which I had written for sentiment classfication. HTH.
https://github.com/nikhilno1/nlp_projects/blob/master/pytorch-transformers-extensions/examples/run_inference.py<|||||>Ah, that was exactly what I needed; thank you!

One final thing, though: I'm still a bit confused on exactly what the "labels" are they you put into the model. Looking at your code, it seems like they can either have a value of "0" or "1", but I'm confused when it should be one over the other. Or does that not really matter when you are doing inference?<|||||>It does not matter. It is just a dummy input.<|||||>Alright! Thanks again for all of your help!