DEV Community

fadingNA
fadingNA

Posted on

Happy Hacking: My First Hacktoberfest Pull Request šŸŽ‰

Itā€™s that time of year againā€”October has arrived, and so has Hacktoberfest! As a developer participating in this event, Iā€™m excited to share my experience contributing to open-source projects. In this blog post, Iā€™ll walk you through my first pull request (PR) to the Hugging Face Transformers repository.
In generally, we have to go through all the popular and active repository to make our changed or pull request to maintainer review it and accept it. From my first pull request to Transformers

Find the Issue

Before diving into the details, I spent some time exploring various popular and active repositories to find an issue that I could contribute to. The goal is to make meaningful changes that can be reviewed and, hopefully, merged by the maintainers and I am focussing on good first issue.

After some research, I found an issue in the Hugging Face Transformers repo titled ā€œMultiTask Classification and label_names on Trainer,ā€ created by @joaopedrosdmm.

Understanding the Issue

The issue in question revolved around multi-task classification with the Trainer class in the Transformers library. The problem arose when the model evaluation started after training, throwing a KeyError for 'eval_loss' due to an incomplete setup for handling the labels during evaluation.

The key challenge was the incorrect or missing label_names that needed to be passed to the Trainer. In multi-task classification, multiple labels must be processed for each task, and those labels should be correctly defined and passed into the training arguments.

Approach to improve error handling

After thoroughly reviewing the issue and comments from the community, I found that the error likely stemmed from a typo and the misconfiguration of the evaluation metrics.

  • function by updating the KeyError message when the metric_for_best_model argument is not found in the evaluation metrics. The new error message provides clearer guidance, including suggestions on checking the compute_metrics function and updating TrainingArguments if necessary.

Update an keyerror on _save_check_point prevent confusion of missing ā€¦ #33832

What does this PR do?

This PR improves the error handling in the _save_checkpoint

  • function by updating the KeyError message when the metric_for_best_model argument is not found in the evaluation metrics. The new error message provides clearer guidance, including suggestions on checking the compute_metrics function and updating TrainingArguments if necessary.

Fixes issues #33193

Before submitting

  • [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • [x] Did you read the contributor guideline, Pull Request section?
  • [ ] Was this discussed/approved via a Github issue or the forum? Please add a link to it if that's the case.
  • [ ] Did you make sure to update the documentation with your changes? Here are the documentation guidelines, and here are tips on formatting docstrings.
  • [ ] Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag members/contributors who may be interested in your PR. @muellerzr and @SunMarc

3 Commits

After testing my solution and ensuring that the improved error handling worked correctly, I submitted a pull request to the Hugging Face Transformers repository.

Update error handling

As shown in the image above, it took me three commits to fix the grammatical errors and finalize the changes in both the _evaluation function and the _save_checkpoint function. The PR addressed the issue with better error messages and ensured that the code provided clearer guidance for developers who encounter similar problems in the future.

Conclusion

Approve hacktober

Participating in Hacktoberfest 2024 has been a great opportunity to contribute to open-source projects, learn from a vibrant community, and improve my coding skills. My first pull request to the Hugging Face Transformers repository taught me the value of clear error messages, collaboration, and continuous learning.

I encourage everyone to participate in Hacktoberfest and contribute to open-source projects. Whether youā€™re fixing small bugs, adding documentation, or contributing new features, your contributions matter and help make these projects better for everyone.

Top comments (0)