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
c55e8237
Commit
c55e8237
authored
Feb 04, 2021
by
Leo Gao
Browse files
Get rid of annoying logging
parent
d5cd9655
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
2 deletions
+9
-2
lm_eval/models/gpt2.py
lm_eval/models/gpt2.py
+1
-0
lm_eval/models/gpt3.py
lm_eval/models/gpt3.py
+6
-2
main.py
main.py
+2
-0
No files found.
lm_eval/models/gpt2.py
View file @
c55e8237
...
...
@@ -12,6 +12,7 @@ class GPT2LM(LM):
self
.
gpt2
=
transformers
.
GPT2LMHeadModel
.
from_pretrained
(
'gpt2'
).
to
(
self
.
device
)
self
.
gpt2
.
eval
()
self
.
tokenizer
=
transformers
.
GPT2TokenizerFast
.
from_pretrained
(
'gpt2'
)
self
.
tokenizer
.
pad_token
=
"<|endoftext|>"
@
classmethod
def
create_from_arg_string
(
cls
,
arg_string
):
...
...
lm_eval/models/gpt3.py
View file @
c55e8237
...
...
@@ -38,6 +38,9 @@ class GPT3LM(LM):
import
openai
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|>"
self
.
truncate
=
truncate
# Read from environment variable OPENAI_API_SECRET_KEY
...
...
@@ -50,11 +53,12 @@ class GPT3LM(LM):
def
loglikelihood
(
self
,
requests
):
import
openai
for
chunk
in
tqdm
(
utils
.
chunks
(
requests
,
self
.
REQ_CHUNK_SIZE
)):
res
=
[]
for
chunk
in
tqdm
(
list
(
utils
.
chunks
(
requests
,
self
.
REQ_CHUNK_SIZE
))):
inps
=
[]
ctxlens
=
[]
for
context
,
continuation
in
chunk
:
print
(
context
)
context_enc
=
self
.
tokenizer
.
encode
(
context
)
continuation_enc
=
self
.
tokenizer
.
encode
(
continuation
)
inp
=
(
context_enc
+
continuation_enc
)[
-
self
.
MAX_LENGTH
:]
...
...
main.py
View file @
c55e8237
...
...
@@ -4,9 +4,11 @@ import numpy as np
import
random
import
itertools
import
collections
import
logging
from
lm_eval
import
models
,
tasks
,
evaluator
,
base
logging
.
getLogger
(
"openai"
).
setLevel
(
logging
.
WARNING
)
def
parse_args
():
parser
=
argparse
.
ArgumentParser
()
...
...
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