Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions textattack/attack_recipes/clare_li_2020.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,9 @@ def build(model):

# "A common choice of sim(·,·) is to encode sentences using neural networks,
# and calculate their cosine similarity in the embedding space (Jin et al., 2020)."
# The original implementation uses similarity of 0.7. Since the CLARE code is based on the TextFooler code,
# we need to adjust the threshold to account for the missing / pi in the cosine similarity comparison
# So the final threshold is 1 - arccos(1 - 0.7) / pi = 0.904507034.
# The original implementation uses similarity of 0.7.
use_constraint = UniversalSentenceEncoder(
threshold=0.904507034,
threshold=0.7,
metric="cosine",
compare_against_original=True,
window_size=15,
Expand Down
2 changes: 1 addition & 1 deletion textattack/attack_recipes/textbugger_li_2018.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ def build(model):
#
# Greedily swap words with "Word Importance Ranking".
#
search_method = GreedyWordSwapWIR()
search_method = GreedyWordSwapWIR(wir_method="delete")

return Attack(goal_function, constraints, transformation, search_method)