"""Converts the gpt2-tiny-chinese safetensors file to the input method's format. Format (little-endian): "AZLM" magic, uint32 header length, JSON header, then float16 tensors back to back. Header: {"n_layer", "n_head", "n_embd", "vocab", "eps", "tensors": [[name, [shape], offset]]} (offset in float16 elements from the start of the data). Linear weights keep the GPT-2 Conv1D layout [in, out]. The attention mask buffers are dropped. Usage: export_lm.py (standard library only) """ import array import json import struct import sys def main(src, out): cfg = json.load(open(f"{src}/config.json")) with open(f"{src}/model.safetensors", "rb") as f: n = struct.unpack("