# WHALE — IEEE Big Data Artifacts

<https://files.dice-research.org/datasets/WHALE/IEEE_Big_Data/>

This release contains the knowledge-graph dumps, the trained Clifford-algebra
knowledge-graph-embedding (KGE) models, and the benchmark evaluation suite used in the
WHALE IEEE Big Data submission. All models were trained with
[dice-embeddings](https://github.com/dice-group/dice-embeddings) (`dicee`) on the
Noctua 2 cluster (PC2, Paderborn University).

The headline artifacts are two KGE models trained end-to-end on *complete*
knowledge graphs rather than on the usual sampled benchmarks:

| Model | Knowledge graph | Entities | Relations | Train triples | Parameters |
|---|---|---:|---:|---:|---:|
| DBpedia | DBpedia snapshot 2022-12 (full) | 156,456,361 | 13,943 | 843,684,312 | ~40.06 B |
| Wikidata | Wikidata `latest-truthy`, literals removed | 396,400,379 | 2,855 | 1,397,639,131 | ~101.48 B |

Both are trained at the **baseline Clifford signature `(p=0, q=1, r=0)`**, i.e. in
`Cl_{0,1,0}(R^d)` — the degenerate-free complex case, which is the DeCaL reduction
that coincides with ComplEx. Embedding dimension is 256 in every run.

---

## 1. Directory layout

```
IEEE_Big_Data/
├── dbpedia/
│   ├── dbpedia-snapshot-2022-12.ttl.zst        11.8 GiB   raw KG dump
│   └── dbpedia-snapshot-2022-12.tar.gz         76.5 GiB   trained model
├── wikidata/
│   ├── latest-truthy-clean.nt.gz               10.0 GiB   raw KG dump
│   └── latest-truthy-clean.tar.gz             618.6 GiB   trained model
└── evaluation/
    ├── DBpedia50k.zip                         454.7 KiB   benchmark dataset
    ├── DBpedia50k_models.zip                  237.3 MiB   10 signature models
    ├── DBpedia_EN_FR_100K.zip                   8.8 MiB   benchmark dataset
    ├── DBpedia_EN_FR_100K_models.zip            3.3 GiB   10 signature models
    ├── Wikidata5M.zip                          96.1 MiB   benchmark dataset
    └── Wikidata5M_models.zip                   81.7 GiB   10 signature models
```

> **Download size warning.** `wikidata/latest-truthy-clean.tar.gz` expands to roughly
> **830 GB** on disk, and `dbpedia/dbpedia-snapshot-2022-12.tar.gz` to roughly **191 GB**.
> Check free space before extracting. If you only need the embeddings and not the
> optimizer/checkpoint state, extract selected members (see §4).

---

## 2. `dbpedia/`

### 2.1 `dbpedia-snapshot-2022-12.ttl.zst` — 11.8 GiB

The complete DBpedia snapshot 2022-12. Decompress with:

```bash
zstd -d dbpedia-snapshot-2022-12.ttl.zst -o dbpedia-snapshot-2022-12.ttl
```

### 2.2 `dbpedia-snapshot-2022-12.tar.gz` — 76.5 GiB

The trained model at signature `(p=0, q=1, r=0)`. 

**Files inside the archive:**

| File | Size | What it is |
|---|---:|---|
| `configuration.json` | 2.1 KB | The complete, resolved `dicee` run configuration — every hyperparameter, trainer setting and input path as actually used. This is what `KGE(path=...)` reads to reconstruct the model class and its `(p, q, r)` signature. |
| `report.json` | 263 B | Run summary: `num_entities`, `num_relations`, `NumParam`, `EstimatedSizeMB`, and total `Runtime` in seconds. |
| `model.pt` | 150 GiB | The trained weights — a PyTorch `state_dict` holding the entity embedding table (`156,456,361 × 256`) and the relation embedding table (`13,943 × 256`). This is the artifact you load for inference. It is the materialised (unsharded) form of the FSDP training state. |
| `entity_to_idx.csv` | 11 GiB | Entity vocabulary: row *i* maps integer index *i* to the entity's surface string. 156,456,361 rows. Needed to translate an IRI into a row of the embedding table and back. Format is `,entity` with a leading index column. |
| `relation_to_idx.csv` | 641 KB | Relation vocabulary, same layout as above. 13,943 rows. |
| `train_set.npy` | 9.5 GiB | The full training set as a NumPy array of shape `(843,684,312, 3)`, dtype `int32` — one row per triple, holding `(head_idx, relation_idx, tail_idx)` in the index space defined by the two `*_to_idx.csv` files. |
| `memory_map_train_set.npy` | 9.5 GiB | The same triple array written as a raw `np.memmap` (no `.npy` header), so training workers can page it in from disk instead of holding 843 M triples in RAM. |
| `memory_map_details.json` | 132 B | The header the memmap does not carry: `shape = [843684312, 3]`, `dtype = "<i4"`, plus `num_entities` and `num_relations`. Required to reopen `memory_map_train_set.npy` correctly. |
| `epoch_losses.csv` | 13 KB | Per-epoch mean training loss, 500 rows (`,EpochLoss`). Use it to plot or verify the convergence curve. |

---

## 3. `wikidata/`

### 3.1 `latest-truthy-clean.nt.gz` — 10.0 GiB

The Wikidata `latest-truthy` dump with **all literals removed**, leaving only
entity-to-entity statements; N-Triples, gzip compressed. Uncompressed, it is ~186 GB
(the untouched `latest-truthy` dump is ~1.06 TB, which is why the cleaned variant is the
one published here). This is the input to the training run.

```
<http://wikiba.se/ontology#Dump> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Dataset> .
```

### 3.2 `latest-truthy-clean.tar.gz` — 618.6 GiB

The trained model at signature `(p=0, q=1, r=0)`.

**Files inside the archive:**

| File | Size | What it is |
|---|---:|---|
| `configuration.json` | 2.2 KB | The resolved `dicee` run configuration, including the `torchFSDP` kwargs (bfloat16, CPU optimizer offload, per-epoch checkpointing) that this run needed to fit a 101 B-parameter model. |
| `report.json` | 185 B | Run summary. For this run it carries `num_entities`, `num_relations` and the experiment folder only — `NumParam`/`Runtime` were not written, because the run was resumed from FSDP checkpoints rather than finishing in a single process. |
| `model.pt` | 190 GiB | The materialised (unsharded) `state_dict`: entity table `396,400,379 × 256` and relation table `2,855 × 256`, in bfloat16. Produced from the FSDP shards by `dicee`'s offline materialisation step. This is the file to load for inference. |
| `entity_to_idx.csv` | 23 GiB | Entity vocabulary, 396,400,379 rows, `,entity` layout. Maps embedding-table row index ↔ entity IRI. |
| `relation_to_idx.csv` | 139 KB | Relation vocabulary, 2,855 rows, same layout. |
| `train_set.npy` | 16 GiB | Training triples as a NumPy array of shape `(1,397,639,131, 3)`, dtype `int32`. |
| `memory_map_train_set.npy` | 16 GiB | The same array as a raw `np.memmap` for out-of-core training. |
| `memory_map_details.json` | 132 B | Shape/dtype header for the memmap: `[1397639131, 3]`, `"<i4"`, plus entity and relation counts. |
| `fsdp_shard_checkpoint/` | 568 GiB | The raw distributed training state, 18 files (detailed below). Keep it if you want to **resume** training or re-materialise `model.pt`; delete it if you only need inference. |

**Inside `fsdp_shard_checkpoint/`:**

| File | Size | What it is |
|---|---:|---|
| `meta.json` | 2.2 KB | Checkpoint manifest: `epoch` (100), `world_size` (8), `num_entities`, `embedding_dim` (256), and the full per-epoch `loss_history` array. This is the run's loss curve — the Wikidata directory has no separate `epoch_losses.csv`. |
| `entity_shard_rank{0..7}_of_8.pt` | 71 GiB each | The entity embedding table split across the 8 FSDP ranks — rank *k* holds its contiguous slice of the 396 M × 256 table plus the matching Adam moments. Concatenated in rank order they reconstitute the full table. |
| `rank_state_rank{0..7}_of_8.pt` | 716 KB each | Per-rank training bookkeeping: RNG state, dataloader/sampler position and optimizer step counter, so a resumed run continues from the exact same point. |
| `dense_state.pt` | 2.8 MB | The non-sharded ("dense") parameters replicated on every rank — the 2,855 × 256 relation table and the algebra coefficient parameters — plus their optimizer state. |

---

## 4. `evaluation/`

Three standard link-prediction benchmarks, each paired with a sweep of **ten Clifford
signatures** trained under identical hyperparameters.

### 4.1 Benchmark datasets

| Archive | Contents | Train | Valid | Test | Entities | Relations | Triple format |
|---|---|---:|---:|---:|---:|---:|---|
| `DBpedia50k.zip` | `DBpedia50k/{train,valid,test}.txt` | 32,203 | 123 | 2,095 | 24,624 | 351 | tab-separated surface labels (`$_(film)  starring  Goldie_Hawn`) |
| `DBpedia_EN_FR_100K.zip` | `datasets/EN_FR_100K/{train,test}.txt` | 402,446 | — | 165,446 | 200,000 | 516 | full IRIs; OpenEA v1.1 EN-FR 100K cross-lingual DBpedia split (no validation file) |
| `Wikidata5M.zip` | `Wikidata5M/{train,valid,test}.txt` | 20,614,279 | 5,163 | 5,133 | 4,594,485 | 822 | Wikidata Q/P identifiers (`Q1  P1343  Q602358`); transductive split |

### 4.2 Model archives

Each `*_models.zip` unpacks to `models/<DATASET>_FSDP_signatures/` holding one run
directory per signature, named
`DeCaL_torchFSDP_<DATASET>_p<P>_q<Q>_r<R>`, plus a combined loss plot:

```
models/Wikidata5M_FSDP_signatures/
├── epoch_loss_by_signature_log.png           loss curves of all 10 signatures, log scale
├── DeCaL_torchFSDP_Wikidata5M_p0_q0_r0/
├── DeCaL_torchFSDP_Wikidata5M_p0_q0_r1/
├── DeCaL_torchFSDP_Wikidata5M_p0_q0_r3/
├── DeCaL_torchFSDP_Wikidata5M_p0_q1_r0/
├── DeCaL_torchFSDP_Wikidata5M_p0_q1_r2/
├── DeCaL_torchFSDP_Wikidata5M_p0_q3_r4/
├── DeCaL_torchFSDP_Wikidata5M_p1_q1_r1/
├── DeCaL_torchFSDP_Wikidata5M_p1_q2_r4/
├── DeCaL_torchFSDP_Wikidata5M_p1_q3_r3/
└── DeCaL_torchFSDP_Wikidata5M_p2_q2_r3/
```

Each run directory contains the same core files described in §2.2 (`configuration.json`,
`report.json`, `model.pt`, `entity_to_idx.csv`, `relation_to_idx.csv`, `train_set.npy`,
`memory_map_train_set.npy`, `memory_map_details.json`, `epoch_losses.csv`) plus the
evaluation-specific ones:

| File | What it is |
|---|---|
| `valid_set.npy`, `test_set.npy` | Held-out splits as `int32` `(n, 3)` index arrays, in the same vocabulary space as `train_set.npy`. |
| `er_vocab.p` | Pickled `dict` mapping `(head, relation) → [tails]` over all splits. Used as the filter set for filtered link-prediction ranking (tail direction). |
| `re_vocab.p` | Pickled `dict` mapping `(relation, tail) → [heads]` — the head-direction filter set. |
| `ee_vocab.p` | Pickled `dict` mapping `(head, tail) → [relations]`, used for relation-prediction and for constructing negatives. |
| `eval_report.json` | Filtered test-set link-prediction metrics: `MRR`, `H@1`, `H@3`, `H@10`. |
| `fsdp_shard_checkpoint/` | Present in the Wikidata5M and EN_FR_100K runs (4 ranks there, not 8): `meta.json`, `dense_state.pt`, `entity_shard_rank{0..3}_of_4.pt`, `rank_state_rank{0..3}_of_4.pt` — same semantics as §3.2. |
| `model_dense.pt`, `model_entity_shard_{0..3}.pt` | Intermediate per-shard materialisation outputs kept alongside the merged `model.pt`. |

Evaluation-run hyperparameters are shared across all signatures: `DeCaL`,
`embedding_dim = 256`, `num_epochs = 500`, Adam at `lr = 0.1`, `FixedNegSample` with
`neg_ratio = 2`, `random_seed = 1`, `eval_model = "test"`. Trainer is `torchFSDP`
(bfloat16, CPU optimizer offload) for Wikidata5M and EN_FR_100K, and `torchCPUTrainer`
for the small DBpedia50k runs. `batch_size` is 500,000 except Wikidata5M, which uses
3,800,000.

---

## 5. Using the artifacts

### Download

```bash
BASE=https://files.dice-research.org/datasets/WHALE/IEEE_Big_Data
wget -c $BASE/evaluation/DBpedia50k.zip
wget -c $BASE/evaluation/DBpedia50k_models.zip
# large ones — use -c so an interrupted transfer resumes
wget -c $BASE/dbpedia/dbpedia-snapshot-2022-12.tar.gz
```

### Extract

```bash
tar -xzf dbpedia-snapshot-2022-12.tar.gz          # -> dbpedia-snapshot-2022-12/
tar -I 'pigz -d' -xf latest-truthy-clean.tar.gz   # -> latest-truthy-clean_100_000/
```

Inference only, skipping the 568 GiB of FSDP shards:

```bash
tar -I 'pigz -d' -xf latest-truthy-clean.tar.gz \
  --exclude='*/fsdp_shard_checkpoint/*'
```

### Load a model

Loading these run directories requires `dicee` (dice-embeddings), the framework the
models were trained with — <https://github.com/dice-group/dice-embeddings>.

```bash
# from PyPI — GPU
pip install dicee

# from PyPI — CPU-only
pip install dicee --extra-index-url https://download.pytorch.org/whl/cpu

# or from source, if you want the exact training code and the export/materialise scripts
git clone https://github.com/dice-group/dice-embeddings
cd dice-embeddings && pip install -e .
```

```python
from dicee import KGE

model = KGE(path="dbpedia-snapshot-2022-12")     # any run directory in this release
print(model)

# nearest neighbours / scoring
model.predict_topk(h=["http://dbpedia.org/resource/Berlin"],
                   r=["http://dbpedia.org/ontology/country"],
                   topk=10)
```

`KGE` reads `configuration.json` to rebuild the model class and signature, `model.pt`
for the weights, and the two `*_to_idx.csv` files for the vocabularies — those four are
the minimum needed for inference.

> The DBpedia and Wikidata entity tables are 150 GiB and 190 GiB respectively. Loading
> either one whole requires a machine with comparable RAM; for smaller machines, read
> the vectors you need directly out of `model.pt` by index, or use the RDF export.

### Read the triple arrays directly

```python
import json, numpy as np

meta = json.load(open("latest-truthy-clean_100_000/memory_map_details.json"))
triples = np.memmap("latest-truthy-clean_100_000/memory_map_train_set.npy",
                    dtype=meta["dtype"], mode="r", shape=tuple(meta["shape"]))
print(triples.shape, triples[0])   # (1397639131, 3) [head_idx rel_idx tail_idx]
```
---

## 6. Reproducing the runs

```bash
git clone https://github.com/dice-group/dice-embeddings
cd dice-embeddings && pip install -e .

dicee --path_single_kg dbpedia-snapshot-2022-12.ttl.zst \
      --model Keci --p 0 --q 1 --embedding_dim 256 \
      --trainer torchFSDP --num_epochs 500 --batch_size 500000 --lr 0.05 \
      --scoring_technique NegSample --neg_ratio 2 --random_seed 1
```

The exact, fully resolved arguments for every run are in that run's
`configuration.json`; passing those values reproduces the run bit-for-bit given the same
number of FSDP ranks (`deterministic: true`, `random_seed: 1`).
