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
77b44470
Commit
77b44470
authored
Feb 18, 2021
by
Leo Gao
Browse files
Add gpt2/3 tokenizer sanity check
parent
7d5aa3f7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
1 deletion
+11
-1
lm_eval/base.py
lm_eval/base.py
+2
-0
lm_eval/models/gpt2.py
lm_eval/models/gpt2.py
+2
-0
lm_eval/models/gpt3.py
lm_eval/models/gpt3.py
+7
-1
No files found.
lm_eval/base.py
View file @
77b44470
...
...
@@ -305,6 +305,8 @@ class Request:
def
__eq__
(
self
,
other
):
return
self
.
type
==
other
.
type
and
self
.
args
==
other
.
args
and
self
.
index
==
other
.
index
def
__repr__
(
self
):
return
f
"Req_
{
self
.
type
}{
self
.
args
}
[
{
self
.
index
}
]
\n
"
class
RequestFactory
:
def
__getattr__
(
self
,
attr
):
...
...
lm_eval/models/gpt2.py
View file @
77b44470
...
...
@@ -16,6 +16,8 @@ class GPT2LM(LM):
self
.
tokenizer
=
transformers
.
GPT2TokenizerFast
.
from_pretrained
(
pretrained
)
self
.
tokenizer
.
pad_token
=
"<|endoftext|>"
assert
self
.
tokenizer
.
encode
(
'hello
\n\n
hello'
)
==
[
31373
,
198
,
198
,
31373
]
@
classmethod
def
create_from_arg_string
(
cls
,
arg_string
):
args
=
utils
.
simple_parse_args_string
(
arg_string
)
...
...
lm_eval/models/gpt3.py
View file @
77b44470
...
...
@@ -52,8 +52,10 @@ class GPT3LM(LM):
self
.
engine
=
engine
self
.
tokenizer
=
transformers
.
GPT2TokenizerFast
.
from_pretrained
(
'gpt2'
)
# to make the annoying "Using pad_token, but it is not set yet." error go away
self
.
tokenizer
.
pad_token
=
"<|endoftext|>"
assert
self
.
tokenizer
.
encode
(
'hello
\n\n
hello'
)
==
[
31373
,
198
,
198
,
31373
]
self
.
truncate
=
truncate
# Read from environment variable OPENAI_API_SECRET_KEY
...
...
@@ -115,8 +117,12 @@ class GPT3LM(LM):
logprobs
=
10
,
stop
=
until
)
s
=
response
.
choices
[
0
][
'text'
]
for
term
in
until
:
s
=
s
.
split
(
term
)[
0
]
res
.
append
(
response
.
choices
[
0
][
'text'
]
)
res
.
append
(
s
)
return
res
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