{"id":33100269,"url":"https://github.com/mnick/scikit-kge","last_synced_at":"2026-01-28T10:18:36.138Z","repository":{"id":40643759,"uuid":"51112487","full_name":"mnick/scikit-kge","owner":"mnick","description":"Python library to compute knowledge graph embeddings","archived":false,"fork":false,"pushed_at":"2019-02-10T19:26:32.000Z","size":24,"stargazers_count":473,"open_issues_count":11,"forks_count":143,"subscribers_count":37,"default_branch":"master","last_synced_at":"2024-07-19T17:43:37.786Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/mnick.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":"2016-02-04T23:10:29.000Z","updated_at":"2024-07-08T13:36:09.000Z","dependencies_parsed_at":"2022-09-18T15:13:20.317Z","dependency_job_id":null,"html_url":"https://github.com/mnick/scikit-kge","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mnick/scikit-kge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnick%2Fscikit-kge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnick%2Fscikit-kge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnick%2Fscikit-kge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnick%2Fscikit-kge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mnick","download_url":"https://codeload.github.com/mnick/scikit-kge/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnick%2Fscikit-kge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284662610,"owners_count":27043071,"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","status":"online","status_checked_at":"2025-11-16T02:00:05.974Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-11-14T21:00:37.722Z","updated_at":"2025-11-16T05:00:55.986Z","avatar_url":"https://github.com/mnick.png","language":"Python","funding_links":[],"categories":["Transformer-based Model \u003cspan id=\"transformer-based-models-\"\u003e\u003c/span\u003e","Libraries, Softwares and Tools"],"sub_categories":["RNN-agnostic Models \u003cspan id=\"rnn-agnostic-models-\"\u003e\u003c/span\u003e","KRL Libraries"],"readme":"# Knowledge Graph Embeddings\n\nscikit-kge is a Python library to compute embeddings of knowledge graphs. The\nlibrary consists of different building blocks to train and develop models for\nknowledge graph embeddings.\n\nTo compute a knowledge graph embedding, first instantiate a model and then train it\nwith desired training method. For instance, to train [holographic embeddings of knowledge graphs](http://arxiv.org/abs/1510.04935) (HolE) with a logistcc loss function:\n\n```python\nfrom skge import HolE, StochasticTrainer\n\n# Load knowledge graph \n# N = number of entities\n# M = number of relations\n# xs = list of (subject, object, predicte) triples\n# ys = list of truth values for triples (1 = true, -1 = false)\nN, M, xs, ys = load_data('path to data')\n\n# instantiate HolE with an embedding space of size 100\nmodel = HolE((N, N, M), 100)\n\n# instantiate trainer\ntrainer = StochasticTrainer(model)\n\n# fit model to knowledge graph\ntrainer.fit(xs, ys)\n```\n\nSee the [repository for the experiments in the HolE paper](https://github.com/mnick/holographic-embeddings) for an extensive example how to use this library.\n\nThe different available buildings blocks are described in more detail in the following:\n\n### Model\n\nInstantiating a model, e.g. HolE\n```python\nmodel = HolE(\n    self.shape,\n    self.args.ncomp,\n    init=self.args.init,\n    rparam=self.args.rparam\n)\n```\n\n### Trainer\n\nscikit-kge supports two basic ways to train models: \n\n##### StochasticTrainer (skge.base.StochasticTrainer)\nTrains a model with logistic loss function\n```python\ntrainer = StochasticTrainer(\n    model,\n    nbatches=100,\n    max_epochs=500,\n    post_epoch=[self.callback],\n    learning_rate=0.1\n)\nself.trainer.fit(xs, ys)\n```\n##### PairwiseStochasticTrainer (skge.base)\nTo train a model with pairwise ranking loss\n```python\ntrainer = PairwiseStochasticTrainer(\n    model,\n    nbatches=100,\n    max_epochs=500,\n    post_epoch=[self.callback],\n    learning_rate=0.1,\n    margin=0.2,\n    af=af.Sigmoid\n)\nself.trainer.fit(xs, ys)\n```\n\n### Parameter Update\nscitkit-kge supports different methods to update the parameters of a model via\nthe `param_update` keyword of `StochasticTrainer` and `PairwiseStochasticTrainer`.\n\nFor instance,\n```python\nfrom skge.param import AdaGrad\n\ntrainer = StochasticTrainer(\n    ...,\n    param_update=AdaGrad,\n    ...\n)\n```\nuses `AdaGrad` to update the parameter. \n\nAvailable parameter update methods are\n##### SGD (skge.param.SGD)\nBasic stochastic gradient descent. Only parameter is the learning rate.\n\n##### AdaGrad (skge.param.AdaGrad)\nAdaGrad method of [Duchi et al., 2011](http://jmlr.org/papers/volume12/duchi11a/duchi11a.pdf). Automatically adapts learning rate based on gradient history. Only parameter is the initial learning rate.\n\n### Sampling\nsckit-kge implements different strategies to sample negative examples.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmnick%2Fscikit-kge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmnick%2Fscikit-kge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmnick%2Fscikit-kge/lists"}