Download starcoder_example.py from sp103107/skatingP: direct link, hf CLI and curl.
- Browser
- Download file 423 Bytes
-
https://huggingface.co/spaces/sp103107/skatingP/resolve/main/starcoder_example.py
- Command line
-
hf download hf://spaces/sp103107/skatingP/starcoder_example.py
-
curl -L -o starcoder_example.py https://huggingface.co/spaces/sp103107/skatingP/resolve/main/starcoder_example.py
423 Bytes
| from transformers import pipeline | |
| # Load the StarCoder model and send it to the GPU | |
| model_name = "bigcode/starcoder" | |
| code_pipeline = pipeline("text-generation", model=model_name, device=0) # 0 for first GPU | |
| # Provide the prompt | |
| prompt = "def fibonacci(n):\n # Compute the Fibonacci sequence" | |
| # Generate the code | |
| result = code_pipeline(prompt, max_new_tokens=50) | |
| # Print the output | |
| print(result[0]['generated_text']) |