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
87dff8b0
Commit
87dff8b0
authored
Jan 06, 2024
by
daniel-furman
Browse files
first stab at wrap_chat_template, print statements in loglikelihood for testing
parent
3e27f9dd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
lm_eval/models/huggingface.py
lm_eval/models/huggingface.py
+7
-7
No files found.
lm_eval/models/huggingface.py
View file @
87dff8b0
...
...
@@ -664,10 +664,13 @@ class HFLM(LM):
return
self
.
tokenizer
.
decode
(
tokens
,
skip_special_tokens
=
True
)
def
tok_wrap_chat_template
(
self
,
requests
:
List
[
Instance
],
system
:
bool
=
False
)
->
List
[
Instance
]:
"""
Utility for adding chat templates via the apply_chat_template() method
"""
new_reqs
=
[]
for
req
in
requests
:
context
,
continuation
=
req
.
args
[
0
].
strip
(),
req
.
args
[
1
].
strip
()
if
system
:
chat
=
[
{
"role"
:
"system"
,
"content"
:
system
},
...
...
@@ -690,7 +693,7 @@ class HFLM(LM):
continuation
=
single_tokenized_conversation
[
rfind_continuation
:]
req
.
args
=
(
context
,
continuation
)
new_reqs
.
append
(
req
)
return
new_reqs
...
...
@@ -774,12 +777,9 @@ class HFLM(LM):
return
context_enc
,
continuation_enc
def
loglikelihood
(
self
,
requests
:
List
[
Instance
])
->
List
[
Tuple
[
float
,
bool
]]:
#print(requests)
print
(
requests
[
0
])
print
(
requests
[
0
].
args
)
print
(
f
"First element before prompt formatting...
\n
{
requests
[
0
].
args
}
"
)
requests
=
self
.
tok_wrap_chat_template
(
requests
)
print
(
requests
[
0
])
print
(
requests
[
0
].
args
)
print
(
f
"First element after prompt formatting...
\n
{
requests
[
0
].
args
}
"
)
new_reqs
=
[]
for
context
,
continuation
in
[
req
.
args
for
req
in
requests
]:
if
context
==
""
:
...
...
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