Closed Dzz1th closed 2 years ago
Hi! Thanks for the suggestion! I never thought about that, because I always had the original data.
I think you might be good to go if you comment out the self._build_optimizers()
bit (you might need to manually initialize self.optimizers
and self.schedulers
as empty dictionaries).
Let me know how it works out for you!
I will fix this later myself in the master branch, thanks again.
@vdobrovolskii I found out following error:
Traceback (most recent call last):
File "predict.py", line 71, in <module>
result = model.run(doc)
File "/home/mlb/Job/nlp_trading/src/coreference_resolution/wl-coref/coref/coref_model.py", line 220, in run
words, cluster_ids = self.we(doc, self._bertify(doc))
File "/home/mlb/Job/nlp_trading/src/coreference_resolution/wl-coref/coref/coref_model.py", line 359, in _bertify
return out[subword_mask_tensor]
TypeError: only integer tensors of a single element can be converted to an index
I printed out subword_mask_tensor and found that it is tensor of bool. So, what should be there to done it correctly? I used sample_input.jsonline as input for model.
Hmmm. Are you using the same versions of dependencies as listed in requirements.txt?
Boolean masks can be freely used as indices in pytorch, so I am a little confused. Please, make sure that you install the versions from requirements.txt, if it doesn't work, send me the output of your pip freeze
and I'll try to reproduce your error.
@vdobrovolskii I use the latest pytorch version(1.9), so the trouble was here:
out, _ = self.bert(
subwords_batches_tensor,
attention_mask=torch.tensor(
attention_mask, device=self.config.device))
In latest pytorch versions self.bert return
<class 'transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions'>
, so you need just to get only out and then to extract 'last_hidden_state' manually. After this code is running successfully.
I will fix this later myself in the master branch, thanks again.
Looking forward to it, @vdobrovolskii. Thanks for your awesome research!
@vdobrovolskii I use the latest pytorch version(1.9), so the trouble was here:
out, _ = self.bert( subwords_batches_tensor, attention_mask=torch.tensor( attention_mask, device=self.config.device))
In latest pytorch versions self.bert return
<class 'transformers.modeling_outputs.BaseModelOutputWithPoolingAndCrossAttentions'>
, so you need just to get only out and then to extract 'last_hidden_state' manually. After this code is running successfully.
@Dzz1th I am stuck at this can you please describe it? Thank you
@ShahzebPurelogics The output of AutoModel is now different, so try downgrading or using this line of code as a replacement:
out = self.bert(subwords_batches_tensor, attention_mask=torch.tensor(attention_mask, device=self.config.device)).last_hidden_state
Hi! Thank you for posting the model. Could you please provide how to make inference from the box? If I understood correctly, model from dropbox has already been fitted, so we should be able to run it, but by the design model require original data and building of optimisers to run
So maybe there is an option to run it without all this stuff?