{"id":13677111,"url":"https://github.com/yao8839836/kg-bert","last_synced_at":"2025-04-04T16:15:05.866Z","repository":{"id":40605242,"uuid":"206275296","full_name":"yao8839836/kg-bert","owner":"yao8839836","description":"KG-BERT: BERT for Knowledge Graph Completion","archived":false,"fork":false,"pushed_at":"2022-07-11T05:16:18.000Z","size":78167,"stargazers_count":740,"open_issues_count":26,"forks_count":141,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-28T15:09:19.276Z","etag":null,"topics":["bert","knowledge-graph"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yao8839836.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-04T08:54:05.000Z","updated_at":"2025-03-25T06:36:26.000Z","dependencies_parsed_at":"2022-08-24T23:41:15.244Z","dependency_job_id":null,"html_url":"https://github.com/yao8839836/kg-bert","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yao8839836%2Fkg-bert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yao8839836%2Fkg-bert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yao8839836%2Fkg-bert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yao8839836%2Fkg-bert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yao8839836","download_url":"https://codeload.github.com/yao8839836/kg-bert/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247208150,"owners_count":20901570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bert","knowledge-graph"],"created_at":"2024-08-02T13:00:37.059Z","updated_at":"2025-04-04T16:15:05.846Z","avatar_url":"https://github.com/yao8839836.png","language":"Python","funding_links":[],"categories":["Python","关系抽取、信息抽取"],"sub_categories":["其他_文本生成、文本对话"],"readme":"# KG-BERT: BERT for Knowledge Graph Completion\n\nThe repository is modified from [pytorch-pretrained-BERT](https://github.com/huggingface/pytorch-pretrained-BERT) and tested on Python 3.5+.\n\n\n## Installing requirement packages\n\n```bash\npip install -r requirements.txt\n```\n\n## Data\n\n(1) The benchmark knowledge graph datasets are in ./data. \n\n(2) entity2text.txt or entity2textlong.txt in each dataset contains entity textual sequences.\n\n(3) relation2text.txt in each dataset contains relation textual sequences.\n\n## Reproducing results\n \n### 1. Triple Classification\n\n#### WN11\n\n```shell\npython run_bert_triple_classifier.py \n--task_name kg\n--do_train  \n--do_eval \n--do_predict \n--data_dir ./data/WN11 \n--bert_model bert-base-uncased \n--max_seq_length 20 \n--train_batch_size 32 \n--learning_rate 5e-5 \n--num_train_epochs 3.0 \n--output_dir ./output_WN11/  \n--gradient_accumulation_steps 1 \n--eval_batch_size 512\n```\n\n#### FB13\n\n```shell\npython run_bert_triple_classifier.py \n--task_name kg  \n--do_train  \n--do_eval \n--do_predict \n--data_dir ./data/FB13 \n--bert_model bert-base-cased\n--max_seq_length 200\n--train_batch_size 32 \n--learning_rate 5e-5 \n--num_train_epochs 3.0 \n--output_dir ./output_FB13/  \n--gradient_accumulation_steps 1 \n--eval_batch_size 512\n```\n\n\n### 2. Relation Prediction\n\n#### FB15K\n\n```shell\npython3 run_bert_relation_prediction.py \n--task_name kg  \n--do_train  \n--do_eval \n--do_predict \n--data_dir ./data/FB15K \n--bert_model bert-base-cased\n--max_seq_length 25\n--train_batch_size 32 \n--learning_rate 5e-5 \n--num_train_epochs 20.0 \n--output_dir ./output_FB15K/  \n--gradient_accumulation_steps 1 \n--eval_batch_size 512\n```\n\n### 3. Link Prediction\n\n#### WN18RR\n\n```shell\npython3 run_bert_link_prediction.py\n--task_name kg  \n--do_train  \n--do_eval \n--do_predict \n--data_dir ./data/WN18RR\n--bert_model bert-base-cased\n--max_seq_length 50\n--train_batch_size 32 \n--learning_rate 5e-5 \n--num_train_epochs 5.0 \n--output_dir ./output_WN18RR/  \n--gradient_accumulation_steps 1 \n--eval_batch_size 5000\n```\n\n#### UMLS\n\n```shell\npython3 run_bert_link_prediction.py\n--task_name kg  \n--do_train  \n--do_eval \n--do_predict \n--data_dir ./data/umls\n--bert_model bert-base-uncased\n--max_seq_length 15\n--train_batch_size 32 \n--learning_rate 5e-5 \n--num_train_epochs 5.0 \n--output_dir ./output_umls/  \n--gradient_accumulation_steps 1 \n--eval_batch_size 135\n```\n\n#### FB15k-237\n\n```shell\npython3 run_bert_link_prediction.py\n--task_name kg  \n--do_train  \n--do_eval \n--do_predict \n--data_dir ./data/FB15k-237\n--bert_model bert-base-cased\n--max_seq_length 150\n--train_batch_size 32 \n--learning_rate 5e-5 \n--num_train_epochs 5.0 \n--output_dir ./output_FB15k-237/  \n--gradient_accumulation_steps 1 \n--eval_batch_size 1500\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyao8839836%2Fkg-bert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyao8839836%2Fkg-bert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyao8839836%2Fkg-bert/lists"}