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

Issues attacking se2seq model (seq2sick) #771

Open
SachJbp opened this issue Jan 5, 2024 · 0 comments
Open

Issues attacking se2seq model (seq2sick) #771

SachJbp opened this issue Jan 5, 2024 · 0 comments

Comments

@SachJbp
Copy link

SachJbp commented Jan 5, 2024

Seems like raw outputs of the model are being passed to NonOverlappingOutput implemented methods _is_goal_complete which subsequently calls word_difference_score with those tensors leading to split() being called on tensors giving TypeError: split() missing 1 required positional argument: 'split_size'. Let me know if there is something wrong while constructing the model_wrapper or if BART can be attacked using TextAttack?

import transformers
from transformers import BartForConditionalGeneration, BartTokenizer
import textattack
from textattack.attack_recipes.seq2sick_cheng_2018_blackbox import Seq2SickCheng2018BlackBox

# Define the input text and target summary
input_text = "ministers from the european union and its mediterranean neighbors gathered here under heavy security on monday for an unprecedented conference"
original_summary = "eu mediterranean nations meet for first-ever conference on cooperation."

# Load the Hugging Face BART model
# Load model, tokenizer, and model_wrapper
model = transformers.BartForConditionalGeneration.from_pretrained("facebook/bart-large-cnn")
tokenizer = transformers.BartTokenizer.from_pretrained("facebook/bart-large-cnn")
model_wrapper = textattack.models.wrappers.HuggingFaceModelWrapper(model, tokenizer)

# Specify the attack recipe and constraints
attack_recipe = Seq2SickCheng2018BlackBox.build(model_wrapper)

# Run the attack
result = attack_recipe.attack(input_text, original_summary)

# Print the result
print(result.__str__(color_method="ansi"))


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

No branches or pull requests

1 participant