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
9d975e23
Unverified
Commit
9d975e23
authored
Dec 24, 2020
by
Stella Biderman
Committed by
GitHub
Dec 24, 2020
Browse files
Merge pull request #67 from EleutherAI/uyhcire-new-harness-2
Tweak StoryCloze script to be agnostic to tokenization
parents
e4af3e77
6b453bfd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
14 deletions
+1
-14
batch_eval/main.py
batch_eval/main.py
+1
-14
No files found.
batch_eval/main.py
View file @
9d975e23
...
@@ -89,11 +89,6 @@ def evaluate_example(model, tokenizer, example):
...
@@ -89,11 +89,6 @@ def evaluate_example(model, tokenizer, example):
def
compute_per_token_logit_for_completion
(
model
,
tokenizer
,
prompt
,
completion
):
def
compute_per_token_logit_for_completion
(
model
,
tokenizer
,
prompt
,
completion
):
prompt_token_count
=
(
tokenizer
.
encode
(
prompt
,
add_special_tokens
=
False
,
return_tensors
=
"pt"
)
.
to
(
"cuda"
)
.
shape
[
1
]
)
encoded_prompt_with_completion
=
tokenizer
.
encode
(
encoded_prompt_with_completion
=
tokenizer
.
encode
(
prompt
+
" "
+
completion
,
prompt
+
" "
+
completion
,
add_special_tokens
=
False
,
add_special_tokens
=
False
,
...
@@ -114,15 +109,7 @@ def compute_per_token_logit_for_completion(model, tokenizer, prompt, completion)
...
@@ -114,15 +109,7 @@ def compute_per_token_logit_for_completion(model, tokenizer, prompt, completion)
input_tokens_at_positions_with_logits
.
unsqueeze
(
1
),
input_tokens_at_positions_with_logits
.
unsqueeze
(
1
),
).
squeeze
(
1
)
).
squeeze
(
1
)
return
(
return
logits_for_provided_tokens
.
mean
().
item
()
logits_for_provided_tokens
[
prompt_token_count
# Again, the model does not predict the first input token, so we need
-
1
:
]
.
mean
()
.
item
()
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
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