Skip to content
This repository has been archived by the owner on Oct 13, 2022. It is now read-only.

Can we merge a batch of text into one decoding graph? #24

Open
yaguanghu opened this issue Nov 20, 2020 · 9 comments
Open

Can we merge a batch of text into one decoding graph? #24

yaguanghu opened this issue Nov 20, 2020 · 9 comments

Comments

@yaguanghu
Copy link
Contributor

Hello, I'm learning using k2 to implement CTC.
In the "create_decoding_graph" function, it seems like merging a batch of label text into one decoding graph, is it reasonable?

def create_decoding_graph(texts, L, symbols):

def create_decoding_graph(texts, L, symbols):
    word_ids_list = []
    for text in texts:
        filter_text = [
            i if i in symbols._sym2id else '<UNK>' for i in text.split(' ')
        ]
        word_ids = [symbols.get(i) for i in filter_text]
        word_ids_list.append(word_ids)

And, what's the meaning of the following line, for ctc blank self loop?

decoding_graph = k2.add_epsilon_self_loops(decoding_graph)

@qindazhu
Copy link
Collaborator

Sure, definitely we need to do this, we also plan to cache those static decoding graph at the beginning of training.

@yaguanghu
Copy link
Contributor Author

In my opinion, we should create an independent label graph for each utterance.That means we can get a list of decoding graph at the begining of training, or during training.
But according to the above code, it seems like merging those into one graph. Is my understanding right?

@danpovey
Copy link
Contributor

danpovey commented Nov 20, 2020 via email

@yaguanghu
Copy link
Contributor Author

I see.
So what's the meaning of "add_epsilon_self_loops"?

decoding_graph = k2.add_epsilon_self_loops(decoding_graph)

@qindazhu
Copy link
Collaborator

We add self-loops with symbol zero (epsilon) here so it can match blank in CTC training. You may want to check the code intersect_dense_pruned below, we do CTC alignment with FSA intersection. Noted we view network output as an Fsa (dense_fsa_vec) as well

@yaguanghu
Copy link
Contributor Author

How to deal with repeated characters?

@danpovey
Copy link
Contributor

danpovey commented Nov 20, 2020 via email

@yaguanghu
Copy link
Contributor Author

I see.
Maybe i can try to implement a standard CTC with k2, is it worth doing?

@danpovey
Copy link
Contributor

danpovey commented Nov 20, 2020 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants