fix(upload): cast genre to ClassLabel; align PIMT forward with fused labels and publication metrics
Browse files- src/pino/upload_data.py +5 -1
src/pino/upload_data.py
CHANGED
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
| 2 |
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
from datasets import DatasetDict, load_dataset
|
| 6 |
|
| 7 |
|
| 8 |
def split_and_upload_dataset(jsonl_path: str, repo_id: str) -> None:
|
|
@@ -14,6 +14,10 @@ def split_and_upload_dataset(jsonl_path: str, repo_id: str) -> None:
|
|
| 14 |
print(f"Loading raw production corpus from {jsonl_path}...")
|
| 15 |
raw_dataset = load_dataset("json", data_files=jsonl_path, split="train")
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
print("Executing stratified 80/20 train/validation split...")
|
| 18 |
split_data = raw_dataset.train_test_split(
|
| 19 |
test_size=0.2,
|
|
|
|
| 2 |
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
from datasets import ClassLabel, DatasetDict, load_dataset
|
| 6 |
|
| 7 |
|
| 8 |
def split_and_upload_dataset(jsonl_path: str, repo_id: str) -> None:
|
|
|
|
| 14 |
print(f"Loading raw production corpus from {jsonl_path}...")
|
| 15 |
raw_dataset = load_dataset("json", data_files=jsonl_path, split="train")
|
| 16 |
|
| 17 |
+
print("Casting genre column to ClassLabel for stratification...")
|
| 18 |
+
genres = sorted(set(raw_dataset["genre"]))
|
| 19 |
+
raw_dataset = raw_dataset.cast_column("genre", ClassLabel(names=genres))
|
| 20 |
+
|
| 21 |
print("Executing stratified 80/20 train/validation split...")
|
| 22 |
split_data = raw_dataset.train_test_split(
|
| 23 |
test_size=0.2,
|