Spaces:
Sleeping
Sleeping
Commit
路
793a724
1
Parent(s):
dfffcb1
app.py
CHANGED
@@ -1,30 +1,20 @@
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
from awq import AutoAWQForCausalLM
|
4 |
-
from transformers import AutoTokenizer
|
5 |
import spaces
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
@spaces.GPU(duration=120) # Asegura que una GPU est茅 disponible durante la carga del modelo
|
10 |
def cargar_modelo():
|
11 |
model_id = "hugging-quants/Meta-Llama-3.1-70B-Instruct-AWQ-INT4"
|
12 |
|
13 |
-
#
|
14 |
-
quantization_config = AwqConfig(
|
15 |
-
bits=4,
|
16 |
-
fuse_max_seq_len=512,
|
17 |
-
do_fuse=True,
|
18 |
-
)
|
19 |
-
|
20 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
21 |
-
|
22 |
model = AutoAWQForCausalLM.from_pretrained(
|
23 |
model_id,
|
24 |
torch_dtype=torch.float16,
|
25 |
low_cpu_mem_usage=True,
|
26 |
-
device_map=
|
27 |
-
quantization_config=quantization_config
|
28 |
)
|
29 |
return model, tokenizer
|
30 |
|
@@ -36,7 +26,7 @@ instructions = """
|
|
36 |
Como Ministro de la Corte Suprema de Chile, su objetivo es mejorar y finalizar los borradores de resoluciones judiciales para el sistema judicial civil del pa铆s...
|
37 |
"""
|
38 |
|
39 |
-
@spaces.GPU(duration=120)
|
40 |
def mejorar_resolucion(message, history=None):
|
41 |
prompt = [
|
42 |
{"role": "system", "content": instructions},
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
from awq import AutoAWQForCausalLM
|
4 |
+
from transformers import AutoTokenizer
|
5 |
import spaces
|
6 |
|
7 |
+
@spaces.GPU(duration=120)
|
|
|
|
|
8 |
def cargar_modelo():
|
9 |
model_id = "hugging-quants/Meta-Llama-3.1-70B-Instruct-AWQ-INT4"
|
10 |
|
11 |
+
# Omite quantization_config si ya est谩 incluido en el modelo
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
|
|
13 |
model = AutoAWQForCausalLM.from_pretrained(
|
14 |
model_id,
|
15 |
torch_dtype=torch.float16,
|
16 |
low_cpu_mem_usage=True,
|
17 |
+
device_map=None # Evita especificar manualmente el device_map
|
|
|
18 |
)
|
19 |
return model, tokenizer
|
20 |
|
|
|
26 |
Como Ministro de la Corte Suprema de Chile, su objetivo es mejorar y finalizar los borradores de resoluciones judiciales para el sistema judicial civil del pa铆s...
|
27 |
"""
|
28 |
|
29 |
+
@spaces.GPU(duration=120)
|
30 |
def mejorar_resolucion(message, history=None):
|
31 |
prompt = [
|
32 |
{"role": "system", "content": instructions},
|