Skip to content

How to get the task name of the victim model during the transformations  #444

Open

Description

@ddehun

Hi. First of all, thank you for your awesome project!

I'm trying to add a new recipe with MLM-based substitution (e.g., BAE or CLARE).
And I've struggled to load the BERT that is also trained on the same dataset with the victim model.
For instance, if the victim model is some arbitrary model fine-tuned on the YELP polarity dataset, I want to use the BERT that is also trained on YELP for word substitution or insertion.

To this end, It seems that my recipe class should be able to know the information about the victim model (maybe somewhere like the below code, where the recipe class calls the transformation class).
https://github.com/QData/TextAttack/blob/master/textattack/attack_recipes/bae_garg_2019.py#L53

but I'm not sure whether there exists any shortcut for this problem. Could you give me any advice for my purpose?

Thank you!

Activity

  1. donggrant commented on Oct 29, 2021

    @donggrant

    This is also an enhancement that I think could be very useful. When trying to enhance Tutorial 9, I needed to find a faster alternative to the CamemBert model that was pretrained on the Allocine dataset. It was hard to locate an alternative dataset where the CamemBert model was pretrained on.

  2. qiyanjun commented on Aug 13, 2026

    @qiyanjun
    Member

    This is a real API design gap — there's currently no clean way for a Transformation to know what dataset/task the victim model was trained on, so MLM-based transformations (BAE/CLARE) can't pick a same-domain masked-LM the way this issue and @donggrant's comment both want. Threading that metadata from AttackRecipe.build(model_wrapper) down into Transformation.__init__ would need a design decision on where that metadata lives (on ModelWrapper? passed explicitly to build()?) — not something to guess at unilaterally. Leaving open as a real, still-valid feature request.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions