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
gaoqiong
lm-evaluation-harness
Commits
b569f483
Commit
b569f483
authored
Sep 29, 2021
by
Leo Gao
Browse files
add support for HF revision
parent
3b81a361
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
lm_eval/models/gpt2.py
lm_eval/models/gpt2.py
+2
-2
No files found.
lm_eval/models/gpt2.py
View file @
b569f483
...
...
@@ -13,7 +13,7 @@ class GPT2LM(LM):
VOCAB_SIZE
=
50257
EOT_TOKEN_ID
=
50256
def
__init__
(
self
,
device
=
'cuda'
,
pretrained
=
'gpt2'
,
batch_size
=
1
):
def
__init__
(
self
,
device
=
'cuda'
,
pretrained
=
'gpt2'
,
revision
=
"main"
,
batch_size
=
1
):
super
().
__init__
()
assert
isinstance
(
device
,
str
)
...
...
@@ -24,7 +24,7 @@ class GPT2LM(LM):
self
.
device
=
torch
.
device
(
device
)
else
:
self
.
device
=
torch
.
device
(
'cuda'
)
if
torch
.
cuda
.
is_available
()
else
torch
.
device
(
'cpu'
)
self
.
gpt2
=
transformers
.
AutoModelForCausalLM
.
from_pretrained
(
pretrained
).
to
(
self
.
device
)
self
.
gpt2
=
transformers
.
AutoModelForCausalLM
.
from_pretrained
(
pretrained
,
revision
=
revision
).
to
(
self
.
device
)
self
.
gpt2
.
eval
()
# pretrained tokenizer for neo is broken for now so just hardcoding this to gpt2
...
...
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