Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Megatron-LM
Commits
41df5ff7
Commit
41df5ff7
authored
Aug 08, 2021
by
rprenger
Browse files
Fixing bug where the wrong token was used to index the log probabilities
parent
e0bf5199
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
megatron/text_generation_utils.py
megatron/text_generation_utils.py
+2
-2
No files found.
megatron/text_generation_utils.py
View file @
41df5ff7
...
@@ -270,7 +270,7 @@ def sample_sequence_batch(model, context_tokens, context_lengths,
...
@@ -270,7 +270,7 @@ def sample_sequence_batch(model, context_tokens, context_lengths,
lengths
=
torch
.
ones
([
batch_size
]).
long
().
cuda
()
*
maxlen
lengths
=
torch
.
ones
([
batch_size
]).
long
().
cuda
()
*
maxlen
while
context_length
<
=
(
maxlen
)
:
while
context_length
<
maxlen
:
types2use
=
None
types2use
=
None
if
counter
==
0
:
if
counter
==
0
:
tokens2use
=
tokens
[:,
:
context_length
]
tokens2use
=
tokens
[:,
:
context_length
]
...
@@ -316,7 +316,7 @@ def sample_sequence_batch(model, context_tokens, context_lengths,
...
@@ -316,7 +316,7 @@ def sample_sequence_batch(model, context_tokens, context_lengths,
if
output_logits
is
None
:
if
output_logits
is
None
:
output_context
=
F
.
log_softmax
(
output
[:,
:
context_length
,
:],
2
)
output_context
=
F
.
log_softmax
(
output
[:,
:
context_length
,
:],
2
)
indices
=
torch
.
unsqueeze
(
tokens
[:,
:
context_length
],
2
)
indices
=
torch
.
unsqueeze
(
tokens
[:,
1
:
context_length
+
1
],
2
)
output_logits
=
torch
.
gather
(
output_context
,
2
,
indices
).
squeeze
(
2
)
output_logits
=
torch
.
gather
(
output_context
,
2
,
indices
).
squeeze
(
2
)
else
:
else
:
indices
=
torch
.
unsqueeze
(
new_tokens
,
1
).
unsqueeze
(
2
)
indices
=
torch
.
unsqueeze
(
new_tokens
,
1
).
unsqueeze
(
2
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment