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
chenpangpang
transformers
Commits
3aca02ef
Unverified
Commit
3aca02ef
authored
Mar 09, 2020
by
Sam Shleifer
Committed by
GitHub
Mar 09, 2020
Browse files
Bart example: model.to(device) (#3194)
parent
5164ea91
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
examples/summarization/bart/evaluate_cnn.py
examples/summarization/bart/evaluate_cnn.py
+1
-1
No files found.
examples/summarization/bart/evaluate_cnn.py
View file @
3aca02ef
...
...
@@ -18,7 +18,7 @@ def chunks(lst, n):
def
generate_summaries
(
lns
,
out_file
,
batch_size
=
8
,
device
=
DEFAULT_DEVICE
):
fout
=
Path
(
out_file
).
open
(
"w"
)
model
=
BartForConditionalGeneration
.
from_pretrained
(
"bart-large-cnn"
,
output_past
=
True
,)
model
=
BartForConditionalGeneration
.
from_pretrained
(
"bart-large-cnn"
,
output_past
=
True
,)
.
to
(
device
)
tokenizer
=
BartTokenizer
.
from_pretrained
(
"bart-large"
)
for
batch
in
tqdm
(
list
(
chunks
(
lns
,
batch_size
))):
dct
=
tokenizer
.
batch_encode_plus
(
batch
,
max_length
=
1024
,
return_tensors
=
"pt"
,
pad_to_max_length
=
True
)
...
...
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