textattack.goal_function_results package
Goal Function Result package:
Goal function results report the result of a goal function evaluation, indicating whether an attack succeeded for a given example.
ClassificationGoalFunctionResult Class
- class textattack.goal_function_results.classification_goal_function_result.ClassificationGoalFunctionResult(attacked_text, raw_output, output, goal_status, score, num_queries, ground_truth_output)[source]
Bases:
GoalFunctionResult
Represents the result of a classification goal function.
- get_colored_output(color_method=None)[source]
Returns a string representation of this result’s output, colored according to color_method.
GoalFunctionResult class
- class textattack.goal_function_results.goal_function_result.GoalFunctionResult(attacked_text, raw_output, output, goal_status, score, num_queries, ground_truth_output, goal_function_result_type='')[source]
Bases:
ABC
Represents the result of a goal function evaluating a AttackedText object.
- Parameters:
attacked_text – The sequence that was evaluated.
output – The display-friendly output.
goal_status – The
GoalFunctionResultStatus
representing the status of the achievement of the goal.score – A score representing how close the model is to achieving its goal.
num_queries – How many model queries have been used
ground_truth_output – The ground truth output
- abstract get_colored_output(color_method=None)[source]
Returns a string representation of this result’s output, colored according to color_method.
- class textattack.goal_function_results.goal_function_result.GoalFunctionResultStatus[source]
Bases:
object
- MAXIMIZING = 2
- SEARCHING = 1
- SKIPPED = 3
- SUCCEEDED = 0
TextToTextGoalFunctionResult Class
text2text goal function Result
- class textattack.goal_function_results.text_to_text_goal_function_result.TextToTextGoalFunctionResult(attacked_text, raw_output, output, goal_status, score, num_queries, ground_truth_output)[source]
Bases:
GoalFunctionResult
Represents the result of a text-to-text goal function.
- get_colored_output(color_method=None)[source]
Returns a string representation of this result’s output, colored according to color_method.