Skip to content

Conversation

@agunapal
Copy link
Contributor

@agunapal agunapal commented Mar 11, 2025

Finetune llama-guard with torchtune

This PR includes a notebook which does the following:

  • Shows how to finetune llama-guard with torchtune
  • Shows how to finetune with a custom dataset & custom prompt template with torchtune
  • Shows how to finetune llama-guard to return multiple PII violations

Fixes # (issue)

Feature/Issue validation/testing

Please describe the tests that you ran to verify your changes and relevant result summary. Provide instructions so it can be reproduced.
Please also list any relevant details for your test configuration.

  • Test A
    Logs for Test A

  • Test B
    Logs for Test B

Before submitting

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

Thanks for contributing 🎉!

@albertodepaola albertodepaola self-requested a review March 12, 2025 16:34
@IgorKasianenko
Copy link
Contributor

IgorKasianenko commented Mar 18, 2025

Thanks for the PR!

  1. Could you please add torch tune install step in the notebook? I was missing torchao and torchtune
  2. What is the memory requirement? I am running OOM on batch_size=64, maybe it is worth setting it to 16 in the tune line

@IgorKasianenko
Copy link
Contributor

image
@agunapal Thanks for the notebook, it works end to end. The only thing is fine tuning on 8 NVIDIA L4 doesn't fit batch 64, and batch 16 for 10 epochs gives slightly worse performance f1 score is 44.49% vs 45.18% in your example.

@IgorKasianenko IgorKasianenko self-assigned this Mar 31, 2025
@IgorKasianenko
Copy link
Contributor

Looks good, please clear the cell outputs for install and training and I'll merge

Copy link
Contributor

@IgorKasianenko IgorKasianenko left a comment

Choose a reason for hiding this comment

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

LGTM

@IgorKasianenko IgorKasianenko merged commit 80149c2 into meta-llama:main Apr 1, 2025
4 checks passed
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.

3 participants