Closed molbap closed 9 months ago
The idea would be to have a cleaner task setup for finetune/eval and refactor the other tasks, eval_ocr
in priority, to be aligned.
@molbap looks like something got fairly hosed in the init of docvqa eval task, bunch of repeated code...
Should be better. Something I added to handle passing args to task_cls init depending on task (some will need checkpoint_path, some resume, etc) is this to get non default arguments, basically passing unpacked non-defaults arguments only to task_cls. Instead of non-default, a better way could be to restrict the argument scope depending on the task_cls but I don't see how to do that without increasing the need for maintenance over all existing tasks, so current solution is
def get_selected_non_default_args(dataclass_instance, arg_names):
"""
Extracts a subset of non-default arguments from a dataclass instance.
This checks a specified list of argument names in a given instance.
It returns a dictionary of arguments that are not set to their default values.
Parameters:
- dataclass_instance: An instance of a dataclass from which to extract arguments.
- arg_names: A list of strings representing the names of the arguments to be considered.
Returns:
- A dictionary containing key-value pairs of argument names and their values,
for those arguments that are not set to their default values.
"""
selected_non_default_args = {}
for field in fields(dataclass_instance.__class__):
if field.name in arg_names:
value = getattr(dataclass_instance, field.name)
default_value = field.default
if field.default_factory != dataclasses.MISSING:
default_value = field.default_factory()
if value != default_value:
selected_non_default_args[field.name] = value
return selected_non_default_args
This makes finetune docVQA and the associated eval task more inline with the recent updates that factored out common task utils. I also added donut-specific preprocessing. This is conditioned on one TODO that are pre-release I would say
create_model
, or directly from the task init. First option would be better.Experiments for finetuning on DocVQA on this can run on
and for eval
Where the checkpoint comes from the finished finetuning experiment.