• Simon Brandeis's avatar
    Add flags to return scores, hidden states and / or attention weights in GenerationMixin (#9150) · c89f1bc9
    Simon Brandeis authored
    
    
    * Define new output dataclasses for greedy generation
    
    * Add output_[...] flags in greedy generation methods
    
    Added output_attentions, output_hidden_states, output_scores flags in
    generate and greedy_search methods in GenerationMixin.
    
    * [WIP] Implement logic and tests for output flags in generation
    
    * Update GreedySearchOutput classes & docstring
    
    * Implement greedy search output accumulation logic
    
    Update greedy_search unittests
    
    Fix generate method return value docstring
    
    Properly init flags with the default config
    
    * Update configuration to add output_scores flag
    
    * Fix test_generation_utils
    
    Sort imports and fix isinstance tests for GreedySearchOutputs
    
    * Fix typo in generation_utils
    
    * Add return_dict_in_generate for backwards compatibility
    
    * Add return_dict_in_generate flag in config
    
    * Fix tyPo in configuration
    
    * Fix handling of attentions and hidden_states flags
    
    * Make style & quality
    
    * first attempt attentions
    
    * some corrections
    
    * improve tests
    
    * special models requires special test
    
    * disable xlm test for now
    
    * clean tests
    
    * fix for tf
    
    * isort
    
    * Add output dataclasses for other generation methods
    
    * Add logic to return dict in sample generation
    
    * Complete test for sample generation
    
    - Pass output_attentions and output_hidden_states flags to encoder in
    encoder-decoder models
    - Fix import satements order in test_generation_utils file
    
    * Add logic to return dict in sample generation
    
    - Refactor tests to avoid using self.assertTrue, which provides
    scarce information when the test fails
    - Add tests for the three beam_search methods: vanilla, sample and
    grouped
    
    * Style doc
    
    * Fix copy-paste error in generation tests
    
    * Rename logits to scores and refactor
    
    * Refactor group_beam_search for consistency
    
    * make style
    
    * add sequences_scores
    
    * fix all tests
    
    * add docs
    
    * fix beam search finalize test
    
    * correct docstring
    
    * clean some files
    
    * Made suggested changes to the documentation
    
    * Style doc ?
    
    * Style doc using the Python util
    
    * Update src/transformers/generation_utils.py
    
    * fix empty lines
    
    * fix all test
    Co-authored-by: default avatarPatrick von Platen <patrick.v.platen@gmail.com>
    c89f1bc9
test_modeling_xlm.py 17 KB