Upload metrics.py with huggingface_hub
Browse files- metrics.py +4 -1
metrics.py
CHANGED
@@ -2255,6 +2255,8 @@ class Perplexity(BulkInstanceMetric):
|
|
2255 |
self.model_class().from_pretrained(self.model_name).to(self.device)
|
2256 |
)
|
2257 |
self.tokenizer = AutoTokenizer.from_pretrained(self.model_name)
|
|
|
|
|
2258 |
self.single_token_mode = single_token_mode
|
2259 |
|
2260 |
def compute_lm(
|
@@ -3348,7 +3350,8 @@ class BinaryMaxF1(F1Binary):
|
|
3348 |
|
3349 |
best_thr = -1
|
3350 |
best_f1 = -1
|
3351 |
-
for
|
|
|
3352 |
new_predictions = [
|
3353 |
"1" if float_prediction >= thr else "0"
|
3354 |
for float_prediction in float_predictions
|
|
|
2255 |
self.model_class().from_pretrained(self.model_name).to(self.device)
|
2256 |
)
|
2257 |
self.tokenizer = AutoTokenizer.from_pretrained(self.model_name)
|
2258 |
+
if self.tokenizer.pad_token_id is None:
|
2259 |
+
self.tokenizer.pad_token_id = self.tokenizer.eos_token_id
|
2260 |
self.single_token_mode = single_token_mode
|
2261 |
|
2262 |
def compute_lm(
|
|
|
3350 |
|
3351 |
best_thr = -1
|
3352 |
best_f1 = -1
|
3353 |
+
thrs = {round(fp, 3) for fp in float_predictions}
|
3354 |
+
for thr in thrs:
|
3355 |
new_predictions = [
|
3356 |
"1" if float_prediction >= thr else "0"
|
3357 |
for float_prediction in float_predictions
|