jmschrei / pomegranate

Fast, flexible and easy to use probabilistic modelling in Python.
http://pomegranate.readthedocs.org/en/latest/
MIT License
3.35k stars 589 forks source link

Top-K Viterbi #983

Closed kroegern1 closed 1 year ago

kroegern1 commented 2 years ago

Hello Jacob, thank you for your Pomegranate efforts - much appreciated!

I want to get the top-k paths from viterbi (or forward algorithm if that's easier). I see there's no functionality for this so I'm trying to find a way to make it work, but I'm confused because of the silent states (I don't understand the purpose of them).

I found code for Top-K Viterbi and am using this: https://gist.github.com/PetrochukM/afaa3613a99a8e7213d2efdd02ae4762

I'm making 2 assumptions on the inputs for this to work. Can you confirm if my understanding is correct? :

viterbi_paths, viterbi_scores = viterbi_decode(seq, trans_mat, top_k=num_top_paths)

1) trans_mat, is the transition matrix - model.dense_transition_matrix(). But this has the silent states so I'm worried if this will work at all. 2) seq, is the state conditional (emission) probabilities for a given sequence - calculated using model.predict_log_proba() - which doesn't seem give the probabilities for silent states.

jmschrei commented 1 year ago

Thank you for opening an issue. pomegranate has recently been rewritten from the ground up to use PyTorch instead of Cython (v1.0.0), and so all issues are being closed as they are likely out of date. Please re-open or start a new issue if a related issue is still present in the new codebase.