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
06a04113
Commit
06a04113
authored
Feb 05, 2025
by
Baber
Browse files
send messages
parent
52c96866
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
lm_eval/filters/judge.py
lm_eval/filters/judge.py
+9
-3
lm_eval/models/api_models.py
lm_eval/models/api_models.py
+6
-1
No files found.
lm_eval/filters/judge.py
View file @
06a04113
...
...
@@ -69,11 +69,17 @@ class JudgeFilter(Filter):
base_url
=
url
,
pretrained
=
model
,
num_concurrent
=
2
,
**
kwargs
)
@
staticmethod
def
create_message
(
str
)
->
list
[
dict
]:
return
[{
"role"
:
"user"
,
"content"
:
str
}]
def
apply
(
self
,
resps
:
list
[
list
[
str
]],
docs
:
list
[
dict
])
->
list
[
list
[
str
]]:
inputs
=
[
self
.
PROMPT
+
"
\n\n
"
+
f
"Question:
{
doc
[
'question'
]
}
\n
Answer:
{
resp
}
\n
Ground Truth:
{
doc
[
'answer'
]
}
"
self
.
create_message
(
self
.
PROMPT
+
"
\n\n
"
+
f
"Question:
{
doc
[
'question'
]
}
\n
Answer:
{
resp
}
\n
Ground Truth:
{
doc
[
'answer'
]
}
"
)
for
resp
,
doc
in
zip
(
resps
,
docs
)
]
...
...
lm_eval/models/api_models.py
View file @
06a04113
...
...
@@ -200,6 +200,9 @@ class TemplateAPI(TemplateLM):
)
# list[dict["role":..., "content":...],...]
return
json
.
loads
(
messages
[
0
].
prompt
)
elif
isinstance
(
messages
[
0
],
dict
):
# list[dict["role":..., "content":...],...]
return
messages
if
not
self
.
tokenized_requests
:
# if messages are tokenized:
...
...
@@ -721,7 +724,9 @@ class TemplateAPI(TemplateLM):
return
loglikelihoods
def
simple_async_generate
(
self
,
requests
:
Union
[
List
[
List
[
str
]],
List
[
List
[
dict
]]],
gen_kwargs
:
dict
self
,
requests
:
Union
[
List
[
List
[
str
],
list
[
list
[
dict
]]],
List
[
List
[
dict
]]],
gen_kwargs
:
dict
,
):
results
=
itertools
.
chain
.
from_iterable
(
asyncio
.
run
(
...
...
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