Spaces:
Runtime error
Runtime error
Commit
·
369620c
1
Parent(s):
d995b22
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,8 +30,9 @@ list_audios= [[Problema_tarjetaCredito]]
|
|
| 30 |
def gen_conversation(text,max_new_tokens=100):
|
| 31 |
text = "<SN>instruction: " + text + "\n "
|
| 32 |
batch = tokenizer2(text, return_tensors='pt')
|
| 33 |
-
|
| 34 |
-
|
|
|
|
| 35 |
max_new_tokens=max_new_tokens,
|
| 36 |
eos_token_id= tokenizer2.eos_token_id,
|
| 37 |
pad_token_id= tokenizer2.pad_token_id,
|
|
@@ -43,6 +44,7 @@ def gen_conversation(text,max_new_tokens=100):
|
|
| 43 |
num_beams=3
|
| 44 |
)
|
| 45 |
gc.collect()
|
|
|
|
| 46 |
return tokenizer2.decode(output_tokens[0], skip_special_tokens=True).split("\n")[-1].replace("output:","")
|
| 47 |
|
| 48 |
conversacion = ""
|
|
|
|
| 30 |
def gen_conversation(text,max_new_tokens=100):
|
| 31 |
text = "<SN>instruction: " + text + "\n "
|
| 32 |
batch = tokenizer2(text, return_tensors='pt')
|
| 33 |
+
batch = {k: v.to('cuda') for k, v in batch.items()}
|
| 34 |
+
with torch.cuda.amp.autocast():
|
| 35 |
+
output_tokens = model2.generate(**batch,
|
| 36 |
max_new_tokens=max_new_tokens,
|
| 37 |
eos_token_id= tokenizer2.eos_token_id,
|
| 38 |
pad_token_id= tokenizer2.pad_token_id,
|
|
|
|
| 44 |
num_beams=3
|
| 45 |
)
|
| 46 |
gc.collect()
|
| 47 |
+
torch.cuda.memory_summary(device=None, abbreviated=False)
|
| 48 |
return tokenizer2.decode(output_tokens[0], skip_special_tokens=True).split("\n")[-1].replace("output:","")
|
| 49 |
|
| 50 |
conversacion = ""
|