Skip to content

TF: clearer model variable naming #16051

@gante

Description

@gante

This issue is part of our Great Code Cleanup 2022. If you're interested in helping out, take a look at this thread, or come join us on Discord and talk with other contributors!

As introduced in #15908 and implemented in #15907, we now have a new @unpack_inputs decorator to unpack TensorFlow model call() arguments. In essence, if we apply the decorator, we can replace inputs["foo"] with foo, making the code for the layer/model much shorter and clearer.

This issue is a call for contributors, to implement the new decorator in the architectures below. If you wish to contribute, reply in this thread which architectures you'd like to take :)

Guide to contributing:

  1. Ensure you've read our contributing guidelines 📜
  2. Claim your architecture(s) in this thread (confirm no one is working on it) 🎯
  3. Implement the changes as in TF: Unpack model inputs through a decorator  #15907 (see the diff on the model architectures for a few examples) 💪
    • The file you want to look at is in src/transformers/models/[model_name]/modeling_tf_[model_name].py
    • In functions that have an input_processing call, remove it and add the @unpack_inputs decorator
    • Replace any use of the inputs variable in those functions (e.g. inputs["foo"] -> foo)
  4. Test your changes on the architecture with RUN_SLOW=1 py.test -vv tests/[model_name]/test_modeling_tf_[model_name].py 💻
  5. Open the PR and tag me in it (don't forget to run make fixup before your final commit) 🎊
    • Note that some code is copied across our codebase. If you see a line like # Copied from transformers.models.bert..., this means that the code is copied from that source, and our scripts will automatically keep that in sync. If you see that, you should not edit the copied method! Instead, edit the original method it's copied from, and run make fixup to synchronize that across all the copies. Be sure you installed the development dependencies with pip install -e ".[dev]", as described in the contributor guidelines above, to ensure that the code quality tools in make fixup can run.

Models updated:

  • (the templates)
  • albert
  • auto
  • bart
  • bert
  • blenderbot
  • blenderbot_small
  • camembert
  • clip
  • convbert
  • convnext
  • ctrl
  • deberta
  • deberta_v2
  • distilbert
  • dpr
  • electra
  • encoder_decoder
  • flaubert
  • funnel
  • gpt2
  • hubert
  • layoutlm
  • led
  • longformer
  • lxmert
  • marian
  • mbart
  • mobilebert
  • mpnet
  • mt5
  • openai
  • pegasus
  • rag
  • rembert
  • roberta
  • roformer
  • speech_to_text
  • t5
  • tapas
  • transfo_xl
  • vision_encoder_decoder
  • vit
  • wave2vec2 👉 lgnore this one for now, looking into the issue @infinite-Joy raised
  • xlm
  • xlm_roberta
  • xlnet

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions