Download sample.py from AmauryLC/NanoConte-51M: direct link, hf CLI and curl.
- Browser
- Download file 554 Bytes
-
https://huggingface.co/AmauryLC/NanoConte-51M/resolve/main/sample.py
- Command line
-
hf download hf://AmauryLC/NanoConte-51M/sample.py
-
curl -L -o sample.py https://huggingface.co/AmauryLC/NanoConte-51M/resolve/main/sample.py
554 Bytes
| """Write stories with the trained model saved in out/model.pt. | |
| uv run --with-requirements requirements.txt sample.py | |
| uv run --with-requirements requirements.txt sample.py "The little dog" | |
| """ | |
| import sys | |
| import torch | |
| from train import GPT | |
| model = GPT() | |
| model.load_state_dict(torch.load("out/model.pt", map_location="cpu")) | |
| # prompt = sys.argv[1] if len(sys.argv) > 1 else "Once upon a time" | |
| prompt = sys.argv[1] if len(sys.argv) > 1 else "Il était une fois" | |
| for _ in range(3): | |
| print(model.generate(prompt), end="\n\n") | |