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

Update x_ops.cc #51

Merged
merged 3 commits into from
Mar 28, 2019
Merged

Update x_ops.cc #51

merged 3 commits into from
Mar 28, 2019

Conversation

zh794390558
Copy link
Contributor

No description provided.

@googlebot googlebot added the cla: yes For the CLA bot label Mar 26, 2019
drpngx
drpngx previously approved these changes Mar 28, 2019
Copy link
Contributor

@drpngx drpngx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@lingvo-bot lingvo-bot merged commit d91f97e into tensorflow:master Mar 28, 2019
lingvo-bot pushed a commit that referenced this pull request Mar 28, 2019
PiperOrigin-RevId: 240686612
copybara-service bot pushed a commit that referenced this pull request Oct 24, 2021
…els.

Highlights:

1. Introducing additional terminating condition "force_last_chunk_eoc_in_topk". This option is in spirit similar to the existing "force_eos_in_topk". If force_last_chunk_eoc_in_topk set to True, when the local score of last chunk eoc is not high enough to enter the top-(k+2) extensions of the input hyp, we force it to be included. This makes it easier to terminate by last chunk eoc. Even with the rest changes, this modification was crucial to bring down the TPU WER for voice search to 6.4% from around 17.0% (see b/199517196, #70). In the unit test of beam_search_equivalence_test.py, this option helps the voice search model to terminate on the "triumphal ornaments" utterance even for the cpu beam search helper. The implementation of this logic was recently checked in for the cpu beam search helper in cl/402971620, and here we test the equivalence with real model and data.

2. Writing a new merge_hyps operation to perform exact path merging. This is achieved by maintaining the token history for active hyps, similarly to the "prev_labels" field of the Hyp structure in cpu beam search. The proposed implementation does not use any loop and shall be time efficient. Also the history is overwritten at each step, and we do not store this info across all decoding steps. The time and memory complexity for merge_hyps is of the order O(num_beams * num_hyps_per_beam^2 * target_seq_len) and in our typical RNN-T use case, num_beams=32, num_hyps_per_beam=4 or 8, target_seq_len=256 for EMBR training; such complexity shall be affordable. Note the previous merge_hyps implementation uses hash maps to approximately maintain hyp history, and it was observed that hash map collision occur frequently (see b/199517196, #51), causing the merged score to be wrong.

Other changes:

3. Providing the option to disable fast gather of float32 and bool matrices by matmul, throughout the tpu beam search helper. It was observed that matmul may cause severe loss of precision, see cl/402747554 and b/199517196 (#52).

4. Switched the order of merge_hyps and determining terminating hyps. Previously we merge hyps before terminating, and thus it is possible that a last chunk eoc (last frame blank) is merged and this extension is killed, making it harder to terminate the hyp.

5. Move last chunk eoc off the beam regardless of whether it can terminate. The reason is that if a eoc extension survives pruning, it will advance frame index for RNN-T models. And if a last chunk eoc survives pruning, it will try to move frame index out of bound (though we do have safeguard for this in steps/rnnt_features.py).

6. Due to changes 4 and 5, we now handle terminations before merging hyps, and therefore terminating scores are not merged to active hyps. I think this is the correct behavior and is consistent with CPU beam search. Another advantage with this change is that we can now perform top-k selection directly on the remaining extensions (there are k * (k+2) of them) without any more eos and eoc tokens. This allows us to completely remove the confusing 2*k pre-selection logic in previous implementation.

7. Introduced new option "combine_eos_and_eoc_strategy". When both eoc and eos can terminate the hypothesis, this option specifies whether to use the higher score (what TPU beam search was using) or the lower score (what the CPU beam search has been using).

PiperOrigin-RevId: 405278044
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants