# Fine tune with SFTTrainer

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tune-with-sfttrainer%2F67311%3E%5C
**Category:** Intermediate\
**Created:** [December 28, 2023, 7:16pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tune-with-sfttrainer%2F67311 "2023-12-28T19:16:32Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![ran-w](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ran-w/32/24245_2.png) [@ran-w](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fran-w)%5C
**Post date:** [March 3, 2024, 12:21am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tune-with-sfttrainer%2F67311%2F4 "2024-03-03T00:21:40Z")

</div>

Hi, not sure if you have tried or seen this. When I try to do sft on only completions using `DataCollatorForCompletionOnlyLM`, I get nan in the gradients very quickly. However, when I use the default sft which is on the entire input, everything works well. Do you happen to have any ideas why?

My issue is linked here: [TRL SFT super prone to nan when using data collator](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftrl-sft-super-prone-to-nan-when-using-data-collator%2F75634)

---

_[View the full topic](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tune-with-sfttrainer%2F67311)._
