Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add incremental linear-chain CRF #119

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

haozheji
Copy link

@haozheji haozheji commented Nov 4, 2021

No description provided.

@haozheji haozheji closed this Nov 4, 2021
@srush
Copy link
Collaborator

srush commented Nov 4, 2021

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

@haozheji
Copy link
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
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
Copy link
Collaborator

srush commented Nov 15, 2021

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

@haozheji
Copy link
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