-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
[examples/run_s2s] remove task_specific_params and update rouge computation #10133
Conversation
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.
Thanks a lot for fixing the script!
examples/seq2seq/run_seq2seq.py
Outdated
# update config with task specific params | ||
task_specific_params = model.config.task_specific_params | ||
if task_specific_params is not None: | ||
params = task_specific_params.get(data_args.task, {}) | ||
logger.info(f"Updating model.config with task specific params for {data_args.task}:\n {params}") | ||
logger.info("Note: command line args may override some of these.") | ||
model.config.update(params) |
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.
This was the thing @patrickvonplaten told me to remove, so just pinging him here so you two can fight :-)
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.
This is mostly for T5 and for reproducing the metrics. I don't have any strong opinion here. If we decide to remove this, then we should remove all mentions of task_specific_params
from the script and use the prefix
only if the user has specified it.
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.
I don't care if you want to change this, as long as we can accomplish the same in a new way.
I have a bit of a hard time understanding what is the intention behind removing functionality. Is this bad functionality? Is it not useful?
As I mentioned several times in this let's-rewrite-things context, as long as I have a reliable sensitive tool that can help me detect quality regressions over short dataset sample sets I am not attached to any specific way.
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.
Thank you, @patil-suraj for this functionality sync with the old script. That's wonderful!
I see there is a potential conflict with restoring functionality that was purposefully removed. so let's see what @patrickvonplaten says.
Context: Here some context on the
=> So this design was chosen only for the pipelines and essentially only for T5 version 1 since T5 version 1, is the only model we have that needs task-specific params (especially due to the different required prefixes depending on the task). Up until now, there were too many problems with this mechanism IMO so that the benefit of having it is IMO outweighed by its disadvantages, which are: 1) It blows up the config a lot and is not scalable (what do you do with many-to-many translation models? you can have each combination of 2) No one understood anymore what was happening under the hood. IMO, having such a mechanism is a bit too "magical" because it creates a whole other logical layer to the already complicated mechanism that we have for the config params. In short, we currently have the following logic in pipelines: i) The function argument is used (such as => It is obvious that this a very complicated and somewhat "magical" logic and lot of people internally didn't even really understand it. This is why I really would like to remove the second step. It's confusing to see multiple 3) So far 4) It makes the pipelines in general very inflexible. E.g. when importing the pipeline classes directly, say the
task param. But in order to correctly load T5 translation params for TranslationPipeline , you actually manually have to pass task="translation_en_to_de" to the init (also note here that it's not as easy as just saying - let's just add a class attribute self.task = "translation_en_to_de" because the same pipeline is also used for EN->RO translation in which case one could not use the class attribute... => this created a lot of problems leading to @julien-c eventually hard-coding (I think) the correct task name for T5 into the inference API code, which then kind of defeated the purpose of having this mechanism.
Conclusion That being said, I see two solutions in general:
=> This means that I really don't think that should use this param in
Sorry for the long text, but I think this is actually an important mechanism not too many people are aware of and we should think about a more general solution for how to continue with Happy to hear your opinions on what I wrote above :-) |
Thanks a lot for the context @patrickvonplaten Regarding the script, to follow the examples philosophy, let's just remove it completely. If a model requires |
Thank you for the detailed explanation, @patrickvonplaten - that was very awesome of you to write it all out in such clarity. I'm totally fine with your proposal, yet I think it'd be important to document how does one reproduce the same behavior with the new script and new t5 config then. I already started an issue that documents the nuances of porting from Should you decide to remove this mechanism completely, the t5 models on the hub should probably be updated to reflect that at some future point, so that there is no baggage to carry forward. Perhaps in a few release cycles after the cut is done? Surely, users who use older |
To reproduce the same behavior with the new script
Again, this is just for T5, the rest of the models should give similar results. So I'm going to merge this PR and let's update the readme in the clean-up PR #10136. |
What does this PR do?
correctly handle
task_specific_params
andprefix
The current script tries to access the
prefix
fromconfig.task_specific_params.prefix
, which is always going to beNone
astask_specific_params
is a nesteddict
with each key being a task name. This PR retrieves thetask_specific_params
fromconfig
using the task name (data_args.task
), updates theconfig
with the retrieved params (this is needed forT5
), and accessprefix
usingconfig.prefix
@stas00 as you reported offline, the bleu score for the new script was different from the old script for
T5
on theen-ro
task. This was because the old script was using thetask_specific_params
and the new script wasn't. This update should resolve that issue.Update
rouge
score computation.The
rougeLsum
metric expects newlines between each sentence, this is usually the score reported in papers. This PRpreds
andlabels
usingnltk
to correctly computerougeLsum
use_stemmer=True
tometric.compute
to match the metrics with old script.Add
test_file
argument toDataTrainingArguments
to load custom test dataset.