Spaces:
Running
on
Zero
Running
on
Zero
Reimplement EOT weighting
Browse files
app.py
CHANGED
|
@@ -100,6 +100,9 @@ def noisify_answer(input_ids, answer_start, threshold=1.0, eot_weight=1.0, mask_
|
|
| 100 |
|
| 101 |
mixed_probs = token_probabilities.copy()
|
| 102 |
|
|
|
|
|
|
|
|
|
|
| 103 |
# Scale all other probabilities so they sum to 1 - mask_weight
|
| 104 |
total_other = mixed_probs.sum() - mixed_probs[mask_token_id]
|
| 105 |
scale = (1.0 - mask_weight) / total_other
|
|
@@ -159,6 +162,9 @@ def confidence_guided_noising(input_ids, answer_start, confidences, noise_clippi
|
|
| 159 |
|
| 160 |
mixed_probs = token_probabilities.copy()
|
| 161 |
|
|
|
|
|
|
|
|
|
|
| 162 |
# Scale all other probabilities so they sum to 1 - mask_weight
|
| 163 |
total_other = mixed_probs.sum() - mixed_probs[mask_token_id]
|
| 164 |
scale = (1.0 - mask_weight) / total_other
|
|
|
|
| 100 |
|
| 101 |
mixed_probs = token_probabilities.copy()
|
| 102 |
|
| 103 |
+
# Apply EOT weighting
|
| 104 |
+
mixed_probs[eot_token_id] *= eot_weight
|
| 105 |
+
|
| 106 |
# Scale all other probabilities so they sum to 1 - mask_weight
|
| 107 |
total_other = mixed_probs.sum() - mixed_probs[mask_token_id]
|
| 108 |
scale = (1.0 - mask_weight) / total_other
|
|
|
|
| 162 |
|
| 163 |
mixed_probs = token_probabilities.copy()
|
| 164 |
|
| 165 |
+
# Apply EOT weighting
|
| 166 |
+
mixed_probs[eot_token_id] *= eot_weight
|
| 167 |
+
|
| 168 |
# Scale all other probabilities so they sum to 1 - mask_weight
|
| 169 |
total_other = mixed_probs.sum() - mixed_probs[mask_token_id]
|
| 170 |
scale = (1.0 - mask_weight) / total_other
|