Search code examples
embedallennlp

How can I use the AllenNLP framework to embed a label?


Just like using "textfieldembedder" to embed "textfieldtensors", I want to embed labels and convert them into tensors with the same dimension as embedded input texts.


Solution

  • Do you know about LabelField? Just put the appropriate LabelFields into your instances, and AllenNLP will add the labels to the vocabulary for you. When Model.__init__() runs, you can query the size of the label namespace to find out how big to make your embedding matrix.