0

尝试使用 Unwind 将词嵌入添加到我的节点。

编码:

nodes = [x['m'] for x in result]
        for dic in nodes:
            dic['embedding'] = list(np.round(model_st.encode(dic['name'], show_progress_bar=False), 3))
query_update = f""" UNWIND $nodes as res_dict
                    MATCH (n:Word {{name: res_dict.name}})
                    SET n.embedding = res_dict.embedding
                """
self.conn.query(query=query_update, parameters={'nodes': nodes})

但是当我尝试运行它时,我收到以下错误:

Parameters of type float32 are not supported

如何在 Python 中实现它?有没有更好的方法来设置嵌入到节点?

4

1 回答 1

0

我能够使用以下代码添加嵌入

embedding = list(np.round(model_st.encode(name, show_progress_bar=False).astype(np.float64),3))

我仍然认为 Neo4j 没有创建嵌入的本地方式(使用 apoc/gds)很奇怪

于 2022-01-06T07:56:53.360 回答