最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python 3.x - word sentence similarities - Stack Overflow

programmeradmin4浏览0评论

I am trying to find if a given word/ set of words are similar to a definition.

Example - Definition - "vegetarian User"

Now, if I want to check a set of sentences like below

sentences = ['vegetarian User',
            'user sometimes eats chicken',
            'user is vegetarian',
            'user only eats fruits',
            'user likes fish']

I tried using some sentence transformer like below

model = SentenceTransformer("all-mpnet-base-v2")
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings,embeddings)
print(similarities)

But this is not giving me expected results.

What is the best approach to achieve results like below?

[False,True,True,False]

Is it doable with nlp/ some other technique?

发布评论

评论列表(0)

  1. 暂无评论