-
Notifications
You must be signed in to change notification settings - Fork 299
Supports extended tasks #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
81618c3
4fafc3c
41496e8
9443aac
0d13b4a
af0a2a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,8 +39,19 @@ | |
# Original follows the original implementation as closely as possible | ||
# Leaderboard are the evaluations we fixed on the open llm leaderboard - you should get similar results | ||
# Community are for community added evaluations | ||
# Extended are for evaluations with custom logic | ||
# Custom is for all the experiments you might want to do! | ||
DEFAULT_SUITES = ["helm", "bigbench", "harness", "leaderboard", "lighteval", "original", "custom", "community"] | ||
DEFAULT_SUITES = [ | ||
"helm", | ||
"bigbench", | ||
"harness", | ||
"leaderboard", | ||
"lighteval", | ||
"original", | ||
"extended", | ||
"custom", | ||
"community", | ||
] | ||
|
||
TRUNCATE_FEW_SHOTS_DEFAULTS = True | ||
|
||
|
@@ -97,14 +108,18 @@ def get_task_class( | |
) | ||
|
||
def get_task_dict( | ||
self, task_name_list: List[str], custom_tasks: Optional[Union[str, ModuleType]] = None | ||
self, | ||
task_name_list: List[str], | ||
custom_tasks: Optional[Union[str, ModuleType]] = None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mhh so we keep both custom and extended ? Or custom here is meant to be community ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. community and custom tasks can be launched here |
||
extended_tasks: str = None, | ||
) -> Dict[str, LightevalTask]: | ||
""" | ||
Get a dictionary of tasks based on the task name list. | ||
|
||
Args: | ||
task_name_list (List[str]): A list of task names. | ||
custom_tasks (Optional[Union[str, ModuleType]]): Path to the custom tasks file or name of a module to import containing custom tasks or the module it-self | ||
extended_tasks (Optional[str]): The path to the extended tasks group of submodules | ||
|
||
Returns: | ||
Dict[str, LightevalTask]: A dictionary containing the tasks. | ||
|
@@ -115,13 +130,20 @@ def get_task_dict( | |
""" | ||
# Import custom tasks provided by the user | ||
custom_tasks_registry = None | ||
custom_tasks_module = None | ||
custom_tasks_module = [] | ||
TASKS_TABLE = [] | ||
if custom_tasks is not None: | ||
custom_tasks_module = create_custom_tasks_module(custom_tasks=custom_tasks) | ||
if custom_tasks_module is not None: | ||
custom_tasks_registry = create_config_tasks( | ||
meta_table=custom_tasks_module.TASKS_TABLE, cache_dir=self.cache_dir | ||
custom_tasks_module.append(create_custom_tasks_module(custom_tasks=custom_tasks)) | ||
if extended_tasks is not None: | ||
hlog_warn( | ||
"You are using extended_tasks. Make sure you installed their dependencies using `pip install -e .[extended_tasks]`." | ||
) | ||
custom_tasks_module.extend(load_extended_tasks_modules(extended_tasks_path=extended_tasks)) | ||
for module in custom_tasks_module: | ||
TASKS_TABLE.extend(module.TASKS_TABLE) | ||
|
||
if len(TASKS_TABLE) > 0: | ||
custom_tasks_registry = create_config_tasks(meta_table=TASKS_TABLE, cache_dir=self.cache_dir) | ||
hlog(custom_tasks_registry) | ||
|
||
# Select relevant tasks given the subset asked for by the user | ||
|
@@ -133,6 +155,16 @@ def get_task_dict( | |
return tasks_dict | ||
|
||
|
||
def load_extended_tasks_modules(extended_tasks_path: str): | ||
all_modules = [] | ||
for folder in os.listdir(extended_tasks_path): | ||
cur_module = create_custom_tasks_module(os.path.join(extended_tasks_path, folder, "main.py")) | ||
hlog(f"Successfully loaded extended task: {folder}.") | ||
all_modules.append(cur_module) | ||
|
||
return all_modules | ||
|
||
|
||
def create_custom_tasks_module(custom_tasks: Union[str, ModuleType]) -> ModuleType: | ||
"""Creates a custom task module to load tasks defined by the user in their own file. | ||
|
||
|
@@ -153,7 +185,7 @@ def create_custom_tasks_module(custom_tasks: Union[str, ModuleType]) -> ModuleTy | |
|
||
|
||
def get_custom_tasks(custom_tasks: Union[str, ModuleType]) -> Tuple[ModuleType, str]: | ||
"""Get custom tasks from the given custom tasks file or module. | ||
"""Get all the custom tasks available from the given custom tasks file or module. | ||
|
||
Args: | ||
custom_tasks (Optional[Union[str, ModuleType]]): Path to the custom tasks file or name of a module to import containing custom tasks or the module it-self | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we keep custom ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Custom is for experiments you might want to do on your side, community for community added tasks imo