microth / PathLSTM

Neural SRL model
71 stars 14 forks source link

Generate Dependency Path Embedding #23

Closed smilenrhyme closed 5 years ago

smilenrhyme commented 5 years ago

Hi,

Its a great effort towards SRL Task 👍 I was looking for getting dependency path embeddings instead of end-to-end SRL pipeline. Could you please share or guide in achieving sample code which illustrates generation of dependency path embeddings with some sample text input. (may be dig into intermediate steps as well)

It would be great learning more about dependency path embeddings from you. Looking forward from you !!

microth commented 5 years ago

Hi,

The embedding of the dependency path between a predicate pred and an argument arg, as represented by the hidden layer state of the LSTM at the end of the path, is calculated in the function call here:

https://github.com/microth/PathLSTM/blob/pre-illinois-built/src/main/java/uk/ac/ed/inf/srl/features/DependencyPathEmbedding.java#L135

Line 141 of the same file provides an example of how to access the embedding representation itself:

(AbstractWeightedCompound)net.getComponentByName("Hidden")).getOutput().getActivations()

(Note that the function getFeatureValue() is called twice during the end-to-end task: once for argument identification and once for argument classification. Of course, the embeddings look different for the (first) unlabeled identification step vs. the (second) actual role labeling step.)

Hope that helps!

Best, Michael