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

Add Fine-Tune BERT LLM Example #2021

Merged

Conversation

andreyvelich
Copy link
Member

@andreyvelich andreyvelich commented Mar 10, 2024

I added example to fine-tune BERT model with Yelp review dataset.
This example is based on this tutorial: https://huggingface.co/docs/transformers/en/training
I used split_dataset_by_node to distribute data across PyTorchJob workers.

Also, I moved our SDK examples to these folders: text-classification, image-classification, language-modeling.
Similar to HuggingFace transformers examples: https://github.com/huggingface/transformers/tree/main/examples/pytorch

I think, we should refactor our Training Operator examples directory in the future PRs to make it more ML engineers and data scientists friendly.
Regardless if users are using Kubeflow Python SDK or kubectl and YAMLs to submit jobs they should be able to find the appropriate AI/ML training use-cases.

From my perspective, for the long-term we should guide our users more towards Python SDK to submit Kubeflow Jobs.

Please let me know what do you think @johnugeorge @gaocegege @terrytangyuan @kuizhiqing @deepanker13 @Jeffwan @droctothorpe @tenzen-y @StefanoFioravanzo

/hold for review

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Signed-off-by: Andrey Velichkevich <andrey.velichkevich@gmail.com>
@coveralls
Copy link

coveralls commented Mar 10, 2024

Pull Request Test Coverage Report for Build 8237084497

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 42.896%

Totals Coverage Status
Change from base Build 8214367884: 0.02%
Covered Lines: 3756
Relevant Lines: 8756

💛 - Coveralls

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it fine to use space blank in filename?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Notebook files it should be normal, but if we want, we can name files without space blanks.

@kuizhiqing
Copy link
Member

Happy to see it, thank @andreyvelich for driving this. Maybe we can make a roadmap for the examples and I'd like to contribute too.

One thing from my personal perspective is that if we dedicate to the notebook format or we can support pure python code with markdown or something like that?

@tenzen-y
Copy link
Member

Happy to see it, thank @andreyvelich for driving this. Maybe we can make a roadmap for the examples and I'd like to contribute too.

+1
Let's create a dedicated issue.

@@ -0,0 +1,683 @@
{
Copy link
Member

@tenzen-y tenzen-y Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line #8.        num_workers=3,  # Number of PyTorch workers to use.

Should we replace this with 1 aligned with the above comment:

At least 1 GPU on your Kubernetes cluster to fine-tune BERT model on 1 worker.

Or, should we update the above comment?


Reply via ReviewNB

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, let me change it to 3.

@@ -0,0 +1,683 @@
{
Copy link
Member

@tenzen-y tenzen-y Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line #9.    good_review = "This is one of the best restaurants. I've ever been to."


Reply via ReviewNB

Copy link
Member Author

@andreyvelich andreyvelich Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, however LLM can easily recognize sentences without full stop 😃
Also, I believe this sentence is grammatically correct, isn't ?

This is one of the best restaurants I've ever been to

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense.
Also, Grammarly says this is fine as well :)

@andreyvelich
Copy link
Member Author

Maybe we can make a roadmap for the examples and I'd like to contribute too.

That's good idea, do you want to start issue to identify examples that we want to add (e.g. text-generation, speech recognition, and more)?

One thing from my personal perspective is that if we dedicate to the notebook format or we can support pure python code with markdown or something like that?

I think, we have pros and cons of using Notebook files vs Python files. For example, it's easier to implement E2Es test for Python files, but Notebooks are usually more Data Scientists friendly. I an open to your suggestions @tenzen-y @kuizhiqing @johnugeorge.

Signed-off-by: Andrey Velichkevich <andrey.velichkevich@gmail.com>
@tenzen-y
Copy link
Member

I think, we have pros and cons of using Notebook files vs Python files. For example, it's easier to implement E2Es test for Python files, but Notebooks are usually more Data Scientists friendly. I an open to your suggestions @tenzen-y @kuizhiqing @johnugeorge.

Anyway, I think that we should have a dedicated issue.

Copy link
Member

@tenzen-y tenzen-y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andreyvelich, tenzen-y

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [andreyvelich,tenzen-y]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@andreyvelich
Copy link
Member Author

/assign @kuizhiqing @johnugeorge @deepanker13 For the final review

@kuizhiqing
Copy link
Member

/lgtm

@johnugeorge
Copy link
Member

We will add a similar one using Train API
/hold cancel

@google-oss-prow google-oss-prow bot merged commit 395e8ca into kubeflow:master Mar 12, 2024
37 checks passed
@andreyvelich andreyvelich deleted the add-example-fine-tune-llm branch March 12, 2024 12:02
tedhtchang pushed a commit to tedhtchang/training-operator that referenced this pull request Apr 5, 2024
* Add Fine-Tune BERT LLM Example

Signed-off-by: Andrey Velichkevich <andrey.velichkevich@gmail.com>

* Add 3 GPUs in Notebook requirements

Signed-off-by: Andrey Velichkevich <andrey.velichkevich@gmail.com>

---------

Signed-off-by: Andrey Velichkevich <andrey.velichkevich@gmail.com>
deepanker13 pushed a commit to deepanker13/deepanker-training-operator that referenced this pull request Apr 8, 2024
* Add Fine-Tune BERT LLM Example

Signed-off-by: Andrey Velichkevich <andrey.velichkevich@gmail.com>

* Add 3 GPUs in Notebook requirements

Signed-off-by: Andrey Velichkevich <andrey.velichkevich@gmail.com>

---------

Signed-off-by: Andrey Velichkevich <andrey.velichkevich@gmail.com>
Signed-off-by: deepanker13 <deepanker.gupta@nutanix.com>
johnugeorge pushed a commit to johnugeorge/training-operator that referenced this pull request Apr 28, 2024
* Add Fine-Tune BERT LLM Example

Signed-off-by: Andrey Velichkevich <andrey.velichkevich@gmail.com>

* Add 3 GPUs in Notebook requirements

Signed-off-by: Andrey Velichkevich <andrey.velichkevich@gmail.com>

---------

Signed-off-by: Andrey Velichkevich <andrey.velichkevich@gmail.com>
johnugeorge pushed a commit to johnugeorge/training-operator that referenced this pull request Apr 28, 2024
* Add Fine-Tune BERT LLM Example

Signed-off-by: Andrey Velichkevich <andrey.velichkevich@gmail.com>

* Add 3 GPUs in Notebook requirements

Signed-off-by: Andrey Velichkevich <andrey.velichkevich@gmail.com>

---------

Signed-off-by: Andrey Velichkevich <andrey.velichkevich@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants