"""Minimal GPT-2 forward pass in numpy, for the CKIP gpt2-tiny-chinese model (https://huggingface.co/ckiplab/gpt2-tiny-chinese, GPL-3.0). Character-level: each Chinese character is one token of the bert-base-chinese vocabulary. Used to evaluate language-model reranking before porting it to the input methods. """ import json import math import struct import numpy as np CLS, UNK = 101, 100 def load_safetensors(path): with open(path, "rb") as f: n = struct.unpack("