biosum-cuh / examples /load_activations.py
Saria307's picture
Add files using upload-large-folder tool
17c90a7 verified
Raw
History Blame Contribute Delete
765 Bytes
"""Minimal streaming example for Saria307/biosum-cuh activations."""
import numpy as np
from datasets import load_dataset
stream = load_dataset(
"Saria307/biosum-cuh",
"activations",
split="train",
streaming=True,
)
row = next(iter(stream))
length = row["length"]
attn_act = np.asarray(row["attn_act"], dtype=np.float32)[:length]
logit_margin = np.asarray(row["logit_margin"], dtype=np.float32)[:length]
logit_topk = np.asarray(row["logit_topk"], dtype=np.float32)[:length]
labels = np.asarray(row["labels"], dtype=np.int64)
assert attn_act.shape == (length, 4096)
assert logit_margin.shape == (length, 1)
assert logit_topk.shape == (length, 50)
assert labels.shape == (length,)
print(row["activation_id"], row["source_train_index"], length)