Download test_agent_1.py from smallagi/agent_1: direct link, hf CLI and curl.
- Browser
- Download file 374 Bytes
-
https://huggingface.co/spaces/smallagi/agent_1/resolve/main/test_agent_1.py
- Command line
-
hf download hf://spaces/smallagi/agent_1/test_agent_1.py
-
curl -L -o test_agent_1.py https://huggingface.co/spaces/smallagi/agent_1/resolve/main/test_agent_1.py
374 Bytes
| # test_agent_1.py | |
| from transformers import GPT2LMHeadModel, GPT2Tokenizer | |
| tokenizer = GPT2Tokenizer.from_pretrained("./tiny-gpt") | |
| model = GPT2LMHeadModel.from_pretrained("./tiny-gpt") | |
| prompt = "Once upon a time" | |
| inputs = tokenizer(prompt, return_tensors="pt") | |
| outputs = model.generate(**inputs, max_length=50) | |
| print(tokenizer.decode(outputs[0], skip_special_tokens=True)) | |