google-research / smore

Apache License 2.0
162 stars 28 forks source link

Issue with saving a trained model with Torchscript #15

Open jesunsahariar opened 10 months ago

jesunsahariar commented 10 months ago

Hello,

Thank you for sharing the code to train models for link predictions on KGs!

I am currently trying to save a trained model (vecFeatured) on the wikikgv2 dataset for link prediction by adding saved_model = torch.jit.script(model) line to the last line of the save_model function. However, when Torchscript tries to execute this line, it throws the following error:

Tried to set an attribute: job_handle on a non-class: Tensor: 
smore/common/embedding/sparse_embed.py", line 66 
else:
                mat = self.embedding[indices]
            mat.job_handle = self.dummy_job
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
            return mat

I was wondering whether you have any suggestion to get around this error or any suggestion in general to save a trained model from your repo to be used for inference (in a C++ library). Thanks in advance!

Best regards, Jesun Firoz