Build your own GPT-2
Load the GPT-2 weights·2 min

safetensors vs pickle

0 / 3

safetensors exists for a reason: the format it replaced — Python pickle — runs arbitrary code on load. Three quick checks on what you just parsed.

Knowledge check

Why does GPT-2 ship as safetensors instead of a Python pickle?

Knowledge check

A tensor's data_offsets are [begin, end]. Where do its raw bytes live in the file, given a header length N?

Knowledge check

GPT-2's tensors are all F32. How many bytes does the value at wte.weight[0][0] occupy, and how do you read it?