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
9118d998
Commit
9118d998
authored
Jun 27, 2024
by
Nathan Habib
Browse files
checkout from main
parent
d26aeda7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
8 deletions
+29
-8
lm_eval/tasks/__init__.py
lm_eval/tasks/__init__.py
+29
-8
No files found.
lm_eval/tasks/__init__.py
View file @
9118d998
...
@@ -14,27 +14,43 @@ class TaskManager:
...
@@ -14,27 +14,43 @@ class TaskManager:
"""
"""
def
__init__
(
self
,
verbosity
=
"INFO"
,
include_path
:
Optional
[
str
]
=
None
)
->
None
:
def
__init__
(
self
,
verbosity
=
"INFO"
,
include_path
:
Optional
[
Union
[
str
,
List
]]
=
None
,
include_defaults
:
bool
=
True
,
)
->
None
:
self
.
verbosity
=
verbosity
self
.
verbosity
=
verbosity
self
.
include_path
=
include_path
self
.
include_path
=
include_path
self
.
logger
=
utils
.
eval_logger
self
.
logger
=
utils
.
eval_logger
self
.
logger
.
setLevel
(
getattr
(
logging
,
f
"
{
verbosity
}
"
))
self
.
logger
.
setLevel
(
getattr
(
logging
,
f
"
{
verbosity
}
"
))
self
.
_task_index
=
self
.
initialize_tasks
(
include_path
=
include_path
)
self
.
_task_index
=
self
.
initialize_tasks
(
include_path
=
include_path
,
include_defaults
=
include_defaults
)
self
.
_all_tasks
=
sorted
(
list
(
self
.
_task_index
.
keys
()))
self
.
_all_tasks
=
sorted
(
list
(
self
.
_task_index
.
keys
()))
self
.
task_group_map
=
collections
.
defaultdict
(
list
)
self
.
task_group_map
=
collections
.
defaultdict
(
list
)
def
initialize_tasks
(
self
,
include_path
:
Optional
[
str
]
=
None
):
def
initialize_tasks
(
self
,
include_path
:
Optional
[
Union
[
str
,
List
]]
=
None
,
include_defaults
:
bool
=
True
,
):
"""Creates a dictionary of tasks index.
"""Creates a dictionary of tasks index.
:param include_path: str = None
:param include_path: Union[str, List] = None
An additional path to be searched for tasks
An additional path to be searched for tasks recursively.
Can provide more than one such path as a list.
:param include_defaults: bool = True
If set to false, default tasks (those in lm_eval/tasks/) are not indexed.
:return
:return
Dictionary of task names as key and task metadata
Dictionary of task names as key and task metadata
"""
"""
all_paths
=
[
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
+
"/"
]
if
include_defaults
:
all_paths
=
[
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
+
"/"
]
else
:
all_paths
=
[]
if
include_path
is
not
None
:
if
include_path
is
not
None
:
if
isinstance
(
include_path
,
str
):
if
isinstance
(
include_path
,
str
):
include_path
=
[
include_path
]
include_path
=
[
include_path
]
...
@@ -296,8 +312,13 @@ class TaskManager:
...
@@ -296,8 +312,13 @@ class TaskManager:
:return
:return
Dictionary of task names as key and task metadata
Dictionary of task names as key and task metadata
"""
"""
ignore_dirs
=
[
"__pycache__"
,
".ipynb_checkpoints"
,
]
tasks_and_groups
=
collections
.
defaultdict
()
tasks_and_groups
=
collections
.
defaultdict
()
for
root
,
_
,
file_list
in
os
.
walk
(
task_dir
):
for
root
,
dirs
,
file_list
in
os
.
walk
(
task_dir
):
dirs
[:]
=
[
d
for
d
in
dirs
if
d
not
in
ignore_dirs
]
for
f
in
file_list
:
for
f
in
file_list
:
if
f
.
endswith
(
".yaml"
):
if
f
.
endswith
(
".yaml"
):
yaml_path
=
os
.
path
.
join
(
root
,
f
)
yaml_path
=
os
.
path
.
join
(
root
,
f
)
...
...
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