Download load_example.py from brkdrd/simloop: direct link, hf CLI and curl.
- Browser
- Download file 527 Bytes
-
https://huggingface.co/brkdrd/simloop/resolve/main/load_example.py
- Command line
-
hf download hf://brkdrd/simloop/load_example.py
-
curl -L -o load_example.py https://huggingface.co/brkdrd/simloop/resolve/main/load_example.py
527 Bytes
| """Minimal loader. Requires: torch, tokenizers.""" | |
| import torch | |
| from tokenizers import Tokenizer | |
| from simloop.stack import StackConfig, StackedLoop | |
| ck = torch.load("model.pt", map_location="cpu", weights_only=False) | |
| model = StackedLoop(StackConfig(**ck["model_cfg"])) | |
| model.load_state_dict(ck["model"]) | |
| model.eval() | |
| tok = Tokenizer.from_file("tokenizer.json") | |
| ids = torch.tensor([tok.encode("The capital of France is").ids]) | |
| with torch.no_grad(): | |
| logits = model(ids, K=1) | |
| print(tok.decode([int(logits[0, -1].argmax())])) | |