File size: 1,640 Bytes
3970207
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
# Regenerate all datasets and the natural-language tokenizer.
# The outputs are byte-identical to the files shipped in data/ and multi-hop/.
#
# Usage: [PYTHON=python] bash prepare_data.sh   (rewrites the shipped files in place)
# The tokenizer step loads the base "gpt2" tokenizer from the Hugging Face Hub (or the local cache).
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
PYTHON="${PYTHON:-python3}"

# Symbolic two-hop dataset (Sec. 3.1; used in Sec. 3 and Sec. 5.1).
"$PYTHON" data_preparation.py --num-entities 500 --num-relations 50 --out-degree 10 --seed 7

# Symbolic two-hop + three-hop dataset (App. A.2), built from the atoms above.
# manifest.json records --src as given, so keep the paths relative to the repo root.
"$PYTHON" generate_multihop_from_atoms.py \
  --src data/twin_twohop_truood_diff.500.50.10 \
  --out data/twin_23hop_truood_diff.500.50.10 \
  --seed 7 --train-2hop 5000 --train-3hop 5000

# Synthetic natural-language two-hop datasets, direct and reverse formats (Sec. 5.2, App. A.3).
for fmt in direct reverse; do
  "$PYTHON" multi-hop/export_two_graph_dataset.py \
    --output-dir "multi-hop/data/custom/two_graph_${fmt}" --multi-hop-format "${fmt}" \
    --num-entities 200 --num-relations 50 --edges-per-entity 10 --num-hops 2 \
    --num-train-multihop 2000 --num-test-id 1000 --num-test-ood 1000 --seed 42
done

# GPT-2 tokenizer extended with the entity names and relations (with a leading space)
# as added tokens (Sec. 5.2).
"$PYTHON" multi-hop/build_graph_tokenizer.py --base-tokenizer gpt2 --num-relations 200 \
  --output-dir multi-hop/tokenizers/gpt2_names_relations