• Nicolas Patry's avatar
    Fixing the "translation", "translation_XX_to_YY" pipelines. (#7975) · 18ce6b8f
    Nicolas Patry authored
    
    
    * Actually make the "translation", "translation_XX_to_YY" task behave correctly.
    
    Background:
    - Currently "translation_cn_to_ar" does not work. (only 3 pairs are
    supported)
    - Some models, contain in their config the correct values for the (src,
    tgt) pair they can translate. It's usually just one pair, and we can
    infer it automatically from the `model.config.task_specific_params`. If
    it's not defined we can still probably load the TranslationPipeline
    nevertheless.
    
    Proposed fix:
    - A simplified version of what could become more general which is
    a `parametrized` task. "translation" + (src, tgt) in this instance
    it what we need in the general case. The way we go about it for now
    is simply parsing "translation_XX_to_YY". If cases of parametrized task arise
    we should preferably go in something closer to what `datasets` propose
    which is having a secondary argument `task_options`? that will be close
    to what that task requires.
    - Should be backward compatible in all cases for instance
    `pipeline(task="translation_en_to_de") should work out of the box.
    - Should provide a warning when a specific translation pair has been
    selected on behalf of the user using
    `model.config.task_specific_params`.
    
    * Update src/transformers/pipelines.py
    Co-authored-by: default avatarJulien Chaumond <chaumond@gmail.com>
    Co-authored-by: default avatarJulien Chaumond <chaumond@gmail.com>
    18ce6b8f
test_pipelines.py 41 KB