Download evaluate.py from vicentim/sair-modular-v1: direct link, hf CLI and curl.
- Browser
- Download file 697 Bytes
-
https://huggingface.co/vicentim/sair-modular-v1/resolve/main/evaluate.py
- Command line
-
hf download hf://vicentim/sair-modular-v1/evaluate.py
-
curl -L -o evaluate.py https://huggingface.co/vicentim/sair-modular-v1/resolve/main/evaluate.py
697 Bytes
| import torch | |
| from model import SAIRLatencyModel | |
| from tokenizer import encode_input | |
| model=SAIRLatencyModel() | |
| model.load_state_dict( | |
| torch.load( | |
| "sair_latency_v1.pt" | |
| ) | |
| ) | |
| model.eval() | |
| tests=[ | |
| (123456789,987654321,97), | |
| (999999999,888888888,101) | |
| ] | |
| for a,b,p in tests: | |
| x=torch.tensor( | |
| [ | |
| encode_input( | |
| a, | |
| b, | |
| p, | |
| 20 | |
| ) | |
| ] | |
| ) | |
| with torch.no_grad(): | |
| result=model(x) | |
| digits=torch.argmax( | |
| result, | |
| dim=2 | |
| ) | |
| print( | |
| "Input:", | |
| a,b,p | |
| ) | |
| print( | |
| "Prediction:", | |
| digits.tolist() | |
| ) |