Add single-dataset loading example
Browse files
README.md
CHANGED
|
@@ -52,32 +52,44 @@ The underlying recommendation datasets are public datasets from their original s
|
|
| 52 |
|
| 53 |
Please consult the original dataset sources and their terms before using these files.
|
| 54 |
|
| 55 |
-
## Loading
|
| 56 |
|
| 57 |
-
The
|
| 58 |
|
| 59 |
```python
|
|
|
|
| 60 |
import json
|
| 61 |
import numpy as np
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
-
|
|
|
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
)
|
| 79 |
```
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
## Citation
|
| 82 |
|
| 83 |
If you use these processed artifacts, please cite the DIGER paper and the original dataset sources.
|
|
|
|
| 52 |
|
| 53 |
Please consult the original dataset sources and their terms before using these files.
|
| 54 |
|
| 55 |
+
## Loading One Dataset
|
| 56 |
|
| 57 |
+
The three datasets are stored in separate directories. To use only one dataset, download only files from that directory. For example, this loads **Beauty** only and does not download Instruments or Yelp:
|
| 58 |
|
| 59 |
```python
|
| 60 |
+
from huggingface_hub import hf_hub_download
|
| 61 |
import json
|
| 62 |
import numpy as np
|
| 63 |
|
| 64 |
+
repo_id = "junchenfu/diger-processed-data"
|
| 65 |
+
dataset = "beauty"
|
| 66 |
|
| 67 |
+
train_path = hf_hub_download(repo_id=repo_id, repo_type="dataset", filename=f"{dataset}/{dataset}.train.jsonl")
|
| 68 |
+
valid_path = hf_hub_download(repo_id=repo_id, repo_type="dataset", filename=f"{dataset}/{dataset}.valid.jsonl")
|
| 69 |
+
test_path = hf_hub_download(repo_id=repo_id, repo_type="dataset", filename=f"{dataset}/{dataset}.test.jsonl")
|
| 70 |
+
map_path = hf_hub_download(repo_id=repo_id, repo_type="dataset", filename=f"{dataset}/{dataset}.emb_map.json")
|
| 71 |
+
emb_path = hf_hub_download(repo_id=repo_id, repo_type="dataset", filename="beauty/Beauty.emb-llama.npy")
|
| 72 |
|
| 73 |
+
with open(train_path, encoding="utf-8") as f:
|
| 74 |
+
first_train = json.loads(next(f))
|
| 75 |
|
| 76 |
+
with open(map_path, encoding="utf-8") as f:
|
| 77 |
+
emb_map = json.load(f)
|
| 78 |
|
| 79 |
+
emb = np.load(emb_path, mmap_mode="r")
|
| 80 |
+
|
| 81 |
+
print(first_train)
|
| 82 |
+
print(len(emb_map))
|
| 83 |
+
print(emb.shape, emb.dtype)
|
| 84 |
```
|
| 85 |
|
| 86 |
+
For the other datasets, use the corresponding directory and embedding filename:
|
| 87 |
+
|
| 88 |
+
- Instruments: `instruments/Instruments.emb-llama.npy`
|
| 89 |
+
- Yelp: `yelp/Yelp.emb-llama.npy`
|
| 90 |
+
|
| 91 |
+
Use `hf_hub_download(filename="...")` for single-dataset loading. Avoid `snapshot_download` unless you intentionally want to download the full repository.
|
| 92 |
+
|
| 93 |
## Citation
|
| 94 |
|
| 95 |
If you use these processed artifacts, please cite the DIGER paper and the original dataset sources.
|