pycoder
pycoder

Reputation: 1

Roberta for sentence similarity

I have a pre trained roberta model. And have a dataset having two sentence pairs with a label that indicated whether the sentence pair is similar or not. I want to use that roberta model to do that.

I want to get sentence embeddings for both of sentences and use them to find the similarity using cosine similarity. Could you please tell me how to do that? or Any resources ?

Upvotes: 0

Views: 438

Answers (1)

Fahad Ebrahim
Fahad Ebrahim

Reputation: 1

The concept of extracting embeddings and calculating the cosine similarity can be referred to as "Semantic Search". You can use the sentence-transformers library.

Following is a link to a quick way to use semantic search with Sentence-transformers.

https://www.sbert.net/examples/applications/semantic-search/README.html

You can train the embeddings for your task using sentence-transformers or you can fine-tune the model for your task using the HuggingFace Trainer API.

Regards,

Upvotes: 0

Related Questions