项目介绍

zjunlp/KNN-KG 是一个托管在 GitHub 上的开源项目,主要使用 Python 编写,目前获得 55 个 Star、9 次 Fork。

仓库全名
zjunlp/KNN-KG
Star 数
55
Fork 数
9
未关闭 Issue
1

README 摘要

KNN-KG Code for the NLPCC2023 paper "Reasoning Through Memorization: Nearest Neighbor Knowledge Graph Embeddings with Language Models". Requirements ========== To install requirements: Run the experiments ========== Training Entity Embedding Initialization Use the command below to add entities to BERT and train the entity embedding layer to use in the later training. For another dataset WN18RR just replacing the…

完整内容见 GitHub 原始 README 或本页 。

常见问题

KNN-KG 用什么语言开发?

主要使用 Python 编写,目前有 55 个 Star。

如何获取 KNN-KG 的源码?

可以直接克隆仓库:git clone https://github.com/zjunlp/KNN-KG.git;安装与运行步骤见仓库 README。

KNN-KG 最近还在维护吗?

仓库最近一次更新为 2023年7月31日,当前有 1 个未关闭 Issue;Star 数为 55,可作为社区活跃度的参考。

关于

[NLPCC 2023] Reasoning Through Memorization: Nearest Neighbor Knowledge Graph Embeddings with Language Models

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

README

KNN-KG

Code for the NLPCC2023 paper “Reasoning Through Memorization: Nearest Neighbor Knowledge Graph Embeddings with Language Models”.

Requirements

To install requirements:

pip install -r requirements.txt

Run the experiments

Training

Entity Embedding Initialization

Use the command below to add entities to BERT and train the entity embedding layer to use in the later training. For another dataset WN18RR just replacing the dataset name will be fine.

./scripts/pretrain_fb15k.sh

The parameters of Entity Embedding Layer trained will be used in the next Entity prediction task.

Entity Prediction Task

Use the command below to train the model to predict the correct entity in the masked position.

./scripts/fb15k-237/fb15k.sh

Consturct Knowledge Store

After training the model in Entity prediction task, we use the model to get the knowledge store built from triples and descriptions.

./scripts/fb15k-237/get_knowledge_store.sh

Inference

Here we have a trained model and our knowledge store (e.g., faiss.dump file), use the command below to inference in the test set.

./scripts/fb15k-237/inference.sh

And for inductive setting, the command is similar to the transductive setting (just replace the dataset with inductive dataset), the code will automatically handle the differences.

评论

暂无评论