Skip to content

Character-level BiLSTM take the first and last hidden state #426

@allanj

Description

@allanj

I want to implement character embedding with BiLSTM as in this paper(Neural Architectures for Named Entity Recognition Guillaume)
.
Specifically, I give the characters of a word as input to a BiLSTM.
Then I concatenate the last hidden state of the forward LSTM and the first hidden state of the backward LSTM, that's the result I want.

However, I found it would be hard if I have the variable length of words.

Let's say the word contains 3 characters (1 2 and 3), the maximal length is 5.
So, the input to the BiLSTM will be the embeddings of the following tokens:

1, 2, 3, 0, 0

But, if I want to take the last hidden state, it would become 0 since the last hidden state is padded by 0. I couldn't let the model know to get the third position as a different sentence has a different position.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions