Skip to content

Conversation

@jadie1
Copy link
Contributor

@jadie1 jadie1 commented May 26, 2025

Enables comp. reg. alignment to multi-attribute targets by adding a component step that for each probe:

  1. Finds the attribute with smaller predicted delta and removes it from predicted scores
  2. Alters the alignment target to only include the more relevant (bigger delta) attribute

Example call to run zeroshot:

run_align_system +experiment=phase2_june_collab/multi_attribute_pipeline_zeroshot_comparative_regression +alignment_target=june2025/ADEPT-June2025-affiliation_merit-0.0_0.0.yaml

Example call to run fewshot:

run_align_system +experiment=phase2_june_collab/multi_attribute_pipeline_fewshot_comparative_regression_loo +alignment_target=june2025/ADEPT-June2025-affiliation_merit-0.0_0.0.yaml

@jadie1 jadie1 marked this pull request as ready for review May 26, 2025 20:49
Copy link
Contributor

@eveenhuis eveenhuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, I'd be fine with merging as is. Just a couple of nits/sanity checks

# Two or more attributes -> keep the one with largest delta
else:
if len(attribute_prediction_scores.keys()) > 2:
raise RuntimeError("Relevance filtering not implemented for more than two choices.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: David recommended I raise NotImplementedError for a similar check

alignment_target):
# If there are two non-medical attributes, removes the one with smaller delta

attributes = list({key for inner in attribute_prediction_scores.values() for key in inner})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we're looping all choice predictions in case different choices have different predictions? Do we think that'll actually happen?

choiceA, choiceB = list(attribute_prediction_scores.keys())
max_delta = -np.inf
for attr in attributes:
delta = abs(np.array(attribute_prediction_scores[choiceA][attr]).mean() - np.array(attribute_prediction_scores[choiceB][attr]).mean())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know at one point we potentially had to handle both a single prediction and a list of predictions. Do we still need to do that? (If not yayyyyy simpler code :))

max_delta = -np.inf
for attr in attributes:
delta = abs(np.array(attribute_prediction_scores[choiceA][attr]).mean() - np.array(attribute_prediction_scores[choiceB][attr]).mean())
if delta > max_delta:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only keep the first one if there's a tie. I think that's fine because I don't know what we'd actually do if there was a tie (plus that seems unlikely), but just double checking you didn't have a different set of assumptions

Comment on lines +204 to +208
# Update predicted scores to only have more relevant attribute
filtered_attribute_prediction_scores = {choiceA:{}, choiceB:{}}
for keep_attr in keep_attributes:
filtered_attribute_prediction_scores[choiceA][keep_attr] = attribute_prediction_scores[choiceA][keep_attr]
filtered_attribute_prediction_scores[choiceB][keep_attr] = attribute_prediction_scores[choiceB][keep_attr]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit)

Suggested change
# Update predicted scores to only have more relevant attribute
filtered_attribute_prediction_scores = {choiceA:{}, choiceB:{}}
for keep_attr in keep_attributes:
filtered_attribute_prediction_scores[choiceA][keep_attr] = attribute_prediction_scores[choiceA][keep_attr]
filtered_attribute_prediction_scores[choiceB][keep_attr] = attribute_prediction_scores[choiceB][keep_attr]
# Update predicted scores to only have more relevant attribute
filtered_attribute_prediction_scores = {
choice: {
keep_attr: predictions[choice][keep_attr]
for keep_attr in keep_attributes
}
for choice in attribute_prediction_scores.keys()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants