History of wikidata5m
The changes to the source code of this entry in the repository, newest first, each with the differences it made to the entry's files. They are also listed on GitLab.
[entries] Add the date when each entry was added, and remove icon_hash beff7c9
The dates are those of the commits that first added the entries' files (2020-08-11 for the entries of the initial commit); renamed entries keep the date of their first name. Changed: none
diff --git a/entries/wikidata5m/__init__.py b/entries/wikidata5m/__init__.py
index 6acf02a..02c00f3 100644
--- a/entries/wikidata5m/__init__.py
+++ b/entries/wikidata5m/__init__.py
@@ -39,7 +39,7 @@ url = ['https://deepgraphlearning.github.io/project/wikidata5m',
'https://doi.org/10.5281/zenodo.5546383']
citation = [('X. Wang, T. Gao, Z. Zhu, Z. Zhang, Z. Liu, J. Li, J. Tang, "KEPLER: A Unified Model for Knowledge Embedding and Pre-trained Language Representation." Transactions of the Association for Computational Linguistics 9, 176-194 (2021)',
'https://doi.org/10.1162/tacl_a_00360')]
-icon_hash = None
+date_added = '2026-10-28'
upstream_license = ("CC BY 4.0", "https://creativecommons.org/licenses/by/4.0/")
# The Zenodo record of the transductive split (published once)
upstream_prefix = 'https://zenodo.org/records/5546383/files'
[entries] Prefix the properties in the descriptions with (Node), (Edge) or (Graph) bc3dbbd
The lists of properties at the end of the descriptions marked edge properties with "Edge" but left node properties unmarked, or grouped them in "Nodes: `a`, ...; `b`, ..." items, so the kind of a property was often unclear. Every item now starts with (Node), (Edge) or (Graph), followed by the property names, a colon and the explanation, one item per property or group of properties; qualifications (kinds of nodes, networks) follow the names in parentheses. Properties that were only named got a short explanation, and a few items that named the wrong kind of property were corrected.
diff --git a/entries/wikidata5m/__init__.py b/entries/wikidata5m/__init__.py
index a50a07c..6acf02a 100644
--- a/entries/wikidata5m/__init__.py
+++ b/entries/wikidata5m/__init__.py
@@ -29,11 +29,11 @@ The triples are given in the "transductive" split of the benchmark (the same ent
The network has the following properties:
-- `wikidata_id`: the Wikidata identifier of the entity, e.g. `Q42`.
-- `name`: the name of the entity (its first alias in the dataset, usually its English label).
-- Edge `relation`: the Wikidata property of the relation, e.g. `P31`.
-- Edge `relation_name`: the name of the relation, e.g. `instance of`.
-- Edge `split`: the set of the benchmark the triple belongs to: `train`, `valid` or `test`."""
+- (Node) `wikidata_id`: the Wikidata identifier of the entity, e.g. `Q42`.
+- (Node) `name`: the name of the entity (its first alias in the dataset, usually its English label).
+- (Edge) `relation`: the Wikidata property of the relation, e.g. `P31`.
+- (Edge) `relation_name`: the name of the relation, e.g. `instance of`.
+- (Edge) `split`: the set of the benchmark the triple belongs to: `train`, `valid` or `test`."""
tags = ['Informational', 'Relatedness', 'Unweighted', 'Multigraph', 'Metadata']
url = ['https://deepgraphlearning.github.io/project/wikidata5m',
'https://doi.org/10.5281/zenodo.5546383']
[entries] New entry: wikidata5m 33b6846
diff --git a/entries/wikidata5m/__init__.py b/entries/wikidata5m/__init__.py
new file mode 100644
index 0000000..a50a07c
--- /dev/null
+++ b/entries/wikidata5m/__init__.py
@@ -0,0 +1,129 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2026 Tiago de Paula Peixoto <tiago@skewed.de>
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Affero General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Affero General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import pyarrow
+import pyarrow.csv
+import pyarrow.compute as pc
+
+from .. import *
+
+title = "Wikidata knowledge graph (Wikidata5M, 2019)"
+description = """A knowledge graph of the entities of Wikidata that have a page in the English Wikipedia, from the Wikidata5M dataset, made for the KEPLER model of knowledge embedding and language representation, and used as a benchmark for link prediction. Each node is an entity of Wikidata (e.g. a person, a place, a work or a concept) that has a Wikipedia page, and a directed edge from entity A to entity B is a statement (A, relation, B) of Wikidata between two such entities, with one of 822 relations (Wikidata properties, e.g. `P31`, "instance of", or `P27`, "country of citizenship"). The data come from the Wikidata dump of 2019-07-31 and the English Wikipedia dump of 2019-08-01; the entities without a Wikipedia page, and those with few statements, were left out by the authors.
+
+The triples are given in the "transductive" split of the benchmark (the same entities in the training, validation and test sets), and all of them are included here, with the set as an edge property. The Wikipedia texts of the entities, also part of the dataset, are not included; the "inductive" split, with the same triples split by entity, is also left out. A larger knowledge graph of Wikidata of 2015 is in the entry `ogbl_wikikg2`, and the complete Wikidata in `wikidata`.
+
+The network has the following properties:
+
+- `wikidata_id`: the Wikidata identifier of the entity, e.g. `Q42`.
+- `name`: the name of the entity (its first alias in the dataset, usually its English label).
+- Edge `relation`: the Wikidata property of the relation, e.g. `P31`.
+- Edge `relation_name`: the name of the relation, e.g. `instance of`.
+- Edge `split`: the set of the benchmark the triple belongs to: `train`, `valid` or `test`."""
+tags = ['Informational', 'Relatedness', 'Unweighted', 'Multigraph', 'Metadata']
+url = ['https://deepgraphlearning.github.io/project/wikidata5m',
+ 'https://doi.org/10.5281/zenodo.5546383']
+citation = [('X. Wang, T. Gao, Z. Zhu, Z. Zhang, Z. Liu, J. Li, J. Tang, "KEPLER: A Unified Model for Knowledge Embedding and Pre-trained Language Representation." Transactions of the Association for Computational Linguistics 9, 176-194 (2021)',
+ 'https://doi.org/10.1162/tacl_a_00360')]
+icon_hash = None
+upstream_license = ("CC BY 4.0", "https://creativecommons.org/licenses/by/4.0/")
+# The Zenodo record of the transductive split (published once)
+upstream_prefix = 'https://zenodo.org/records/5546383/files'
+TRIPLES = 'wikidata5m_transductive.tar.gz'
+# The names of the entities and relations, only published on Dropbox (the
+# link of the project page)
+ALIAS = 'wikidata5m_alias.tar.gz'
+alias_url = 'https://www.dropbox.com/s/lnbhc8yuhit4wm5/wikidata5m_alias.tar.gz?dl=1'
+files = [(tuple(f"{TRIPLES}:wikidata5m_transductive_{s}.txt"
+ for s in ("train", "valid", "test")) +
+ (f"{ALIAS}:wikidata5m_entity.txt", f"{ALIAS}:wikidata5m_relation.txt"),
+ None, None)]
+
+def fetch_upstream(force=False):
+ name = __name__.split(".")[-1]
+ fetch_upstream_files(name, upstream_prefix, [(TRIPLES, None, None)], force)
+ if not force and upstream_file_exists(name, ALIAS):
+ return
+ with open_url(alias_url) as f:
+ head = f.read(1 << 10)
+ check_not_html(ALIAS, head)
+ with open_upstream_file(name, ALIAS, "wb") as output:
+ output.write(head)
+ shutil.copyfileobj(f, output)
+
+def read_aliases(name, fname):
+ "The first alias of each identifier."
+ names = {}
+ with open_upstream_file(name, fname, "r") as f:
+ for line in f:
+ x = line.rstrip("\n").split("\t")
+ names[x[0]] = x[1] if len(x) > 1 else ""
+ return names
+
+def categorical_ep(g, codes, labels, name):
+ "Store the integer codes `codes` of `labels` as the string property `name`."
+ c = g.new_ep("int", vals=codes)
+ p = g.new_ep("string")
+ map_property_values(c, p, lambda i: labels[i])
+ g.ep[name] = p
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+ name = __name__.split(".")[-1]
+ for fnames, alt, fmt in files:
+ if alts is not None and alt not in alts:
+ continue
+ tables = []
+ for fname in fnames[:3]:
+ with open_upstream_file(name, fname, "rb") as f:
+ # <head> <relation> <tail>
+ tables.append(pyarrow.csv.read_csv(
+ f,
+ read_options=pyarrow.csv.ReadOptions(column_names=["h", "r", "t"]),
+ parse_options=pyarrow.csv.ParseOptions(delimiter="\t",
+ quote_char=False),
+ convert_options=pyarrow.csv.ConvertOptions(
+ column_types={c: pyarrow.string() for c in "hrt"})))
+ sizes = [len(t) for t in tables]
+ t = pyarrow.concat_tables(tables)
+ del tables
+ ends = pyarrow.chunked_array(t.column("h").chunks + t.column("t").chunks)
+ ids = pc.unique(ends)
+ del ends
+ ids = pc.take(ids, pc.sort_indices(ids))
+ g = Graph(directed=True)
+ g.add_vertex(len(ids))
+ g.add_edge_list(numpy.column_stack(
+ [pc.index_in(t.column("h"), value_set=ids).to_numpy(),
+ pc.index_in(t.column("t"), value_set=ids).to_numpy()]))
+ rel = t.column("r").combine_chunks().dictionary_encode()
+ del t
+ rlabels = rel.dictionary.to_pylist()
+ codes = rel.indices.to_numpy()
+ categorical_ep(g, codes, rlabels, "relation")
+ rnames = read_aliases(name, fnames[4])
+ categorical_ep(g, codes, [rnames.get(r, "") for r in rlabels], "relation_name")
+ del codes, rel
+ g.ep.split = g.new_ep("string", vals=sum([[s] * n for s, n in
+ zip(("train", "valid", "test"), sizes)], []))
+ ids = ids.to_pylist()
+ g.vp.wikidata_id = g.new_vp("string", vals=ids)
+ enames = read_aliases(name, fnames[3])
+ g.vp.name = g.new_vp("string", vals=[enames.get(x, "") for x in ids])
+ yield alt, g