Spaces:
Sleeping
Sleeping
Download app.py from Akshay-More-007/starcoder: direct link, hf CLI and curl.
- Browser
- Download file 526 Bytes
-
https://huggingface.co/spaces/Akshay-More-007/starcoder/resolve/main/app.py
- Command line
-
hf download hf://spaces/Akshay-More-007/starcoder/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Akshay-More-007/starcoder/resolve/main/app.py
526 Bytes
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| checkpoint = "bigcode/starcoder" | |
| device = "cpu" # for GPU usage or "cpu" for CPU usage | |
| api_key = "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" | |
| tokenizer = AutoTokenizer.from_pretrained(checkpoint, use_auth_token=api_key) | |
| model = AutoModelForCausalLM.from_pretrained(checkpoint, use_auth_token=api_key).to(device) | |
| inputs = tokenizer.encode("def print_hello_world ():", return_tensors="pt").to(device) | |
| outputs = model.generate(inputs) | |
| print(tokenizer.decode(outputs[0])) | |