Spaces:
Running
Running
rdiehlmartinez
commited on
Commit
•
8d4965b
1
Parent(s):
bfe5d3e
Updating PPL to include trust_remote_code
Browse files- perplexity.py +3 -3
perplexity.py
CHANGED
@@ -101,7 +101,7 @@ class Perplexity(evaluate.Metric):
|
|
101 |
)
|
102 |
|
103 |
def _compute(
|
104 |
-
self, predictions, model_id, batch_size: int = 16, add_start_token: bool = True, device=None, max_length=None
|
105 |
):
|
106 |
|
107 |
if device is not None:
|
@@ -111,10 +111,10 @@ class Perplexity(evaluate.Metric):
|
|
111 |
else:
|
112 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
113 |
|
114 |
-
model = AutoModelForCausalLM.from_pretrained(model_id)
|
115 |
model = model.to(device)
|
116 |
|
117 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
118 |
|
119 |
# if batch_size > 1 (which generally leads to padding being required), and
|
120 |
# if there is not an already assigned pad_token, assign an existing
|
|
|
101 |
)
|
102 |
|
103 |
def _compute(
|
104 |
+
self, predictions, model_id, batch_size: int = 16, add_start_token: bool = True, device=None, max_length=None, trust_remote_code=False,
|
105 |
):
|
106 |
|
107 |
if device is not None:
|
|
|
111 |
else:
|
112 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
113 |
|
114 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=trust_remote_code)
|
115 |
model = model.to(device)
|
116 |
|
117 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=trust_remote_code)
|
118 |
|
119 |
# if batch_size > 1 (which generally leads to padding being required), and
|
120 |
# if there is not an already assigned pad_token, assign an existing
|