Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,14 @@
|
|
1 |
from transformers import pipeline
|
2 |
|
3 |
# Initialize the text generation pipeline with the distilgpt2 model
|
4 |
-
generator = pipeline('text-generation', model='distilgpt2')
|
|
|
5 |
|
6 |
# Generate text with the specified parameters
|
7 |
output = generator(
|
8 |
'in this course, we will teach how to',
|
9 |
max_length=20, # Set maximum length of the generated text
|
10 |
-
num_return_sequences=
|
11 |
)
|
12 |
|
13 |
# Print the full output
|
|
|
1 |
from transformers import pipeline
|
2 |
|
3 |
# Initialize the text generation pipeline with the distilgpt2 model
|
4 |
+
generator = pipeline('text-generation', model='distilgpt2', device=0) # Use GPU (device 0)
|
5 |
+
|
6 |
|
7 |
# Generate text with the specified parameters
|
8 |
output = generator(
|
9 |
'in this course, we will teach how to',
|
10 |
max_length=20, # Set maximum length of the generated text
|
11 |
+
num_return_sequences=1 # Generate 2 sequences
|
12 |
)
|
13 |
|
14 |
# Print the full output
|