QData / TextAttack

TextAttack 🐙 is a Python framework for adversarial attacks, data augmentation, and model training in NLP https://textattack.readthedocs.io/en/master/
https://textattack.readthedocs.io/en/master/
MIT License
2.98k stars 397 forks source link

argument error? in PSO attack->perform_search->_turn #753

Open nohuma opened 1 year ago

nohuma commented 1 year ago
            if np.random.uniform() < P1:
                # Move towards local elite
                population[k] = self._turn(
                    local_elites[k],
                    population[k],
                    turn_prob,
                    initial_result.attacked_text,
                )

            if np.random.uniform() < P2:
                # Move towards global elite
                population[k] = self._turn(
                    global_elite,
                    population[k],
                    turn_prob,
                    initial_result.attacked_text,
                )

In this code block: textattack.search_method class ParticleSwarmOptimization(PopulationBasedSearch).perform_search() But it doesn’t match the input of another function: ParticleSwarmOptimization._turn its input param = source_text, target_text, prob, original_text, above code the input param are in the order of local_elites[k] and population[k], is this right?