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
57b20eef
Unverified
Commit
57b20eef
authored
Sep 14, 2023
by
Hailey Schoelkopf
Committed by
GitHub
Sep 14, 2023
Browse files
Merge pull request #857 from chrisociepa/python_3_8_compatible
Use Dict to make the code python 3.8 compatible
parents
5d4ac134
38c9689a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
6 deletions
+7
-6
lm_eval/prompts/__init__.py
lm_eval/prompts/__init__.py
+2
-1
lm_eval/tasks/__init__.py
lm_eval/tasks/__init__.py
+5
-5
No files found.
lm_eval/prompts/__init__.py
View file @
57b20eef
import
ast
import
ast
from
typing
import
Dict
from
lm_eval
import
utils
from
lm_eval
import
utils
from
lm_eval.logger
import
eval_logger
from
lm_eval.logger
import
eval_logger
...
@@ -7,7 +8,7 @@ from lm_eval.logger import eval_logger
...
@@ -7,7 +8,7 @@ from lm_eval.logger import eval_logger
# Stores prompts in a dictionary indexed by 2 levels:
# Stores prompts in a dictionary indexed by 2 levels:
# prompt category name, and prompt name.
# prompt category name, and prompt name.
# This allows us to access prompts
# This allows us to access prompts
PROMPT_REGISTRY
:
d
ict
[
str
,
d
ict
[
str
,
str
]]
=
{
PROMPT_REGISTRY
:
D
ict
[
str
,
D
ict
[
str
,
str
]]
=
{
"qa-basic"
:
{
"qa-basic"
:
{
"question-newline-answer"
:
"Question: {{question}}
\n
Answer:"
,
"question-newline-answer"
:
"Question: {{question}}
\n
Answer:"
,
"q-newline-a"
:
"Q: {{question}}
\n
A:"
,
"q-newline-a"
:
"Q: {{question}}
\n
A:"
,
...
...
lm_eval/tasks/__init__.py
View file @
57b20eef
import
os
import
os
import
yaml
import
yaml
from
typing
import
List
,
Union
from
typing
import
List
,
Union
,
Dict
from
lm_eval
import
utils
from
lm_eval
import
utils
from
lm_eval
import
prompts
from
lm_eval
import
prompts
...
@@ -15,7 +15,7 @@ from lm_eval.api.registry import (
...
@@ -15,7 +15,7 @@ from lm_eval.api.registry import (
)
)
def
register_configurable_task
(
config
:
d
ict
[
str
,
str
])
->
int
:
def
register_configurable_task
(
config
:
D
ict
[
str
,
str
])
->
int
:
SubClass
=
type
(
SubClass
=
type
(
config
[
"task"
]
+
"ConfigurableTask"
,
config
[
"task"
]
+
"ConfigurableTask"
,
(
ConfigurableTask
,),
(
ConfigurableTask
,),
...
@@ -38,7 +38,7 @@ def register_configurable_task(config: dict[str, str]) -> int:
...
@@ -38,7 +38,7 @@ def register_configurable_task(config: dict[str, str]) -> int:
return
0
return
0
def
check_prompt_config
(
config
:
d
ict
[
str
,
str
])
->
List
[
d
ict
[
str
,
str
]]:
def
check_prompt_config
(
config
:
D
ict
[
str
,
str
])
->
List
[
D
ict
[
str
,
str
]]:
all_configs
=
[]
all_configs
=
[]
if
"use_prompt"
in
config
:
if
"use_prompt"
in
config
:
prompt_list
=
prompts
.
load_prompt_list
(
prompt_list
=
prompts
.
load_prompt_list
(
...
@@ -69,7 +69,7 @@ def check_prompt_config(config: dict[str, str]) -> List[dict[str, str]]:
...
@@ -69,7 +69,7 @@ def check_prompt_config(config: dict[str, str]) -> List[dict[str, str]]:
return
all_configs
return
all_configs
def
get_task_name_from_config
(
task_config
:
d
ict
[
str
,
str
])
->
str
:
def
get_task_name_from_config
(
task_config
:
D
ict
[
str
,
str
])
->
str
:
if
"dataset_name"
in
task_config
:
if
"dataset_name"
in
task_config
:
return
"{dataset_path}_{dataset_name}"
.
format
(
**
task_config
)
return
"{dataset_path}_{dataset_name}"
.
format
(
**
task_config
)
else
:
else
:
...
@@ -128,7 +128,7 @@ def get_task_name_from_object(task_object):
...
@@ -128,7 +128,7 @@ def get_task_name_from_object(task_object):
# TODO: pass num_fewshot and other cmdline overrides in a better way
# TODO: pass num_fewshot and other cmdline overrides in a better way
def
get_task_dict
(
task_name_list
:
List
[
Union
[
str
,
d
ict
,
Task
]],
**
kwargs
):
def
get_task_dict
(
task_name_list
:
List
[
Union
[
str
,
D
ict
,
Task
]],
**
kwargs
):
config
=
{
**
kwargs
}
config
=
{
**
kwargs
}
...
...
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