Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,32 +1,3 @@
|
|
| 1 |
-
|
| 2 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 3 |
|
| 4 |
-
|
| 5 |
-
model_name = "BSC-LT/ALIA-40b"
|
| 6 |
-
|
| 7 |
-
# Cargar el tokenizador y el modelo
|
| 8 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 9 |
-
model = AutoModelForCausalLM.from_pretrained(model_name)
|
| 10 |
-
|
| 11 |
-
def generar_texto(entrada):
|
| 12 |
-
# Tokenizar la entrada
|
| 13 |
-
input_ids = tokenizer.encode(entrada, return_tensors="pt")
|
| 14 |
-
|
| 15 |
-
# Generar texto con el modelo
|
| 16 |
-
output = model.generate(input_ids, max_length=100, num_return_sequences=1)
|
| 17 |
-
|
| 18 |
-
# Decodificar y retornar el texto generado
|
| 19 |
-
texto_generado = tokenizer.decode(output[0], skip_special_tokens=True)
|
| 20 |
-
return texto_generado
|
| 21 |
-
|
| 22 |
-
# Crear la interfaz de Gradio
|
| 23 |
-
interfaz = gr.Interface(
|
| 24 |
-
fn=generar_texto,
|
| 25 |
-
inputs=gr.inputs.Textbox(lines=2, placeholder="Escribe tu prompt aquí..."),
|
| 26 |
-
outputs="text",
|
| 27 |
-
title="Generador de Texto con ALIA-40b",
|
| 28 |
-
description="Este modelo genera texto utilizando ALIA-40b, un modelo LLM entrenado por BSC-LT."
|
| 29 |
-
)
|
| 30 |
-
|
| 31 |
-
if __name__ == "__main__":
|
| 32 |
-
interfaz.launch()
|
|
|
|
| 1 |
+
importar gradio como gr
|
|
|
|
| 2 |
|
| 3 |
+
gr.load( "modelos/BSC-LT/ALIA-40b" ).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|