给定两个句子,我想基于语义相似度来量化两个文本之间的相似程度。语义文本相似性 (STS) 评估两个句子在语义上彼此等效的程度。说我的输入是有序的:
index line1 line2
0 the cat ate the mouse the mouse was eaten by the cat
1 the dog chased the cat the alligator is fat
2 the king ate the cake the cake was ingested by the king
应用算法后,输出需要是
index line1 line2 lbl
0 the cat ate the mouse the mouse was eaten by the cat 1
1 the dog chased the cat the alligator is fat 0
2 the king ate the cake the cake was ingested by the king 1
这里 lbl=1 表示句子在语义上相似,lbl=0 表示不相似。我将如何在 python 中实现它?我阅读了bert-as-a-service的文档,但由于我在这方面绝对是菜鸟,所以我无法正确理解它。