Skip to content

add incremental linear-chain CRF#119

Open
haozheji wants to merge 2 commits into
harvardnlp:masterfrom
haozheji:mine
Open

add incremental linear-chain CRF#119
haozheji wants to merge 2 commits into
harvardnlp:masterfrom
haozheji:mine

Conversation

@haozheji

@haozheji haozheji commented Nov 4, 2021

Copy link
Copy Markdown

No description provided.

@haozheji haozheji closed this Nov 4, 2021
@srush

srush commented Nov 4, 2021

Copy link
Copy Markdown
Collaborator

Is there a reason you closed this? It looks cool.

@haozheji

Copy link
Copy Markdown
Author

Oh, I just accidentally commit it to the original main branch. If you found it interesting, maybe I can reopen it?

@haozheji haozheji reopened this Nov 15, 2021
Some modifications to the shape of the input of `semiring.matmul` to make it compatible.
@haozheji

Copy link
Copy Markdown
Author

I use forward-backward algorithm to calculate the marginal of linear-chain CRF of the prefix sequence (in order to support AR models). The parallel calculation can be done in O(logN) complexity with a modified parallel scan. I call it interval parallel scan :). The procedure looks like this:
image

@srush

srush commented Nov 15, 2021

Copy link
Copy Markdown
Collaborator

Very neat. I'll take a read. Do you find that this gives a speedup? Seems hard to parallelize.

@haozheji

Copy link
Copy Markdown
Author

You mean the speed up comparing to using the gradient identity? At first I have tried only calculating the prefix sum and using back-propagation to get the marginal of the prefix sequence. But it requires O(N) times of back propagation separately. Otherwise we have to replicate the whole graph N times for O(1) parallel complexity but it will easily hit the GPU memory limit.
The current version requires O(logN) parallel operations, but I haven't test the speed comparing to other implementations yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants