FB15k_237
¶
FB15k_237(
split: KG_SPLITS = "train",
base_dir: Optional[str] = None,
pre_transform: Optional[Callable] = None,
transform: Optional[Callable] = None,
)
Bases: _KnowledgeGraphDataset
The FB15K237 dataset from the "Translating Embeddings for Modeling Multi-Relational Data" paper, containing 14,541 entities, 237 relations and 310,116 fact triples.
Each split is a separate graph whose edge_index holds the (head, tail)
entity pairs and edge_type the relation of each triplet. Entity and
relation ids are shared across the three splits, and each graph has
num_nodes set to the total number of entities.
This dataset follows the implementation of PyG.
Note
The original FB15k dataset suffers from major test leakage
through inverse relations, where a large number of test triples could
be obtained by inverting triples in the training set. In order to
create a dataset without this characteristic, FB15k_237
contains a subset of FB15k where inverse relations are removed.
| Split | #nodes | #edges | #relations |
|---|---|---|---|
| train | 14,541 | 272,115 | 237 |
| val | 14,541 | 17,535 | 237 |
| test | 14,541 | 20,466 | 237 |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
split
|
KG_SPLITS
|
The split to load ( |
'train'
|
base_dir
|
Optional[str]
|
Directory where to store dataset files. Default is
in the local directory |
None
|
pre_transform
|
Optional[Callable]
|
A function/transform applied to the graph once, before it is saved. |
None
|
transform
|
Optional[Callable]
|
A function/transform applied to the graph at every access. |
None
|
Example:
from mlx_graphs.datasets import FB15k_237
dataset = FB15k_237(split="train")
>>> FB15k_237(num_graphs=1)
dataset[0]
>>> GraphData(
edge_index(shape=(2, 272115), int32)
edge_type(shape=(272115,), int32)
num_nodes=14541)
References
Source code in mlx_graphs/datasets/knowledge_graph.py
from mlx_graphs.datasets import FB15k_237 · mlx_graphs/datasets/knowledge_graph.py