-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
example for is next sentence #48
Comments
I think it should work. You should get a [1, 2] tensor of logits where |
Closing that for now, feel free to reopen if there is another issue. |
Guys, are [CLS] and [SEP] tokens mandatory for this example? |
This is not super clear, even wrong in the examples, but there is this note in the docstring for
That seems to suggest pretty strongly that you have to put in the |
How do i infer this as true or false |
Those are the logits, because you did not pass the My understanding is that you could apply a softmax and get the probability for the sequence to be a possible sequence.
For the first example the probability that the second sentence is a probable continuation is very low. |
predictions = model(tokens_tensor, segments_tensors ) |
Maybe your model is not in evaluation mode ( |
It is OK.THANKS A LOT. |
The above issues get resolved, when I added few extra 1's and 0's to make the shape similar tokens_tensor and segments_tensors. Just wondering am I using in a right way. My predictions output is a tensor array of size 21 X 30522 . |
@thomwolf Actually even when I used model.eval() I still got different results. I observed this when I use every model of the package (BertModel, BertForNextSentencePrediction etc). Only when I fixed the length of the input (e.g. to 128), I can get the same results. In this way I have to pad 0 to indexed_tokens so it has a fixed length. Could you explain why is like this, or did I make any mistake? Thank you so much! |
Make sure
I had symilar symptoms when vocab and config was from diferent berts |
I noticed that the probability for longer sentences, regardless of how much they are related to the same subject, is higher than the shorter ones. For example, I added some random sentences to the end of the first or second part and observed significant increase in the first logit value. Is it a way to regularize the model for the next sentence prediction? |
@pbabvey I am observing the same thing. |
im getting different scores for the sentences that you have tried . please advise why i'm getting it below is my code . import torch text1 = "How old are you?" text1_toks = ["[CLS]"] + tokenizer.tokenize(text1) + ["[SEP]"] tokens_tensor = torch.tensor([indexed_tokens]) o/p of predictions o/p of prediction_sm why is the score still high 0.9923 even after apply softmax ? |
I am facing the same issue. No matter what sentences I use, I always get very high probability of the second sentence being related to the first. |
Yes it was the same issue. And the solution worked like a charm. |
@LysandreJik thanks for the information |
update rationale label generation for mt/mat coqa runner
Use CheckpointManager for checkpointing
Can you make up a working example for 'is next sentence'
Is this expected to work properly ?
The text was updated successfully, but these errors were encountered: