Skip to content
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

[Community Event] Doc Tests Sprint #16292

Open
35 of 192 tasks
patrickvonplaten opened this issue Mar 21, 2022 · 77 comments
Open
35 of 192 tasks

[Community Event] Doc Tests Sprint #16292

patrickvonplaten opened this issue Mar 21, 2022 · 77 comments

Comments

@patrickvonplaten
Copy link
Member

@patrickvonplaten patrickvonplaten commented Mar 21, 2022

This issue is part of our Doc Test Sprint. If you're interested in helping out come join us on Discord and talk with other contributors!

Docstring examples are often the first point of contact when trying out a new library! So far we haven't done a very good job at ensuring that all docstring examples work correctly in 🤗 Transformers - but we're now very dedicated to ensure that all documentation examples work correctly by testing each documentation example via Python's doctest (https://docs.python.org/3/library/doctest.html) on a daily basis.

In short we should do the following for all models for both PyTorch and Tensorflow:

    • Check the current doc examples will run without failure
    • Add an expected output to the doc example and test it via Python's doc test (see Guide to contributing below)

Adding a documentation test for a model is a great way to better understand how the model works, a simple (possibly first) contribution to Transformers and most importantly a very important contribution to the Transformers community 🔥

If you're interested in adding a documentation test, please read through the Guide to contributing below.

This issue is a call for contributors, to make sure docstring exmaples of existing model architectures work correctly. 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 #15987 (see the diff on the model architectures for a few examples) 💪

    In addition, there are a few things we can also improve, for example :

    • Fix some style issues: for example, change ``decoder_input_ids``` to `decoder_input_ids`.
    • Using a small model checkpoint instead of a large one: for example, change "facebook/bart-large" to "facebook/bart-base" (and adjust the expected outputs if any)
  4. Open the PR and tag me @patrickvonplaten @ydshieh or @patil-suraj (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.

PyTorch Model Examples added to tests:

Tensorflow Model Examples added to tests:

  • ALBERT (@vumichien)
  • BART
  • BEiT
  • BERT (@vumichien)
  • Bert
  • BigBird (@vumichien)
  • BigBirdPegasus
  • Blenderbot
  • BlenderbotSmall
  • CamemBERT
  • Canine
  • CLIP (@Aanisha)
  • ConvBERT (@simonzli)
  • ConvNext
  • CTRL
  • Data2VecAudio
  • Data2VecText
  • DeBERTa
  • DeBERTa-v2
  • DeiT
  • DETR
  • DistilBERT (@jmwoloso)
  • DPR
  • ELECTRA (@bhadreshpsavani)
  • Encoder
  • FairSeq
  • FlauBERT
  • FNet
  • Funnel
  • GPT2 (@cakiki)
  • GPT-J (@cakiki)
  • Hubert
  • I-BERT
  • ImageGPT
  • LayoutLM
  • LayoutLMv2
  • LED
  • Longformer (@KMFODA)
  • LUKE
  • LXMERT
  • M2M100
  • Marian
  • MaskFormer (@reichenbch)
  • mBART
  • MegatronBert
  • MobileBERT (@vumichien)
  • MPNet
  • mT5
  • Nystromformer
  • OpenAI
  • OpenAI
  • Pegasus
  • Perceiver
  • PLBart
  • PoolFormer
  • ProphetNet
  • QDQBert
  • RAG
  • Realm
  • Reformer
  • ResNet
  • RemBERT
  • RetriBERT
  • RoBERTa (@patrickvonplaten)
  • RoFormer
  • SegFormer
  • SEW
  • SEW-D
  • SpeechEncoderDecoder
  • Speech2Text
  • Speech2Text2
  • Splinter
  • SqueezeBERT
  • Swin (@johko)
  • T5 (@MarkusSagen)
  • TAPAS
  • Transformer-XL (@simonzli)
  • TrOCR (@arnaudstiegler)
  • UniSpeech
  • UniSpeechSat
  • Van
  • ViLT
  • VisionEncoderDecoder
  • VisionTextDualEncoder
  • VisualBert
  • ViT (@johko)
  • ViTMAE
  • Wav2Vec2
  • WavLM
  • XGLM
  • XLM
  • XLM-RoBERTa (@AbinayaM02)
  • XLM-RoBERTa-XL
  • XLMProphetNet
  • XLNet
  • YOSO
@patrickvonplaten patrickvonplaten changed the title Doc tests sprint [Community Event] Doc Tests Sprint Mar 21, 2022
@patrickvonplaten patrickvonplaten pinned this issue Mar 21, 2022
@reichenbch
Copy link
Contributor

@reichenbch reichenbch commented Mar 21, 2022

@patrickvonplaten I would like to start with Maskformer for Tensorflow/Pytorch. Catch up with how the event goes.

@patrickvonplaten
Copy link
Member Author

@patrickvonplaten patrickvonplaten commented Mar 21, 2022

Awesome! Let me know if you have any questions :-)

@KMFODA
Copy link
Contributor

@KMFODA KMFODA commented Mar 21, 2022

Hello! I'd like to take on Longformer for Tensorflow/Pytorch please.

@MarkusSagen
Copy link
Contributor

@MarkusSagen MarkusSagen commented Mar 21, 2022

@patrickvonplaten I would like to start with T5 for pytorch and tensorflow

@patrickvonplaten
Copy link
Member Author

@patrickvonplaten patrickvonplaten commented Mar 22, 2022

Sounds great!

@patrickvonplaten
Copy link
Member Author

@patrickvonplaten patrickvonplaten commented Mar 22, 2022

LayoutLM is also taken as mentioned by a contributor on Discord!

@cakiki
Copy link
Contributor

@cakiki cakiki commented Mar 22, 2022

@patrickvonplaten I would take GPT and GPT-J (TensorFlow editions) if those are still available.

I'm guessing GPT is GPT2?

@vumichien
Copy link
Contributor

@vumichien vumichien commented Mar 22, 2022

I will take Bert, Albert, and Bigbird for both Tensorflow/Pytorch

@johko
Copy link
Contributor

@johko johko commented Mar 22, 2022

I'll take Swin and ViT for Tensorflow

@jmwoloso
Copy link
Contributor

@jmwoloso jmwoloso commented Mar 22, 2022

I'd like DistilBERT for both TF and PT please

@ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented Mar 22, 2022

@patrickvonplaten I would take GPT and GPT-J (TensorFlow editions) if those are still available.

I'm guessing GPT is GPT2?

@cakiki You can go for GPT2 (I updated the name in the test)

@ArEnSc
Copy link
Contributor

@ArEnSc ArEnSc commented Mar 23, 2022

Can I try GPT2 and GPTJ for Pytorch? if @ydshieh you are not doing so?

@Aanisha
Copy link

@Aanisha Aanisha commented Mar 23, 2022

I would like to try CLIP for Tensorflow and PyTorch.

@NielsRogge
Copy link
Contributor

@NielsRogge NielsRogge commented Mar 23, 2022

I'll take CANINE and TAPAS.

@ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented Mar 23, 2022

Can I try GPT2 and GPTJ for Pytorch? if @ydshieh you are not doing so?

@ArEnSc
No, you can work on these 2 models :-) Thank you!

@vumichien
Copy link
Contributor

@vumichien vumichien commented Mar 23, 2022

@ydshieh Since the MobileBertForSequenceClassification is the copy of BertForSequenceClassification, so I think I will do check doc-test of MobileBert as well to overcome the error from make fixup

@abdouaziz
Copy link

@abdouaziz abdouaziz commented Mar 23, 2022

I'll take FlauBERT and CamemBERT.

@ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented Mar 23, 2022

@abdouaziz Awesome! Do you plan to work on both PyTorch and TensorFlow versions, or only one of them?

@Tegzes
Copy link
Contributor

@Tegzes Tegzes commented Mar 23, 2022

I would like to work on LUKE model for both TF and PT

@NielsRogge
Copy link
Contributor

@NielsRogge NielsRogge commented Mar 23, 2022

@Tegzes you're lucky because there's no LUKE in TF ;) the list above actually just duplicates all models, but many models aren't available yet in TF.

@Tegzes
Copy link
Contributor

@Tegzes Tegzes commented Mar 23, 2022

In this case, I will also take DeBERTa and DeBERTa-v2 for PyTorch

@abdouaziz
Copy link

@abdouaziz abdouaziz commented Mar 23, 2022

@ydshieh

I plan to work only with PyTorch

@patrickvonplaten
Copy link
Member Author

@patrickvonplaten patrickvonplaten commented Mar 23, 2022

@Tegzes you're lucky because there's no LUKE in TF ;) the list above actually just duplicates all models, but many models aren't available yet in TF.

True - sorry I've been lazy at creating this list!

@arnaudstiegler
Copy link
Contributor

@arnaudstiegler arnaudstiegler commented Mar 23, 2022

Happy to work on TrOCR (pytorch and TF)

@patrickvonplaten
Copy link
Member Author

@patrickvonplaten patrickvonplaten commented Mar 23, 2022

I take RoBERTa in PT and TF

@AbinayaM02
Copy link

@AbinayaM02 AbinayaM02 commented Mar 23, 2022

I would like to pick up XLM-RoBERTa in PT and TF.

@bhadreshpsavani
Copy link
Contributor

@bhadreshpsavani bhadreshpsavani commented Mar 23, 2022

I can work on ELECTRA for PT and TF

@hiromu166
Copy link
Contributor

@hiromu166 hiromu166 commented Apr 3, 2022

@ydshieh
I got the same error with hf-internal-testing working on Reformer. And I couldn't find any checkpoints without randomly initialized.
#16292 (comment)

@ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented Apr 4, 2022

@ydshieh I got the same error with hf-internal-testing working on Reformer. And I couldn't find any checkpoints without randomly initialized. #16292 (comment)

Hi, @hiromu166

Looks like we didn't upload a tokenizer for hf-internal-testing/tiny-random-reformer. These tiny models are created for some internal testing purpose, and we didn't have the intention to use it for doctest until now.

I will upload a tokenizer today! Thank you very much for pointing out this.

@ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented Apr 4, 2022

@hiromu166

I uploaded the tokenizer file spiece.model to hf-internal-testing/tiny-random-reformer.

Let me know if you have any problem using it in the doctest 🙏, thanks!

@hiromu166
Copy link
Contributor

@hiromu166 hiromu166 commented Apr 4, 2022

@ydshieh
Thank you for dealing with it quickly!!
I'll check it soon.

@bhadreshpsavani
Copy link
Contributor

@bhadreshpsavani bhadreshpsavani commented Apr 6, 2022

Hi @ydshieh,

For TFElectra i am getting answer index issue

doc.py file TF_QUESTION_ANSWERING_SAMPLE has target index at 14 and 15, while i am getting my prediction at 10, 12 index

@jmwoloso
Copy link
Contributor

@jmwoloso jmwoloso commented Apr 6, 2022

@ydshieh quick question. @jessecambon and I are working on the DistilBert model but we're seeing many of the examples are actually drawn and built from the examples in src/transformers/utils/doc.py which seems to be a global location, meaning it seems multiple models get their doc tests from this single file. So my question is whether someone else has edited those already or if we're free to edit them as part of our work, which will then flow out to other model architectures.

@ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented Apr 7, 2022

Hi @bhadreshpsavani , Yes there is an issue regarding the target indices. Please follow this discussion

#16523 (comment)
#16523 (comment)

I will discuss the team.

Hi @ydshieh,

For TFElectra i am getting answer index issue

doc.py file TF_QUESTION_ANSWERING_SAMPLE has target index at 14 and 15, while i am getting my prediction at 10, 12 index

@ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented Apr 7, 2022

Hi, @jmwoloso & @jessecambon

doc.py is not meant to be modified by the sprint contributor :-)

In order to customize, you can use add_code_sample_docstrings, and provide it with expected_output=..., expected_loss=..., checkpoint=..., etc.

You can looks this change on Roberta as a reference.

Let me know if you have any difficulty using this approach.

@ydshieh quick question. @jessecambon and I are working on the DistilBert model but we're seeing many of the examples are actually drawn and built from the examples in src/transformers/utils/doc.py which seems to be a global location, meaning it seems multiple models get their doc tests from this single file. So my question is whether someone else has edited those already or if we're free to edit them as part of our work, which will then flow out to other model architectures.

@ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented Apr 7, 2022

Hi @bhadreshpsavani , Yes there is an issue regarding the target indices. Please follow this discussion

#16523 (comment) #16523 (comment)

I will discuss the team.

Hi @ydshieh,
For TFElectra i am getting answer index issue
doc.py file TF_QUESTION_ANSWERING_SAMPLE has target index at 14 and 15, while i am getting my prediction at 10, 12 index

By the way, you don't have this issue for Electra (PyTorch version)? Do you use different checkpoint for PyTorch/TensorFlow Electra?

@bhadreshpsavani
Copy link
Contributor

@bhadreshpsavani bhadreshpsavani commented Apr 7, 2022

Hi @bhadreshpsavani , Yes there is an issue regarding the target indices. Please follow this discussion
#16523 (comment) #16523 (comment)
I will discuss the team.

Hi @ydshieh,
For TFElectra i am getting answer index issue
doc.py file TF_QUESTION_ANSWERING_SAMPLE has target index at 14 and 15, while i am getting my prediction at 10, 12 index

By the way, you don't have this issue for Electra (PyTorch version)? Do you use different checkpoint for PyTorch/TensorFlow Electra?

Hi @ydshieh,
Actually, I am using the same checkpoint.

@ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented Apr 7, 2022

Hi @ydshieh, Actually, I am using the same checkpoint. In python, we use where to find index but here its hardcoded i guess

What I saw in PT_QUESTION_ANSWERING_SAMPLE

    ```python
    >>> # target is "nice puppet"
    >>> target_start_index, target_end_index = torch.tensor([14]), torch.tensor([15])

    >>> outputs = model(**inputs, start_positions=target_start_index, end_positions=target_end_index)
    >>> loss = outputs.loss
    >>> round(loss.item(), 2)
    {expected_loss}

