Closed ganarajpr closed 9 years ago
Currently, there isn't a single convenient script for preprocessing and predicting on new sentence pairs (that said, I plan to add the functionality soon).
In order to predict on a sentence pair, you should call the function TreeLSTMSim:predict(ltree, rtree, lsent, rsent) (see https://github.com/stanfordnlp/treelstm/blob/master/relatedness/TreeLSTMSim.lua#L142). ltree and rtree are dependency parse trees of the 'left' and 'right' sentences respectively (see the preprocessing script https://github.com/stanfordnlp/treelstm/blob/master/scripts/preprocess-sick.py for how these parses can be produced). lsent and rsent are 1D Torch tensors consisting of indices into the vocabulary. Since your dataset will have a different vocabulary, you'll probably want to change this function to directly accept NxD tensors of word vectors (where N = sentence length and D = word vector dim).
So basically it should be pretty straightforward:
As per the instructions in the readme I ran the relatedness code and got it to run for 10 epocs - which produced a new trained_models folder containing the "trainedmodel". I am not really sure how I can use this trained model to use with my own two sentences to find a relatedness score between them ?