Georgetown-IR-Lab / cedr

Code for CEDR: Contextualized Embeddings for Document Ranking, accepted at SIGIR 2019.
MIT License
156 stars 28 forks source link

Cannot reproduce VanillaBERT's result on Robust04 #12

Closed a94763075 closed 4 years ago

a94763075 commented 4 years ago

I reproduce VanillaBERT but only get the result **NDCG@20:0.3889 P@20 :0.3180 optimizer :AdamW batch size :1 lr = 1e-5* Train by HingeLoss and by following code's provided 'f.train.pairs' list to random choose pos neg pairs

far from paper's NDCG@20:0.4541 P@20 :0.4042


class VanillaBERT(nn.Module):

    def __init__(self):

        super(VanillaBERT, self).__init__()
        self.bert = BertModel.from_pretrained(pretrained_weights)
        self.dropout =  torch.nn.Dropout(0.1)
        self.Out_FC = nn.Linear(768,1)

    def forward(self, _input_ids,_token_type_ids):
        outputs= self.bert(input_ids=_input_ids.squeeze(1),token_type_ids=_token_type_ids.squeeze(1))
        #print(np.shape(outputs[0][0][0]))
        cls_reps = outputs[0][0][0]
        Pred_out = self.Out_FC(self.dropout(cls_reps))

        return Pred_out
seanmacavaney commented 4 years ago

Hi @a94763075,

It looks like there are a lot of differences that you have, as compared to our implementation and what we reported, which may explain the model's low performance. To name a few:

Can you try using the implementations in this repository directly? Then, if you're still having problems, it will be easier to figure out what's going wrong. Without starting from the same place, it'll be very difficult to figure out what exactly is wrong.

Thanks, sean

a94763075 commented 4 years ago

I have implementations in this repository. Dev NDCG@20:0.4066 P@20:0.4701 It works fine

In my reproduce by your suggestion

But it still have some little different. Dev NDCG@20:0.37536 P@20:0.43176

seanmacavaney commented 4 years ago

It sounds like you are trying to debug your implementation? I cannot really help without the code you are using itself. I'd recommend continuing to replace components in your implementation with those found in this repository. Specifically, handling longer documents is probably important.