So if you use the same checkpoint for PT/TF Electra, the PyTorch should have the same issue I think.
Could you try run the doc test (for PT Electra) and see if it pass?

Also, let's move this discussion to your PR.

@jmwoloso
Copy link
Contributor

@jmwoloso jmwoloso commented Apr 7, 2022

@ydshieh ok, thank you for the clarification. so is the goal then to move away from doc.py and have individual doc tests in the specific model architecture files?

@ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented Apr 7, 2022

Hi, @jmwoloso not exactly. We still use doc.py, but in the individual model file(s), we tried to use a method add_code_sample_docstrings and provide some arguments.

The method add_code_sample_docstrings itself will use the example in doc.py and customize the doc examples using the arguments you provide.

@jmwoloso
Copy link
Contributor

@jmwoloso jmwoloso commented Apr 7, 2022

ok, awesome. thanks @ydshieh!

@san7988
Copy link

@san7988 san7988 commented Apr 14, 2022

Hi,

Is anyone working on BART TF version? If not I can try and contribute WRT that model.
Else can you suggest some model from above list(with slightly lower complexity as this will be my first attempt at contribution to transformers library :) ) which can be taken up?

Thanks

@ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented Apr 14, 2022

Not sure if someone is working on TF Bart. You can search the Pull request list.

Otherwise, TF Wav2Vec2 should be a good one to try. Should be quite easy with the recent change in

#16494 (comment)

@ghlai9665
Copy link
Contributor

@ghlai9665 ghlai9665 commented May 10, 2022

Since no one seems to have taken layoutlmv2 and the last activity on this thread was 25 days ago, I’m going to start working on layoutlmv2 :)

Edit: The PR is ready for review now

@nandwalritik
Copy link
Contributor

@nandwalritik nandwalritik commented May 12, 2022

@patrickvonplaten I would like to start with RoFormer for TF and PT.

@patrickvonplaten
Copy link
Member Author

@patrickvonplaten patrickvonplaten commented May 13, 2022

@nandwalritik - that's great! Do you want to open a PR for this?

@Ruihua-Fang
Copy link

@Ruihua-Fang Ruihua-Fang commented May 18, 2022

Hi @patrickvonplaten , I am interested in working on data2VecText. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests