lumen-models commited on
Commit
1a892e3
·
verified ·
1 Parent(s): 4a8ecd1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -4,18 +4,24 @@ from ctransformers import AutoModelForCausalLM
4
  # Cargar modelo GGUF
5
  model = AutoModelForCausalLM.from_pretrained(
6
  "tinyllama-1.1b-chat-v1.0.Q4_0.gguf",
7
- model_type="llama"
 
 
8
  )
9
 
10
  def chat_fn(message, history):
11
- # Generar texto
 
 
 
 
 
12
  output = model(
13
- message,
14
  max_new_tokens=200,
15
  temperature=0.7
16
  )
17
 
18
- # Convertir a string por seguridad
19
  if isinstance(output, bytes):
20
  output = output.decode("utf-8", errors="ignore")
21
 
@@ -29,4 +35,3 @@ demo = gr.ChatInterface(
29
 
30
  demo.launch()
31
 
32
-
 
4
  # Cargar modelo GGUF
5
  model = AutoModelForCausalLM.from_pretrained(
6
  "tinyllama-1.1b-chat-v1.0.Q4_0.gguf",
7
+ model_type="llama",
8
+ gpu_layers=0,
9
+ threads=4
10
  )
11
 
12
  def chat_fn(message, history):
13
+ prompt = (
14
+ "<|system|>Eres un asistente útil especializado en trámites y administración en España.<|end|>\n"
15
+ f"<|user|>{message}<|end|>\n"
16
+ "<|assistant|>"
17
+ )
18
+
19
  output = model(
20
+ prompt,
21
  max_new_tokens=200,
22
  temperature=0.7
23
  )
24
 
 
25
  if isinstance(output, bytes):
26
  output = output.decode("utf-8", errors="ignore")
27
 
 
35
 
36
  demo.launch()
37