Create generate_text.py
Browse files- generate_text.py +9 -0
generate_text.py
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
|
3 |
+
# Cargar un modelo pre-entrenado de generación de texto GPT-2
|
4 |
+
generator = pipeline('text-generation', model='gpt2')
|
5 |
+
|
6 |
+
# Generar texto con el modelo pre-entrenado
|
7 |
+
generated_text = generator("Once upon a time, in a land far, far away", max_length=100, num_return_sequences=1)
|
8 |
+
|
9 |
+
print(generated_text)
|