Trat80 commited on
Commit
d0a1213
·
1 Parent(s): b235521

Create generate_text.py

Browse files
Files changed (1) hide show
  1. 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)