# Fine Tuning A sentence transformer model with my own data

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tuning-a-sentence-transformer-model-with-my-own-data%2F77085%3E%5C
**Category:** Intermediate\
**Created:** [March 12, 2024, 2:04pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tuning-a-sentence-transformer-model-with-my-own-data%2F77085 "2024-03-12T14:04:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rushikesh124](https://avatars.discourse-cdn.com/v4/letter/r/ea5d25/32.png) [@Rushikesh124](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FRushikesh124)%5C
**Post date:** [March 12, 2024, 2:04pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tuning-a-sentence-transformer-model-with-my-own-data%2F77085%2F1 "2024-03-12T14:04:02Z")

</div>

Hi all!

Cheers to this big community (and my first post here 📣)

I am trying to fine tune a sentence transformer model. The data I have contains below columns:

1. raw\_text - the raw chunks of text
2. label - corresponding label for the text - True or False.

I wanted to fine tune a sentence transformer model such that the embeddings are optimized in a way that all the True sentences are closer in the vector space than all the False sentence.

I have been reading about the losses from [Loss Overview — Sentence-Transformers documentation](https://www.sbert.net/docs/training/loss_overview.html)

I am really confused which loss to use for my type of data and use-case. I am leaned towards below:

 ![image](https://us1.discourse-cdn.com/hellohellohello/original/3X/1/f/1fd7bbbbc28040ffd1ae42f75ff8e42a6f8a4dc4.png)

since it matches my data format. As I read more about these losses and the way they are being computed using anchor, positive and negative samples I feel less confident in using them since my data does not have these kind of pair.

Can someone here help me understand if what I am trying to do is plausible with existing losses in sentence transformer library?

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnielsr)%5C
**Post date:** [March 12, 2024, 7:51pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tuning-a-sentence-transformer-model-with-my-own-data%2F77085%2F2 "2024-03-12T19:51:20Z")

</div>

Hi,

Refer to this blog post: [Train and Fine-Tune Sentence Transformers Models](https://huggingface.co/blog/how-to-train-sentence-transformers). The blog post has a [section](https://huggingface.co/blog/how-to-train-sentence-transformers#how-to-prepare-your-dataset-for-training-a-sentence-transformers-model) on various cases that your dataset may be in, and which loss functions one can use correspondingly.

---

<div class="post-metadata">

**Author:** ![shrijayan](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/shrijayan/32/28178_2.png) [@shrijayan](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fshrijayan)%5C
**Post date:** [April 17, 2024, 5:31pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tuning-a-sentence-transformer-model-with-my-own-data%2F77085%2F3 "2024-04-17T17:31:12Z")

</div>

I am trying to train the Sentence Transformer model also checked the link but always I get the accuracy of only 20 to 30%.

1. Is it maybe base model ? what base model to train
2. How to evaluate these models?
