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
491ec989
Unverified
Commit
491ec989
authored
Jul 04, 2023
by
Hailey Schoelkopf
Committed by
GitHub
Jul 04, 2023
Browse files
Merge pull request #533 from sywangyi/fix_ptun
fix p-tuning inaccuracy, because output logit contains virtual token …
parents
25dfd3f6
318bd988
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
lm_eval/base.py
lm_eval/base.py
+2
-1
No files found.
lm_eval/base.py
View file @
491ec989
...
...
@@ -364,7 +364,7 @@ class BaseLM(LM):
cont_toks_list
.
append
(
cont
)
inplens
.
append
(
inplen
)
batched_inps
=
torch
.
cat
(
inps
,
dim
=
0
)
# [batch, padding_length
batched_inps
=
torch
.
cat
(
inps
,
dim
=
0
)
# [batch, padding_length
]
multi_logits
=
F
.
log_softmax
(
self
.
_model_call
(
batched_inps
),
dim
=-
1
).
cpu
()
# [batch, padding_length, vocab]
...
...
@@ -375,6 +375,7 @@ class BaseLM(LM):
# Slice to original seq length
contlen
=
len
(
cont_toks
)
inplen
=
inplen
+
(
logits
.
shape
[
0
]
-
padding_length
)
# if "virtual tokens" (from prompt tuning) are added, inplen is larger
logits
=
logits
[
inplen
-
contlen
:
inplen
].
unsqueeze
(
0
)
# [1, seq, vocab]
...
...
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