Adversarial Search in NLP

Learn via video courses
Topics Covered

Overview

In many situations, we have to search more than one entity, then comes in picture the Adversarial Search. Often we come across situations where we have more than one agent and all of the agents are searching for the solution or the entity in the same search space, we use the technique of Adversarial Search. Since all the entities involved are searching for the same thing, a conflict arises between achievement and goal. Formally, we can define Adversarial Search as a situation in which there are two or more two players involved with a conflicting goal, and all of them are trying to search within the same search space for gaining the solution. The Adversarial Search is also called a game.

Pre-requisites

Before learning about the adversarial search in NLP, let us first learn some basics about NLP itself.

  • NLP stands for Natural Language Processing. In NLP, we analyze and synthesize the input and the trained NLP model then predicts the necessary output.
  • NLP is the backbone of technologies like Artificial Intelligence and Deep Learning.
  • In basic terms, we can say that NLP is nothing but the computer program's ability to process and understand the provided human language.
  • The NLP process starts by first converting our input text into a series of tokens (called the Doc object) and then performing several operations on the Doc object.
  • A typical NLP process consists of various stages like tokenizer, tagger, lemmatizer, parser, and entity recognizer. In every stage, the input is the Doc object and the output is the processed Doc.
  • Every stage makes some kind of respective change to the Doc object and feeds it to the subsequent stage of the process.

Introduction

In the world of NLP, we often come across situations where we have to search for a particular thing in the input sequence or the data set (for example training data set, etc.). So, if we are searching for a single entity then we can perform a normal search in the entire search space. The normal search has some rules, algorithms, and heuristics to find the required entity.

In many situations, we have to search more than one entity, then the Adversarial Search in NLP comes in. Often we come across situations where we have more than one agent and all of the agents are searching for the solution or the entity in the same search space (for example in a game where all the users are trying to find the destination), we use the technique of Adversarial Search in NLP.

Let us learn more about it in detail in the next sections.

What is Adversarial Search?

The Adversarial Search in NLP involves more than one entity or agent searching for a particular thing. Since all the entities involved are searching for the same thing, a conflict arises between achievement and goal. This type of problem widely arises in the world of gaming where these involved entities are pitched around each other and the approach of the game or the individual's strategy varies and depends on the opponent's move. We can take an example of the snakes and ladder game where all the entities are trying to reach the mark 100, and all of them are trying to reach it first.

In the Adversarial Search in NLP, an individual or a player may take a minimizer role or a maximizer role and the selection of the role depends on the type of the game, the intentions of the opponent, and the involved situation. As the name suggests, the minimizer will always try to minimize the damage and hence minimize the loss. On the other hand, the maximizer will always try to maximize the gain.

Adversarial Search is mainly made for dealing with multi-agent environments. A multi-agent environment is a type of environment where more than one agent is involved. In such an environment, each agent is playing as an opponent to the rest of the agents. Hence, each agent considers the action of the rest of the agents, and the action of the rest of the agents affects their performance.

Formally, we can define Adversarial Search as a situation in which there are two or more two players involved with a conflicting goal, and all of them are trying to search within the same search space for gaining the solution. The Adversarial Search is also called a game.

How does it Work?

Let us now see the working of a game or the Adversarial Search in NLP. The game Adversarial Search is also a type of search in the field of Artificial Intelligence.

  • Start of the game: The starting point of the game and here we deal with the initial state and initial configuration of the game. For example, all the players will have 5 lives to complete the game and 2 minutes to reach the destination. In many games, the obstacles and opponents are also the same for each player and this also comes at the start of the game part.
  • Players: The players involved in the game space.
  • Action: It indicates all the actions and the moves that a player can perform within the game space.
  • Result: It indicates the result or the outcome of the players' movements.
  • Terminal Test: The terminal test is used to check whether the game is over or not. It checks the final move for the result.
  • Utility: The utility is used to denote the final result of the game in terms of win or loss for the individual players.

What is TextAttack in Adversarial Search?

Before learning about adversarial attacks and TextAttack in Adversarial Search, we must be familiar with the concept of Adversarial perturbation.

An adversarial perturbation is an example that is crafted as a change to a benign input. The Adversarial Examples are usually designed as inputs to fool a machine or machine learning model. We can say that the adversarial perturbation is a subset of the adversarial example. All the classes of adversarial examples also include the inputs that are designed to fool a machine learning model.

