Spaces:
Running
Running
vickeee465
commited on
Commit
·
84c21a9
1
Parent(s):
90425de
max_len + low_memory + device_map
Browse files- interfaces/cap.py +2 -3
- interfaces/emotion.py +1 -1
- interfaces/manifesto.py +2 -3
- interfaces/sentiment.py +2 -2
interfaces/cap.py
CHANGED
@@ -96,12 +96,11 @@ def build_huggingface_path(language: str, domain: str):
|
|
96 |
|
97 |
def predict(text, model_id, tokenizer_id):
|
98 |
device = torch.device("cpu")
|
99 |
-
model = AutoModelForSequenceClassification.from_pretrained(model_id, token=HF_TOKEN)
|
100 |
tokenizer = AutoTokenizer.from_pretrained(tokenizer_id)
|
101 |
-
model.to(device)
|
102 |
|
103 |
inputs = tokenizer(text,
|
104 |
-
max_length=
|
105 |
truncation=True,
|
106 |
padding="do_not_pad",
|
107 |
return_tensors="pt").to(device)
|
|
|
96 |
|
97 |
def predict(text, model_id, tokenizer_id):
|
98 |
device = torch.device("cpu")
|
99 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_id, low_cpu_mem_usage=True, device_map="auto", token=HF_TOKEN)
|
100 |
tokenizer = AutoTokenizer.from_pretrained(tokenizer_id)
|
|
|
101 |
|
102 |
inputs = tokenizer(text,
|
103 |
+
max_length=256,
|
104 |
truncation=True,
|
105 |
padding="do_not_pad",
|
106 |
return_tensors="pt").to(device)
|
interfaces/emotion.py
CHANGED
@@ -20,7 +20,7 @@ def build_huggingface_path(language: str):
|
|
20 |
|
21 |
def predict(text, model_id, tokenizer_id):
|
22 |
device = torch.device("cpu")
|
23 |
-
model = AutoModelForSequenceClassification.from_pretrained(model_id, token=HF_TOKEN)
|
24 |
tokenizer = AutoTokenizer.from_pretrained(tokenizer_id)
|
25 |
model.to(device)
|
26 |
|
|
|
20 |
|
21 |
def predict(text, model_id, tokenizer_id):
|
22 |
device = torch.device("cpu")
|
23 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_id, low_cpu_mem_usage=True, device_map="auto", token=HF_TOKEN)
|
24 |
tokenizer = AutoTokenizer.from_pretrained(tokenizer_id)
|
25 |
model.to(device)
|
26 |
|
interfaces/manifesto.py
CHANGED
@@ -24,12 +24,11 @@ def build_huggingface_path(language: str):
|
|
24 |
|
25 |
def predict(text, model_id, tokenizer_id):
|
26 |
device = torch.device("cpu")
|
27 |
-
model = AutoModelForSequenceClassification.from_pretrained(model_id, token=HF_TOKEN)
|
28 |
tokenizer = AutoTokenizer.from_pretrained(tokenizer_id)
|
29 |
-
model.to(device)
|
30 |
|
31 |
inputs = tokenizer(text,
|
32 |
-
max_length=
|
33 |
truncation=True,
|
34 |
padding="do_not_pad",
|
35 |
return_tensors="pt").to(device)
|
|
|
24 |
|
25 |
def predict(text, model_id, tokenizer_id):
|
26 |
device = torch.device("cpu")
|
27 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_id, low_cpu_mem_usage=True, device_map="auto", token=HF_TOKEN)
|
28 |
tokenizer = AutoTokenizer.from_pretrained(tokenizer_id)
|
|
|
29 |
|
30 |
inputs = tokenizer(text,
|
31 |
+
max_length=256,
|
32 |
truncation=True,
|
33 |
padding="do_not_pad",
|
34 |
return_tensors="pt").to(device)
|
interfaces/sentiment.py
CHANGED
@@ -24,12 +24,12 @@ def build_huggingface_path(language: str):
|
|
24 |
|
25 |
def predict(text, model_id, tokenizer_id):
|
26 |
device = torch.device("cpu")
|
27 |
-
model = AutoModelForSequenceClassification.from_pretrained(model_id, token=HF_TOKEN)
|
28 |
tokenizer = AutoTokenizer.from_pretrained(tokenizer_id)
|
29 |
model.to(device)
|
30 |
|
31 |
inputs = tokenizer(text,
|
32 |
-
max_length=
|
33 |
truncation=True,
|
34 |
padding="do_not_pad",
|
35 |
return_tensors="pt").to(device)
|
|
|
24 |
|
25 |
def predict(text, model_id, tokenizer_id):
|
26 |
device = torch.device("cpu")
|
27 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_id, low_cpu_mem_usage=True, device_map="auto", token=HF_TOKEN)
|
28 |
tokenizer = AutoTokenizer.from_pretrained(tokenizer_id)
|
29 |
model.to(device)
|
30 |
|
31 |
inputs = tokenizer(text,
|
32 |
+
max_length=256,
|
33 |
truncation=True,
|
34 |
padding="do_not_pad",
|
35 |
return_tensors="pt").to(device)
|