logo Netzschleuder network catalog, repository, and centrifuge

History of freebase_fb15k

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] New entry: freebase_fb15k by Tiago de Paula Peixoto 727cd17
diff --git a/entries/freebase_fb15k/__init__.py b/entries/freebase_fb15k/__init__.py
new file mode 100644
index 0000000..f3cd3fa
--- /dev/null
+++ b/entries/freebase_fb15k/__init__.py
@@ -0,0 +1,85 @@
+#! /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/>.
+
+
+
+from .. import *
+
+
+title = "Freebase knowledge graph benchmarks (FB15k and FB15k-237, 2013-2015)"
+description = """Two subsets of the Freebase knowledge base, widely used as benchmarks for knowledge graph completion (link prediction):
+
+- `fb15k`: the FB15k dataset of Bordes et al. (2013), with the 14,951 entities of Freebase that are also present in the Wikilinks database and have at least 100 mentions in Freebase, and the 1,345 relations between them that have at least 100 instances (592,213 triples); relations that merely reverse another one (e.g. the reverse of `/people/person/nationality`) were removed.
+- `fb15k_237`: the FB15k-237 dataset of Toutanova and Chen (2015), a subset of FB15k from which near-duplicate and inverse relations were removed (as well as the triples of the validation and test sets that link entities directly linked in the training set), keeping 237 relations and 14,541 entities (310,116 triples). The textual mentions of pairs of entities in the ClueWeb12 corpus, distributed with this dataset, are left out.
+
+Each node is an entity (e.g. a person, a place, a film or a profession), identified by its Freebase machine identifier (mid); the data do not include the names of the entities. A directed edge from entity A to entity B is a triple (A, relation, B), e.g. that a person has a given profession. Some relations of Freebase are two-hop relations, in which an intermediate entity (a "compound value type") was collapsed out (e.g. `/film/film/release_date_s./film/film_regional_release_date/film_release_region`). Pairs of entities may be connected by several edges with different relations.
+
+The triples are divided into training, validation and test sets by the benchmarks; all of them are included, and the set is given as an edge property.
+
+The networks have the following properties:
+
+- `mid`: the Freebase identifier of the entity, e.g. `/m/027rn`.
+- Edge `relation`: the Freebase relation, e.g. `/people/person/profession`.
+- Edge `split`: the set of the benchmark the triple belongs to: `train`, `valid` or `test`."""
+tags = ['Informational', 'Relatedness', 'Unweighted', 'Multigraph', 'Metadata']
+url = ['https://web.archive.org/web/20221204060113/https://everest.hds.utc.fr/doku.php?id=en:transe',
+       'https://www.microsoft.com/en-us/download/details.aspx?id=52312']
+citation = [('A. Bordes, N. Usunier, A. Garcia-DurĂ¡n, J. Weston, O. Yakhnenko, "Translating Embeddings for Modeling Multi-relational Data." Advances in Neural Information Processing Systems 26, 2787-2795 (2013)', 'https://papers.nips.cc/paper/2013/hash/1cecc7a77928ca8133fa24680a88d2f9-Abstract.html'),
+            ('K. Toutanova, D. Chen, "Observed versus latent features for knowledge base and text inference." Proceedings of the 3rd Workshop on Continuous Vector Space Models and their Compositionality, 57-66 (2015)', 'https://doi.org/10.18653/v1/W15-4007'),
+            ('K. Toutanova, D. Chen, P. Pantel, H. Poon, P. Choudhury, M. Gamon, "Representing Text for Joint Embedding of Text and Knowledge Bases." Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing, 1499-1509 (2015)', 'https://doi.org/10.18653/v1/D15-1174')]
+icon_hash = None
+upstream_license = ('CC BY 2.5 (fb15k); Microsoft Research Data License Agreement, for non-commercial or research purposes only (fb15k_237)', None)
+upstream_prefix = None
+
+archived_files = {
+    'fb15k.tgz': 'https://web.archive.org/web/20221209122412id_/https://everest.hds.utc.fr/lib/exe/fetch.php?media=en:fb15k.tgz',
+    'FB15K-237.2.zip': 'https://download.microsoft.com/download/8/7/0/8700516A-AB3D-4850-B4BB-805C515AECE1/FB15K-237.2.zip'}
+files = [(tuple(f'fb15k.tgz:FB15k/freebase_mtr100_mte100-{s}.txt'
+                for s in ['train', 'valid', 'test']), 'fb15k', None),
+         (tuple(f'FB15K-237.2.zip:Release/{s}.txt'
+                for s in ['train', 'valid', 'test']), 'fb15k_237', None)]
+
+def fetch_upstream(force=False):
+    return fetch_archived_files(__name__.split(".")[-1], archived_files, force,
+                                tries=3)
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+    global files
+    name = __name__.split(".")[-1]
+    for fnames, alt, fmt in files:
+        if alts is not None and alt not in alts:
+            continue
+        triples = []
+        splits = []
+        for fname, split in zip(fnames, ["train", "valid", "test"]):
+            with open_upstream_file(name, fname, "r") as f:
+                for line in f:
+                    if not line.strip():
+                        continue
+                    h, r, t = line.rstrip("\n").split("\t")
+                    triples.append((h, t, r))
+                    splits.append(split)
+        g = Graph(directed=True)
+        g.vp.mid = g.add_edge_list(triples, hashed=True,
+                                   eprops=[("relation", "string")])
+        g.ep.relation = g.ep["relation"]
+        g.ep.split = g.new_ep("string", vals=splits)
+        yield alt, g