1
$\begingroup$

How to implement STS(Semantic Textual Similarity) on unlabelled dataset. Dataset column contains Unique_id, text1(contains paragraph), text2(contains paragraph).

Ex: Column representation: Unique_id | Text1 | Text2

Unique_id 0

Text1 public show for reynolds suspension of his coaching licence. portrait sir joshua reynolds portrait of omai will get a public airing following fears it would stay hidden because of an export wrangle.

Text2 then requested to do so by spain s anti-violence commission. the fine was far less than the expected amount of about £22 000 or even the suspension of his coaching licence.

Unique_id 1

Text1 groening. gervais has already begun writing the script but is keeping its subject matter a closely guarded secret. he will also write a part for himself in the episode. i ve got the rough idea but this is the most intimidating project of my career.

Text2 philadelphia said they found insufficient evidence to support the woman s allegations regarding an alleged incident in january 2004. the woman reported the allegations to canadian authorities last month. cosby s lawyer walter m phillips jr said the comedian was pleased with the decision.

In the above problem, I've to compare two paragraphs texts i.e. Text1 & Text2 and then I've to compare semantic similarity between two texts. If they are semantically similar then it will print '1' if not then '0'

Any refrence implementation link or any suggestions !

Thanks in advance

$\endgroup$
0
$\begingroup$

You could take pretrained embedder and look for distances between the embeddings. There's LASER from Facebook. This is an unofficial pypi package, it replaces some of the internal tools used for tokenization and BPE encodings. I've used it extensively and it works just fine. It encodes your text as 1024-element numerical vector. Then you can just calculate distance metric between embeddings i.e. euclidean.

| improve this answer | |
$\endgroup$
  • $\begingroup$ In the above problem, I've to compare two paragraphs texts i.e. Text1 & Text2 and then I've to compare semantic similarity between two texts. If they are semantically similar then it will print '1' if not then '0'. $\endgroup$ – Vishal Singh Jan 3 at 8:56
  • 1
    $\begingroup$ As you want to do it in unsupervised way, you'd eventually need to set some threshold manually on metric. $\endgroup$ – Piotr Rarus - Reinstate Monica Jan 3 at 9:10
0
$\begingroup$

Try google universal sentence encoder ,check out the colab version of UC and just replace the example query in there with your 2 query it will give the score of the similarity between any two sentence . its the best to calculate semantic text similarity

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.