{"id":13678418,"url":"https://github.com/Sujit-O/pykg2vec","last_synced_at":"2025-04-29T13:30:57.967Z","repository":{"id":38808638,"uuid":"174234670","full_name":"Sujit-O/pykg2vec","owner":"Sujit-O","description":"Python library for knowledge graph embedding and representation learning.","archived":false,"fork":false,"pushed_at":"2021-04-21T16:14:56.000Z","size":9742,"stargazers_count":611,"open_issues_count":32,"forks_count":112,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-09T11:08:52.464Z","etag":null,"topics":["embedding-models","embedding-python","knowledge-graph","representation-learning"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sujit-O.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-06T23:06:11.000Z","updated_at":"2025-03-05T00:38:28.000Z","dependencies_parsed_at":"2022-07-16T18:17:04.502Z","dependency_job_id":null,"html_url":"https://github.com/Sujit-O/pykg2vec","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sujit-O%2Fpykg2vec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sujit-O%2Fpykg2vec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sujit-O%2Fpykg2vec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sujit-O%2Fpykg2vec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sujit-O","download_url":"https://codeload.github.com/Sujit-O/pykg2vec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251509436,"owners_count":21600637,"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":["embedding-models","embedding-python","knowledge-graph","representation-learning"],"created_at":"2024-08-02T13:00:53.377Z","updated_at":"2025-04-29T13:30:57.364Z","avatar_url":"https://github.com/Sujit-O.png","language":"Python","funding_links":[],"categories":["Python","Transformer-based Model \u003cspan id=\"transformer-based-models-\"\u003e\u003c/span\u003e"],"sub_categories":["RNN-agnostic Models \u003cspan id=\"rnn-agnostic-models-\"\u003e\u003c/span\u003e"],"readme":"[![Documentation Status](https://readthedocs.org/projects/pykg2vec/badge/?version=latest)](https://pykg2vec.readthedocs.io/en/latest/?badge=latest) [![CircleCI](https://circleci.com/gh/Sujit-O/pykg2vec.svg?style=svg)](https://circleci.com/gh/Sujit-O/pykg2vec) [![Python 3.7](https://img.shields.io/badge/python-3.7-blue.svg)](https://www.python.org/downloads/release/python-370/) [![Build Status](https://travis-ci.org/Sujit-O/pykg2vec.svg?branch=master)](https://travis-ci.org/Sujit-O/pykg2vec) [![PyPI version](https://badge.fury.io/py/pykg2vec.svg)](https://badge.fury.io/py/pykg2vec) [![GitHub license](https://img.shields.io/github/license/Sujit-O/pykg2vec.svg)](https://github.com/Sujit-O/pykg2vec/blob/master/LICENSE) [![Coverage Status](https://coveralls.io/repos/github/Sujit-O/pykg2vec/badge.svg?branch=master)](https://coveralls.io/github/Sujit-O/pykg2vec?branch=master) [![Twitter](https://img.shields.io/twitter/url/https/github.com/Sujit-O/pykg2vec.svg?style=social)](https://twitter.com/intent/tweet?text=Wow:\u0026url=https%3A%2F%2Fgithub.com%2FSujit-O%2Fpykg2vec) \n\n# Pykg2vec: Python Library for KGE Methods \nPykg2vec is a library for learning the representation of entities and relations in Knowledge Graphs built on top of PyTorch 1.5 (TF2 version is available in [tf-master](https://github.com/Sujit-O/pykg2vec/tree/tf2-master) branch as well). We have attempted to bring state-of-the-art Knowledge Graph Embedding (KGE) algorithms and the necessary building blocks in the pipeline of knowledge graph embedding task into a single library. We hope Pykg2vec is both practical and educational for people who want to explore the related fields.  \n\nFeatures:\n* Support state-of-the-art KGE model implementations and benchmark datasets. (also support custom datasets)\n* Support automatic discovery for hyperparameters.\n* Tools for inspecting the learned embeddings. \n  * Support exporting the learned embeddings in TSV or Pandas-supported format.\n  * Interactive result inspector.\n  * TSNE-based, KPI summary visualization (mean rank, hit ratio) in various format. (csvs, figures, latex table)\n\n![](https://github.com/Sujit-O/pykg2vec/blob/master/figures/pykg2vec_structure.png?raw=true)\n\nWe welcome any form of contribution! Please refer to [CONTRIBUTING.md](https://github.com/Sujit-O/pykg2vec/blob/master/CONTRIBUTING.md) for more details. \n\n## To Get Started \nBefore using pykg2vec, we recommend users to have the following libraries installed:\n* python \u003e=3.7 (recommended)\n* pytorch\u003e= 1.5\n\nQuick Guide for Anaconda users:\n\n* Setup a Virtual Environment: we encourage you to use anaconda to work with pykg2vec:\n```bash\n(base) $ conda create --name pykg2vec python=3.7\n(base) $ conda activate pykg2vec\n```\n* Setup Pytorch: we encourage to use pytorch with GPU support for good training performance. However, a CPU version also runs. The following sample commands are for setting up pytorch:\n\n```bash\n# if you have a GPU with CUDA 10.1 installed\n(pykg2vec) $ conda install pytorch torchvision cudatoolkit=10.1 -c pytorch\n# or cpu-only\n(pykg2vec) $ conda install pytorch torchvision cpuonly -c pytorch\n```\n\n* Setup Pykg2vec:\n```bash\n(pykg2vec) $ git clone https://github.com/Sujit-O/pykg2vec.git\n(pykg2vec) $ cd pykg2vec\n(pykg2vec) $ python setup.py install\n```\n\nFor beginners, these papers, [A Review of Relational Machine Learning for Knowledge Graphs](https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=\u0026arnumber=7358050), [Knowledge Graph Embedding: A Survey of Approaches and Applications](https://ieeexplore.ieee.org/document/8047276), and [An overview of embedding models of entities and relationships for knowledge base completion](https://arxiv.org/abs/1703.08098) can be good starting points!\n\n## User Documentation\nThe documentation is [here](https://pykg2vec.readthedocs.io/). \n\n## Usage Examples\nWith pykg2vec command-line interface, you can\n1. Run a single algorithm with various models and datasets (customized dataset also supported).\n    ```\n    # Check all tunnable parameters.\n    (pykg2vec) $ pykg2vec-train -h\n\n    # Train TransE on FB15k benchmark dataset.\n    (pykg2vec) $ pykg2vec-train -mn TransE\n\n    # Train using different KGE methods.\n    (pykg2vec) $ pykg2vec-train -mn [TransE|TransD|TransH|TransG|TransM|TransR|Complex|ComplexN3|\n                        CP|RotatE|Analogy|DistMult|KG2E|KG2E_EL|NTN|Rescal|SLM|SME|SME_BL|HoLE|\n                        ConvE|ConvKB|Proje_pointwise|MuRP|QuatE|OctonionE|InteractE|HypER]\n\n    # For KGE using projection-based loss function, use more processes for batch generation.\n    (pykg2vec) $ pykg2vec-train -mn [ConvE|ConvKB|Proje_pointwise] -npg [the number of processes, 4 or 6]\n\n    # Train TransE model using different benchmark datasets.\n    (pykg2vec) $ pykg2vec-train -mn TransE -ds [fb15k|wn18|wn18_rr|yago3_10|fb15k_237|ks|nations|umls|dl50a|nell_955]\n\n    # Train TransE model using your own hyperparameters.\n    (pykg2vec) $ pykg2vec-train -exp True -mn TransE -ds fb15k -hpf ./examples/custom_hp.yaml\n\n    # Use your own dataset\n    (pykg2vec) $ pykg2vec-train -mn TransE -ds [name] -dsp [path to the custom dataset]\n    ```\n2. Tune a single algorithm.\n    ```\n    # Tune TransE using the benchmark dataset.\n    (pykg2vec) $ pykg2vec-tune -mn [TransE] -ds [dataset name]\n\n    # Tune TransE with your own search space\n    (pykg2vec) $ pykg2vec-tune -exp True -mn TransE -ds fb15k -ssf ./examples/custom_ss.yaml\n    ```\n3. Perform Inference Tasks (more advanced).\n    ```\n    # Train a model and perform inference tasks.\n    (pykg2vec) $ pykg2vec-infer -mn TransE\n\n    # Perform inference tasks over a pretrained model.\n    (pykg2vec) $ pykg2vec-infer -mn TransE -ld [path to the pretrained model]\n    ```\n\\* NB: On Windows, use `pykg2vec-train.exe`, `pykg2vec-tune.exe` and `pykg2vec-infer.exe` instead.\n\nFor more usage of pykg2vec APIs, please check the [programming examples](https://pykg2vec.readthedocs.io/en/latest/auto_examples/index.html).\n\n## Citation\nPlease kindly consider citing our paper if you find pykg2vec useful for your research. \n```\n  @article{yu2019pykg2vec,\n  title={Pykg2vec: A Python Library for Knowledge Graph Embedding},\n  author={Yu, Shih Yuan and Rokka Chhetri, Sujit and Canedo, Arquimedes and Goyal, Palash and Faruque, Mohammad Abdullah Al},\n  journal={arXiv preprint arXiv:1906.04239},\n  year={2019}\n  }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSujit-O%2Fpykg2vec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSujit-O%2Fpykg2vec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSujit-O%2Fpykg2vec/lists"}