Update install stuff

This commit is contained in:
Joey Yakimowich-Payne 2025-05-13 14:58:44 -06:00
commit 25b12a512d
3 changed files with 21 additions and 12 deletions

View file

@ -644,3 +644,20 @@ def get_combined_score(
best_idx = idx
return best_idx
def get_filtered_cands(tokenizer, control_cand, filter_cand=True, curr_control=None):
cands, count = [], 0
for i in range(control_cand.shape[0]):
decoded_str = tokenizer.decode(control_cand[i], skip_special_tokens=True)
if filter_cand:
if decoded_str != curr_control and len(tokenizer(decoded_str, add_special_tokens=False).input_ids) == len(control_cand[i]):
cands.append(decoded_str)
else:
count += 1
else:
cands.append(decoded_str)
if filter_cand:
cands = cands + [cands[-1]] * (len(control_cand) - len(cands))
# print(f"Warning: {round(count / len(control_cand), 2)} control candidates were not valid")
return cands