Skip to content

Conversation

hynky1999
Copy link
Collaborator

@hynky1999 hynky1999 commented Sep 6, 2024

This is PR, which will bring easier way to task prompts, which are language-aware.

Following templates are create

  • multichoice
  • nli
  • copa
  • continuation

@hynky1999 hynky1999 marked this pull request as draft September 6, 2024 12:39
Copy link
Member

@clefourrier clefourrier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The templates folder mixes up a lot of items of different logic level, we'll have to disuss the structure IRL.
Do we really need "NLITaskConfig, CopaTaskConfig, BoolQATaskConfig", etc? I think it would be better to aim for a general structure instead of having lots of small ones

@hynky1999 hynky1999 changed the base branch from main to geneartive_dynamic_metrics September 23, 2024 18:05
@hynky1999
Copy link
Collaborator Author

The templates folder mixes up a lot of items of different logic level, we'll have to disuss the structure IRL. Do we really need "NLITaskConfig, CopaTaskConfig, BoolQATaskConfig", etc? I think it would be better to aim for a general structure instead of having lots of small ones

I did remove the BoolQATask, for the rest I think they have their place as they have some logic in them.
If you would be super strict only the continuation and multichoice would make the cut. The thing is I will need to for the multilang tasks, so I will create it one way or another. If you insist on greater seperation we can have general/task templates.

Secondly I decided that I won't create a question-answer template as one can just use multichoice with cf to achieve just that

@hynky1999 hynky1999 marked this pull request as ready for review September 23, 2024 23:23
Copy link
Member

@clefourrier clefourrier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!
Some comments:

  • avoid too many layers of nested function: in continuation, you nest 3 functions in one other function over about 100 lines of code, it's not super clear
  • in general, you also need to be careful to not change the naming conventions of the lib (for example, we use choices and you used options), it would be best if you could rename to fit our naming convention.
  • other comments are mostly nits/need for doc/comment suggestions/...

instruction: NotRequired[str]


# Python too dumb to do fancy inference :(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove or convert to actionable todo

translation_literals = TRANSLATION_LITERALS[language]
adapter_fn = create_adapter_from_dict(adapter) if isinstance(adapter, dict) else adapter # type: ignore

def nli_natural_prompt(line: dict, task_name: str):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add docstring explaining the diff between the 2 prompt functions

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be clear from the format. The second function uses the natural function for CF formulation

elif label == "contradiction":
return translation_literals.no
elif label == "neutral":
return translation_literals.also
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else raise error?

Copy link
Collaborator Author

@hynky1999 hynky1999 Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That can't happen as long as you are respecting the typing, you don't that's on you

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not underestimate the creativity of some users ^^ and add an error message - but program will fail later anyway so up to you

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it's like calling load_datset(False), it's undefine behaviour, so it's user's problem.

from lighteval.utils.utils import as_list


CONTINUATION_QUERY_CF = "{instruction}{context}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to explain a bit what the diff is between continuation and multichoice

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did so in the function docstring

Copy link
Member

@clefourrier clefourrier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, super nice, thanks for the changes

@hynky1999 hynky1999 changed the base branch from geneartive_dynamic_metrics to main September 27, 2024 15:22
@hynky1999 hynky1999 changed the base branch from main to geneartive_dynamic_metrics September 27, 2024 15:23
@hynky1999 hynky1999 merged commit b014b50 into geneartive_dynamic_metrics Sep 27, 2024
hynky1999 added a commit that referenced this pull request Sep 27, 2024
@hynky1999 hynky1999 mentioned this pull request Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants