harvardnlp / pytorch-struct

Fast, general, and tested differentiable structured prediction in PyTorch
http://harvardnlp.github.io/pytorch-struct
MIT License
1.11k stars 93 forks source link

multi-root non-projective dependency crf with lengths mask #87

Closed chijames closed 3 years ago

chijames commented 3 years ago

Hi,

I implement the feature as stated in title. The implementation basically follows section 3.3 of [1] with similar gradient update rules for marginals (like those in 3.2). I check marginals using the log-partition/marginals identity and they are the same. Let me know if anything needs to be improved!

[1] Structured Prediction Models via the Matrix-Tree Theorem. Koo et al. 2007.

srush commented 3 years ago

This is great thanks for contributing.

Sorry the repo is having some issues due to the travis. I will fix it up this week and add tests.