juanelot commited on
Commit
aa5e6d7
·
verified ·
1 Parent(s): 5ed4d80

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
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 = "meta-llama/Llama-2-7b-chat-hf"
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 en el formato que Llama-2 espera
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}\nAssistant: {ai}\n"
33
- prompt += f"Human: {message}\nAssistant:"
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 Llama-2",
45
- description="Un chatbot de IA avanzado utilizando el modelo Llama-2-7b-chat para conversaciones coherentes y naturales.",
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()