Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -13,13 +13,14 @@ if "model" not in globals():
|
|
13 |
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16)
|
14 |
model.eval() # 🔹 Optimiza la inferencia para que sea más rápida
|
15 |
|
16 |
-
# Función exclusiva para humanización de texto
|
17 |
def humanize_text(input_text):
|
18 |
system_prompt = (
|
19 |
-
"Reescribe el siguiente texto
|
20 |
-
"
|
21 |
-
"
|
22 |
-
"
|
|
|
23 |
)
|
24 |
|
25 |
prompt = f"{system_prompt}\n\nTexto original: {input_text}\n\nTexto humanizado:"
|
@@ -29,11 +30,11 @@ def humanize_text(input_text):
|
|
29 |
outputs = model.generate(
|
30 |
inputs.input_ids,
|
31 |
attention_mask=inputs.attention_mask,
|
32 |
-
max_new_tokens=150, # 🔹
|
33 |
do_sample=True, # 🔹 Mantiene variabilidad en la reescritura
|
34 |
-
temperature=0.
|
35 |
top_p=0.9, # 🔹 Mantiene coherencia en la reescritura
|
36 |
-
repetition_penalty=1.
|
37 |
early_stopping=True,
|
38 |
)
|
39 |
|
@@ -41,7 +42,7 @@ def humanize_text(input_text):
|
|
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")
|
|
|
13 |
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16)
|
14 |
model.eval() # 🔹 Optimiza la inferencia para que sea más rápida
|
15 |
|
16 |
+
# Función exclusiva para humanización de texto con enfoque en marketing
|
17 |
def humanize_text(input_text):
|
18 |
system_prompt = (
|
19 |
+
"Reescribe el siguiente texto con un tono más natural, conversacional y cercano, ideal para marketing. "
|
20 |
+
"Haz que fluya de manera más atractiva y persuasiva, como si lo escribiera un experto en marketing, "
|
21 |
+
"pero sin modificar ni inventar datos. Mantén toda la información original sin omitir detalles. "
|
22 |
+
"Puedes reorganizar las oraciones para mejorar la claridad y el impacto. "
|
23 |
+
"Asegúrate de que el resultado se sienta humano y auténtico, evitando cualquier indicio de automatización."
|
24 |
)
|
25 |
|
26 |
prompt = f"{system_prompt}\n\nTexto original: {input_text}\n\nTexto humanizado:"
|
|
|
30 |
outputs = model.generate(
|
31 |
inputs.input_ids,
|
32 |
attention_mask=inputs.attention_mask,
|
33 |
+
max_new_tokens=150, # 🔹 Suficiente espacio para reformular el texto sin cortes
|
34 |
do_sample=True, # 🔹 Mantiene variabilidad en la reescritura
|
35 |
+
temperature=0.8, # 🔹 Permite más fluidez sin inventar datos
|
36 |
top_p=0.9, # 🔹 Mantiene coherencia en la reescritura
|
37 |
+
repetition_penalty=1.1, # 🔹 Evita repeticiones innecesarias
|
38 |
early_stopping=True,
|
39 |
)
|
40 |
|
|
|
42 |
|
43 |
# Interfaz en Gradio
|
44 |
with gr.Blocks() as demo:
|
45 |
+
gr.Markdown("# ✍️ Humanización de Texto con ALIA (Optimizado para Marketing)")
|
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")
|