Spaces:
Sleeping
Sleeping
JaphetHernandez
commited on
Commit
•
8ecc356
1
Parent(s):
0b95dd9
Update app.py
Browse files
app.py
CHANGED
@@ -33,6 +33,9 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
33 |
quantization_config=quant_config
|
34 |
)
|
35 |
|
|
|
|
|
|
|
36 |
# Establecer el token de relleno
|
37 |
if tokenizer.pad_token_id is None:
|
38 |
tokenizer.pad_token_id = tokenizer.eos_token_id
|
@@ -87,16 +90,16 @@ if uploaded_file is not None:
|
|
87 |
all_scores = []
|
88 |
try:
|
89 |
for batch in job_titles_batches:
|
90 |
-
# Tokenizar la entrada
|
91 |
model_inputs = tokenizer(
|
92 |
batch,
|
93 |
return_tensors="pt",
|
94 |
padding=True,
|
95 |
truncation=True
|
96 |
-
).to(
|
97 |
|
98 |
with torch.cuda.amp.autocast(): # Usar Mixed Precision
|
99 |
-
model_inputs['attention_mask'] = (model_inputs['input_ids'] != tokenizer.pad_token_id).int()
|
100 |
generated_ids = model.generate(
|
101 |
**model_inputs,
|
102 |
max_new_tokens=20, # Reducir para minimizar el uso de memoria
|
@@ -123,6 +126,7 @@ if uploaded_file is not None:
|
|
123 |
st.error("La columna 'job_title' no se encuentra en el archivo CSV.")
|
124 |
|
125 |
|
|
|
126 |
'''
|
127 |
|
128 |
|
|
|
33 |
quantization_config=quant_config
|
34 |
)
|
35 |
|
36 |
+
# Asegurar que el modelo esté en la GPU
|
37 |
+
model.to("cuda")
|
38 |
+
|
39 |
# Establecer el token de relleno
|
40 |
if tokenizer.pad_token_id is None:
|
41 |
tokenizer.pad_token_id = tokenizer.eos_token_id
|
|
|
90 |
all_scores = []
|
91 |
try:
|
92 |
for batch in job_titles_batches:
|
93 |
+
# Tokenizar la entrada y mover a CUDA
|
94 |
model_inputs = tokenizer(
|
95 |
batch,
|
96 |
return_tensors="pt",
|
97 |
padding=True,
|
98 |
truncation=True
|
99 |
+
).to("cuda") # Mover explícitamente a CUDA
|
100 |
|
101 |
with torch.cuda.amp.autocast(): # Usar Mixed Precision
|
102 |
+
model_inputs['attention_mask'] = (model_inputs['input_ids'] != tokenizer.pad_token_id).int().to("cuda")
|
103 |
generated_ids = model.generate(
|
104 |
**model_inputs,
|
105 |
max_new_tokens=20, # Reducir para minimizar el uso de memoria
|
|
|
126 |
st.error("La columna 'job_title' no se encuentra en el archivo CSV.")
|
127 |
|
128 |
|
129 |
+
|
130 |
'''
|
131 |
|
132 |
|