MCPcopy Create free account
hub / github.com/Pints-AI/1.5-Pints / lazy_load_file

Function lazy_load_file

tokenizer/convert/convert.py:884–895  ·  view source on GitHub ↗
(path: Path)

Source from the content-addressed store, hash-verified

882
883@functools.lru_cache(maxsize=None)
884def lazy_load_file(path: Path) -> ModelPlus:
885 fp = open(path, 'rb')
886 first8 = fp.read(8)
887 fp.seek(0)
888 if first8[:2] == b'PK':
889 # A zip file, i.e. PyTorch format
890 return lazy_load_torch_file(fp, path)
891 elif struct.unpack('<Q', first8)[0] < 16 * 1024 * 1024:
892 # Probably safetensors
893 return lazy_load_safetensors_file(fp, path)
894 else:
895 raise ValueError(f"unknown format: {path}")
896
897
898In = TypeVar('In')

Callers 2

load_some_modelFunction · 0.85
mainFunction · 0.85

Calls 2

lazy_load_torch_fileFunction · 0.85

Tested by

no test coverage detected