Add support for prompt augmentation #766
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Summary
This PR adds support for augmenting prompts in TextAttack as well as using these augmented prompts to run LLMs. Note that the design is slightly different than previous offline discussions. Notably, this change reuses the existing
Augmenter
class to leverage existing recipes and code. An example (copied from a new test) is below:Additions
llms
module with a wrapper for HuggingFace and OpenAIprompt_augmentation
module with a pipeline to augment a prompt and run the augmented prompts on a LLMUnmodifiableIndices
andUnmodifiablePhrases
to give users the options to restrict certain parts of a prompt from being augmentedChanges
AttackedText
to fix a bug inconvert_from_original_idxs
as the type argument inininstance
must be a tuple if multiple types are providedTo-Do
Checklist
.rst
file inTextAttack/docs/apidoc
.'