Now, a TextAttack is an example of an attack that generates a specific kind of adversarial example i.e. adversarial perturbation. In a more generalized way, we can say that adversarial attacks are the processes implemented on the machine learning model to generate the adversarial perturbations. The TextAttack performs an iteration over the provided data set that contains a list of inputs provided to the machine learning model. The TextAttack iterates over the data set and searches for the adversarial perturbation whenever a correctly predicted sample is encountered. It does not attack or search for the adversarial perturbation if there is an incorrectly predicted sample as the machine learning model is already fooled due to the incorrect sample.

This TextAttack helps to break the process into stages so that each stage can be managed easily. It not only breaks the process into stages but also provides a system for the interchangeable components so that the management part becomes easier.

Generating Adversarial Examples

As we know, the TextAttack is an example of an attack that generates specific adversarial examples. The TextAttack is used to train the NLP models and make them more robust. We can define the overall process of an adversarial attack using the four components- constraint, goal function, transformation, and the search model. With the help of these four components, we can reuse various things across the various research papers. It not only helps to train the model well but also helps to develop various methods for data augmentation in NLP.

Refer to the image provided below to get an overview of the various functionalities of the TexAttack and Adversarial example.

generating adversarial examples

We integrate the machine learning training code along with the adversarial attacks and data augmentation techniques to provide an environment for testing the adversarial training, and TestAttack(s) in various scenarios.

The Future of Adversarial Attacks in NLP

With the help of Adversarial Attacks, we can explore a lot of cross-platform and cross-comparison of research easily. For example, we can easily compare the performance of research paper A with research paper B with the help of Adversarial Attacks in NLP.

The main focus is on the English language adversarial attacks, in the future these attacks and research can be carried forward for various other languages.

Advantages and Disadvantages of Adversarial Search in NLP

Let us now learn the advantages and the disadvantages of Adversarial Search in NLP.

  • The adversarial systems are lesser prone to abuse and hence it does not support favoritism.
  • The adversarial search logic observed the rights of the prosecuting parties and the defending parties. Hence, it can be used for advising the courts.
  • The adversarial search can be used for helping the police as it will help them in non-bias judgment.
  • There is no scope for bias in the adversarial search hence it can be helpful to build strategies in various scenarios.
  • The adversarial search uses a tedious process to get to the result hence should not be used in simpler situations.
  • The adversarial search performs the analysis and provides the judgment according to the inputs of the lawyers from both sides hence a good lawyer can get benefit and win.

Uses Case of Adversarial Search in NLP

Let us now learn the use cases of Adversarial Search in NLP.

  • In game-based scenarios and other such competitive environments, we use Adversarial Search to find the optimal result.
  • The Adversarial Search is also the backbone for the development of many new technologies such as Alpha-Beta Pruning, etc.
  • The maximize gain concept of the Adversarial Search is used to gain the maximum profit in case of hard negotiations. Hence it can give benefit people who do intelligent negotiations.
  • The Adversarial Search is also used in the field of the business environment for sourcing buyers and suppliers for services and products in a competitive environment.
  • It is also used in the field of legal systems. The jury or the judgment team uses this technique to analyze and examine the whole scenario of both the involved parties. Based on the analysis, the judgment is passed.

Conclusion

  • Often we come across situations where we have more than one agent and all of the agents are searching for the solution or the entity in the same search space, we use the technique of Adversarial Search.
  • We can define Adversarial Search as a situation in which there are two or more two players involved with a conflicting goal, and all of them are trying to search within the same search space for gaining the solution. The Adversarial Search is also called a game.
  • Since all the entities involved are searching for the same thing, a conflict arises between achievement and goal.
  • In the Adversarial Search, an individual or a player may take a minimizer role or a maximizer role and the selection of the role depends on the type of the game, the intentions of the opponent, and the involved situation.
  • Adversarial Search is mainly made for dealing with multi-agent environments. A multi-agent environment is a type of environment where more than one agent is involved. In such an environment, each agent is playing as an opponent to the rest of the agents.
  • The Adversarial Search is used in the field of the business environment for sourcing buyers and suppliers for services and products in a competitive environment. It is used in the field of legal systems. The jury or the judgment team uses this technique to analyze and examine the whole scenario of both the involved parties. Based on the analysis, the judgment is passed.