File size: 423 Bytes
a38b3f5
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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'])