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
e6f2720d
Commit
e6f2720d
authored
Apr 15, 2020
by
Neel Kant
Browse files
Include comprehensive block info when hashing
parent
f3d2426e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
10 deletions
+6
-10
hashed_index.py
hashed_index.py
+5
-9
megatron/data/ict_dataset.py
megatron/data/ict_dataset.py
+1
-1
No files found.
hashed_index.py
View file @
e6f2720d
...
@@ -39,7 +39,7 @@ def main():
...
@@ -39,7 +39,7 @@ def main():
try
:
try
:
input_tokens
,
input_types
,
input_pad_mask
,
\
input_tokens
,
input_types
,
input_pad_mask
,
\
block_tokens
,
block_token_types
,
block_pad_mask
,
block_indices
=
get_batch
(
data_iter
)
block_tokens
,
block_token_types
,
block_pad_mask
,
block_indices
=
get_batch
(
data_iter
)
except
StopIteration
:
except
:
break
break
# TODO: make sure input is still in block
# TODO: make sure input is still in block
...
@@ -49,20 +49,16 @@ def main():
...
@@ -49,20 +49,16 @@ def main():
block_hash_pos
=
torch
.
matmul
(
block_logits
,
hash_matrix
)
block_hash_pos
=
torch
.
matmul
(
block_logits
,
hash_matrix
)
block_hash_full
=
torch
.
cat
((
block_hash_pos
,
-
block_hash_pos
),
axis
=
1
)
block_hash_full
=
torch
.
cat
((
block_hash_pos
,
-
block_hash_pos
),
axis
=
1
)
block_hashes
=
torch
.
argmax
(
block_hash_full
,
axis
=
1
).
detach
().
cpu
().
numpy
()
block_hashes
=
torch
.
argmax
(
block_hash_full
,
axis
=
1
).
detach
().
cpu
().
numpy
()
for
hash
,
i
dx
in
zip
(
block_hashes
,
block_indices
):
for
hash
,
i
ndices_array
in
zip
(
block_hashes
,
block_indices
):
hash_data
[
int
(
hash
)].
append
(
in
t
(
idx
)
)
hash_data
[
int
(
hash
)].
append
(
in
dicecs_array
)
all_input_tokens
.
append
(
input_tokens
.
detach
().
cpu
().
numpy
())
all_input_tokens
.
append
(
input_tokens
.
detach
().
cpu
().
numpy
())
all_input_logits
.
append
(
input_logits
.
detach
().
cpu
().
numpy
())
all_input_logits
.
append
(
input_logits
.
detach
().
cpu
().
numpy
())
all_block_tokens
.
append
(
block_tokens
.
detach
().
cpu
().
numpy
())
all_block_tokens
.
append
(
block_tokens
.
detach
().
cpu
().
numpy
())
all_block_logits
.
append
(
block_logits
.
detach
().
cpu
().
numpy
())
all_block_logits
.
append
(
block_logits
.
detach
().
cpu
().
numpy
())
if
i
%
10
==
0
:
if
i
==
1000
:
print
(
i
,
flush
=
True
)
print
(
i
)
print
(
block_tokens
[
0
])
if
i
==
100
:
break
i
+=
1
i
+=
1
...
...
megatron/data/ict_dataset.py
View file @
e6f2720d
...
@@ -79,7 +79,7 @@ class InverseClozeDataset(Dataset):
...
@@ -79,7 +79,7 @@ class InverseClozeDataset(Dataset):
'context_text'
:
np
.
array
(
context_tokens
),
'context_text'
:
np
.
array
(
context_tokens
),
'context_types'
:
np
.
array
(
context_token_types
),
'context_types'
:
np
.
array
(
context_token_types
),
'context_pad_mask'
:
np
.
array
(
context_pad_mask
),
'context_pad_mask'
:
np
.
array
(
context_pad_mask
),
'context_indices'
:
np
.
array
([
block_idx
]).
astype
(
np
.
int64
)
'context_indices'
:
np
.
array
([
start_idx
,
end_idx
,
doc_idx
,
block_idx
]).
astype
(
np
.
int64
)
}
}
return
sample
return
sample
...
...
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