Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -13,13 +13,12 @@ if "model" not in globals():
|
|
13 |
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16)
|
14 |
model.eval()
|
15 |
|
16 |
-
# 馃敼 Funci贸n de humanizaci贸n
|
17 |
def humanize_text(input_text):
|
18 |
system_prompt = (
|
19 |
-
"Reescribe el siguiente texto
|
20 |
-
"sin cambiar su significado
|
21 |
-
"
|
22 |
-
"Evita tecnicismos y burocracia innecesaria."
|
23 |
)
|
24 |
|
25 |
prompt = f"{system_prompt}\n\nTexto original: {input_text}\n\nTexto humanizado:"
|
@@ -29,12 +28,12 @@ def humanize_text(input_text):
|
|
29 |
outputs = model.generate(
|
30 |
inputs.input_ids,
|
31 |
attention_mask=inputs.attention_mask,
|
32 |
-
max_new_tokens=
|
33 |
min_length=50, # 馃敼 Evita respuestas demasiado cortas
|
34 |
do_sample=True, # 馃敼 Mantiene variabilidad sin ralentizar
|
35 |
-
temperature=0.
|
36 |
-
top_p=0.
|
37 |
-
repetition_penalty=1.
|
38 |
num_return_sequences=1, # 馃敼 Solo una respuesta bien formulada
|
39 |
)
|
40 |
|
@@ -42,7 +41,7 @@ def humanize_text(input_text):
|
|
42 |
|
43 |
# Interfaz en Gradio
|
44 |
with gr.Blocks() as demo:
|
45 |
-
gr.Markdown("# 鉁嶏笍 Humanizaci贸n de Texto con ALIA
|
46 |
input_text = gr.Textbox(label="Pega aqu铆 el texto generado por IA para humanizar")
|
47 |
output_text = gr.Textbox(label="Texto humanizado por ALIA", interactive=False)
|
48 |
submit_button = gr.Button("Humanizar Texto")
|
|
|
13 |
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16)
|
14 |
model.eval()
|
15 |
|
16 |
+
# 馃敼 Funci贸n de humanizaci贸n optimizada
|
17 |
def humanize_text(input_text):
|
18 |
system_prompt = (
|
19 |
+
"Reescribe el siguiente texto con un tono m谩s natural y fluido, "
|
20 |
+
"sin cambiar su significado ni agregar informaci贸n nueva. "
|
21 |
+
"Evita repeticiones y burocracia innecesaria, asegurando que suene humano y claro."
|
|
|
22 |
)
|
23 |
|
24 |
prompt = f"{system_prompt}\n\nTexto original: {input_text}\n\nTexto humanizado:"
|
|
|
28 |
outputs = model.generate(
|
29 |
inputs.input_ids,
|
30 |
attention_mask=inputs.attention_mask,
|
31 |
+
max_new_tokens=120, # 馃敼 Equilibrio entre reformulaci贸n y velocidad
|
32 |
min_length=50, # 馃敼 Evita respuestas demasiado cortas
|
33 |
do_sample=True, # 馃敼 Mantiene variabilidad sin ralentizar
|
34 |
+
temperature=0.8, # 馃敼 Aumentamos un poco la creatividad
|
35 |
+
top_p=0.85, # 馃敼 M谩s variabilidad sin afectar precisi贸n
|
36 |
+
repetition_penalty=1.02, # 馃敼 Evita repeticiones sin ser tan restrictivo
|
37 |
num_return_sequences=1, # 馃敼 Solo una respuesta bien formulada
|
38 |
)
|
39 |
|
|
|
41 |
|
42 |
# Interfaz en Gradio
|
43 |
with gr.Blocks() as demo:
|
44 |
+
gr.Markdown("# 鉁嶏笍 Humanizaci贸n de Texto con ALIA")
|
45 |
input_text = gr.Textbox(label="Pega aqu铆 el texto generado por IA para humanizar")
|
46 |
output_text = gr.Textbox(label="Texto humanizado por ALIA", interactive=False)
|
47 |
submit_button = gr.Button("Humanizar Texto")
|