shibing624 / text2vec

text2vec, text to vector. 文本向量表征工具,把文本转化为向量矩阵,实现了Word2Vec、RankBM25、Sentence-BERT、CoSENT等文本表征、文本相似度计算模型,开箱即用。
https://pypi.org/project/text2vec/
Apache License 2.0
4.39k stars 392 forks source link

执行sim.get_score("hello","hello") 报错。 #147

Closed melisa81 closed 8 months ago

melisa81 commented 8 months ago

Traceback (most recent call last): File "", line 1, in File "/root/miniconda3/envs/mindspore2.2_py39/lib/python3.9/site-packages/text2vec/similarity.py", line 104, in get_score res = cos_sim(emb1, emb2)[0] if self.embedding_type == EmbeddingType.BERT else cosine_distance(emb1, emb2) File "/root/miniconda3/envs/mindspore2.2_py39/lib/python3.9/site-packages/text2vec/similarity.py", line 163, in cos_sim return torch.mm(a_norm, b_norm.transpose(0, 1)) RuntimeError: could not create a primitive descriptor for a matmul primitive

shibing624 commented 8 months ago

只接受列表。

    def get_scores(
            self, sentences1: List[str], sentences2: List[str], only_aligned: bool = False
    ) -> ndarray: