-
Notifications
You must be signed in to change notification settings - Fork 538
Conversation
Job PR-272/3 is complete. |
Codecov Report
@@ Coverage Diff @@
## master #272 +/- ##
=========================================
+ Coverage 76.66% 76.7% +0.03%
=========================================
Files 74 74
Lines 6429 6443 +14
Branches 1004 1008 +4
=========================================
+ Hits 4929 4942 +13
+ Misses 1266 1264 -2
- Partials 234 237 +3
Continue to review full report at Codecov.
|
gluonnlp/model/sequence_sampler.py
Outdated
chosen_word_ids = F.sample_multinomial(smoothed_probs).astype('float32') | ||
chosen_word_log_probs = log_probs[mx.nd.arange(log_probs.shape[0]), | ||
chosen_word_ids.reshape(-1)] \ | ||
.reshape_like(chosen_word_ids) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd better use int32 for indexing. Float32 may overflow if there are a large number of words.
new_valid_length = valid_length + beam_alive_mask | ||
|
||
# Update the samples and vaild_length | ||
new_samples = F.concat(samples, chosen_word_ids.expand_dims(2), dim=2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can append -1
instead of the chosen words if the beam is not alive.
Job PR-272/4 is complete. |
Job PR-272/5 is complete. |
Job PR-272/6 is complete. |
Job PR-272/7 is complete. |
Job PR-272/8 is complete. |
Job PR-272/9 is complete. |
Job PR-272/10 is complete. |
* beam search sampling * refactor * move tests * update readme * use int32 * append -1 for dead beams * add sampling test
Description
sampling feature for beam search.
Checklist
Essentials
Changes