Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove contrast_target_prefixes from contrastive step functions #224

Merged
merged 1 commit into from
Oct 23, 2023

Conversation

gsarti
Copy link
Member

@gsarti gsarti commented Oct 23, 2023

Description

This PR removes the contrast_target_prefixes argument from all contrastive functions and implements default right-side alignment of contrastive sequences. This allows a more intuitive usage of contrastive step functions that 1) doesn't require splitting manually the contrastive target prefix and 2) works out of the box for decoder-only LMs:

Example before:

mt_model.attribute(
    "she started working as a cook in London.",
    "ha iniziato a lavorare come cuoca a Londra.",
    contrast_sources="After finishing her studies, she started working as a cook in London.",
    contrast_target_prefixes="Dopo aver terminato gli studi, ",
)

After:

mt_model.attribute(
    "she started working as a cook in London.",
    "ha iniziato a lavorare come cuoca a Londra.",
    contrast_sources="After finishing her studies, she started working as a cook in London.",
	contrast_targets="Dopo aver terminato gli studi, ha iniziato a lavorare come cuoca a Londra.",
)

@gsarti gsarti merged commit 8d50c70 into main Oct 23, 2023
4 checks passed
@gsarti gsarti deleted the fix-contrast-align branch October 23, 2023 14:10
gsarti added a commit that referenced this pull request Oct 30, 2023
* origin/main:
  Attributed behavior for contrastive step functions (#228)
  Fix command for installing pre-commit hooks. (#229)
  Remove `max_input_length` from `model.encode` (#227)
  Migrate to `ruff format` (#225)
  Remove contrast_target_prefixes from contrastive step functions (#224)
  Step functions fixes, add `in_context_pvi` (#223)
  Format fixes, add Attanasio et al. (2023) to readme
  Add Sequential IG method (#222)
  Fix LIME and Occlusion outputs (#220)
  Update citation information
  Bump dependencies
  Add end_pos for contrast_targets_alignments
  Fix dummy output viz in console
  Minor fixes
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.

None yet

1 participant