liveBook · Manning

Adversarial input

As explained in Generative AI in Action

An adversarial example is an input modified or crafted to cause a machine-learning model to produce an incorrect or undesirable output.

An adversarial input is crafted or modified to test whether a machine-learning model produces an incorrect, unsafe, or otherwise undesirable output. In enterprise GenAI, adversarial inputs support robustness and security testing rather than ordinary user interaction. section 13.0 section 13.4.2

Use adversarial inputs as part of red-teaming:

  • Generate adversarial inputs with TextAttack, a Python framework supporting adversarial attacks, examples, and NLP data augmentation. section 13.4.2
  • Evaluate how consistently an LLM handles bad inputs, edge cases, and other conditions that may produce unexpected outputs. section 13.4.2
  • Combine attack testing with model evaluation, fairness audits, explainability, and data augmentation to investigate broader risks. section 13.4.2
# Run all compatible attacks against Llama 2 7B Chat using a SLURM cluster
python ./scripts/run_pipeline.py --methods all --models 
llama2_7b --step all --mode slurm

# Generate and evaluate completions using a SLURM cluster
python ./scripts/run_pipeline.py --methods all --models 
baichuan2_7b,mistral_7b,llama2_70b --step 2_and_3 --mode slurm

The supplied pipeline listing shows how compatible attacks and completion evaluation can run across several language models on a SLURM cluster. section 13.4.2

How Generative AI in Action covers it

How deep it goes
Defines adversarial attacks and names generation tools, but does not explain attack algorithms or mathematical internals.
Examples
Uses TextAttack and a SLURM pipeline to run attacks and evaluate completions across Llama 2, Baichuan2, Mistral, and other models.
What you can do after
Apply it via TextAttack and attack pipelines to evaluate model resilience against problematic inputs.
How it connects
Connects adversarial inputs with red-teaming, robustness, model evaluation, data augmentation, fairness audits, and explainability.

Also explained in

Compare how 5 books explain adversarial input →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Generative AI in Action. The section links point to the parts of the book it draws on.