Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
3 |
import torch
|
4 |
|
5 |
# Cargar el modelo y el tokenizador
|
6 |
-
model_name = "
|
7 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
8 |
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto", load_in_8bit=True)
|
9 |
|
@@ -26,11 +26,11 @@ def generate_response(prompt, max_length=200):
|
|
26 |
def chatbot(message, history):
|
27 |
history = history or []
|
28 |
|
29 |
-
# Construir el prompt
|
30 |
prompt = "Eres un asistente AI amigable y útil. Responde de manera concisa y coherente.\n\n"
|
31 |
for human, ai in history:
|
32 |
-
prompt += f"Human: {human}\
|
33 |
-
prompt += f"Human: {message}\
|
34 |
|
35 |
response = generate_response(prompt)
|
36 |
|
@@ -41,8 +41,8 @@ iface = gr.Interface(
|
|
41 |
fn=chatbot,
|
42 |
inputs=["text", "state"],
|
43 |
outputs=["chatbot", "state"],
|
44 |
-
title="Tu Compañero AI con
|
45 |
-
description="Un chatbot de IA
|
46 |
)
|
47 |
|
48 |
iface.launch()
|
|
|
3 |
import torch
|
4 |
|
5 |
# Cargar el modelo y el tokenizador
|
6 |
+
model_name = "facebook/opt-1.3b"
|
7 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
8 |
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto", load_in_8bit=True)
|
9 |
|
|
|
26 |
def chatbot(message, history):
|
27 |
history = history or []
|
28 |
|
29 |
+
# Construir el prompt
|
30 |
prompt = "Eres un asistente AI amigable y útil. Responde de manera concisa y coherente.\n\n"
|
31 |
for human, ai in history:
|
32 |
+
prompt += f"Human: {human}\nAI: {ai}\n"
|
33 |
+
prompt += f"Human: {message}\nAI:"
|
34 |
|
35 |
response = generate_response(prompt)
|
36 |
|
|
|
41 |
fn=chatbot,
|
42 |
inputs=["text", "state"],
|
43 |
outputs=["chatbot", "state"],
|
44 |
+
title="Tu Compañero AI con OPT-1.3B",
|
45 |
+
description="Un chatbot de IA utilizando el modelo OPT-1.3B para conversaciones coherentes y naturales.",
|
46 |
)
|
47 |
|
48 |
iface.launch()
|