Home » Creating an AI Disinformation Agent: A Cautionary Experiment Exploring the Energy (and Risks) of Generative AI. | by Sre Chakra Yeddula | Sep, 2023

Creating an AI Disinformation Agent: A Cautionary Experiment Exploring the Energy (and Risks) of Generative AI. | by Sre Chakra Yeddula | Sep, 2023

by Narnia
0 comment
AI Disinformation Agent ; June 2023 undertaking

Disclaimer: This article particulars an experiment performed purely for instructional functions, desiring to make clear potential misuses of generative AI. It’s crucial to grasp the related dangers and be vigilant in opposition to deceptive data on-line.

I don’t endorse this device for any prison or criminal activity.

This web site ( fakeBBC.com) just isn’t the true BBC.com. It is up to date each hour by means of an AI agent that duplicates the unique BBC web site and updates (utilizing #generativeAI) all of the headlines and blurbs to imply the alternative of what they had been initially.

We are effectively and actually within the period of synthetic intelligence. Large Language Models have ushered in an period of unprecedented use instances for AI.
Generative AI functions encompass us, from chatbots to artwork, enterprise functions to Music. The extent to which we will apply generative AI has appeared limitless. Over the previous few months, I’ve been experimenting with the alternative ways to make use of GenAI, from writing books, producing podcasts, and creating AI improvisers to growing an superior meal planner app. For the June 2023 month’s undertaking, I needed to sort out a extra critical and unfavorable utility of Generative AI. I needed to discover and research how dangerous actors might use Generative AI to create extremely convincing disinformation campaigns. I needed to to actually perceive the true price and energy of growing and operating a completely autonomous “AI Disinformation Agent”, In constructing it out, we can discover the methods we will higher equip ourselves in opposition to this slightly actual menace. Like any device developed for progress, there’s all the time a aspect that’s exploited for dangerous functions. This experiment will discover that aspect of generative AI.

To spotlight this concern, I launched into an experiment: making a faux model of the BBC’s web site, “ fakebbc.com.” The idea? Each hour, fetch the content material from the true BBC web site and use GenAI to vary or modify the headlines and blurbs, thereby altering the that means of each story. I needed to maintain the modifications refined to boost the believability of the faux model of the articles. The outcomes had been astounding and scary!

AI Disinformation Agent
Real and pretend bbc.com comparability

A Deep Dive into the Experiment’s Mechanics

Let’s dive deep into the method and the applied sciences we used to provide you a clearer image of how I executed this experiment.

  • Setting Up the Infrastructure: Our experiment revolved across the AWS ecosystem. AWS Lambda capabilities shaped the spine, triggering and performing particular duties at scheduled intervals.
  • AWS Lambda for Web Scraping: One AWS Lambda was set as much as scrape the BBC web site at common intervals.
  • AWS Lambda for Content Modification: Another Lambda operate was liable for invoking the OpenAI API, searching for to reverse the that means of the headlines.
  • S3 for Hosting: AWS S3 hosted our faux BBC web site, guaranteeing it was publicly accessible.
  • Web Scraping with Python: Python, with the Beautiful Soup library, extracted headlines and summaries from the BBC.
import requests
from bs4 import BeautifulSoup
import boto3

def lambda_handler(occasion, context):
# Define the URL to scrape
url = 'https://www.bbc.com/'

# Get the webpage content material
response = requests.get(url)
response.raise_for_status() # increase exception if invalid response

# Parse the webpage content material with BeautifulSoup
soup = BeautifulSoup(response.content material, 'html.parser')

# Serialize the content material (you too can refine this to get extra structured knowledge)
serialized_content = str(soup)

# Save the content material to S3
s3_bucket_name = 'YOUR_S3_BUCKET_NAME'
s3_file_name = 'bbc_front_page.html'

s3_client = boto3.shopper('s3')
s3_client.put_object(Bucket=s3_bucket_name, Key=s3_file_name, Body=serialized_content)

return {
'standingCode': 200,
'physique': 'Scraping accomplished and content material saved to S3!'
}

  • GenAI Content Manipulation: With the content material in hand, the following step was to “twist” it. Leveraging OpenAI’s GPT-3 mannequin, we “requested” the AI to reinterpret the content material with an reverse that means.
import boto3
import requests
from bs4 import BeautifulSoup

OPENAI_API_URL = "https://api.openai.com/v1/completions"
OPENAI_API_KEY = "OPENAIKEY" # Replace together with your OpenAI API key

def get_opposite_text(textual content):
# Construct the immediate for OpenAI
immediate = f"Rewrite this assertion to convey the alternative that means: '{textual content}'?"

headers = {
"Authorization": f"Bearer {OPENAI_API_KEY}",
"Content-Type": "utility/json"
}

knowledge = {
"immediate": immediate,
"max_tokens": 150, # Limit the output size
"mannequin":"text-davinci-003"
}

response = requests.publish(OPENAI_API_URL, headers=headers, json=knowledge)
response.raise_for_status()

opposite_text = response.json().get("decisions")[0].get("textual content").strip()
return opposite_text

def insert_disclaimer(soup):
# Find the h1 tag with the given id
h1_tag = soup.discover('h1', id="page-title")

if h1_tag:
# Create the brand new disclaimer div
disclaimer_div = soup.new_tag("div")
disclaimer_div['class'] = "disclaimer"
disclaimer_div['style'] = "background-color: #f2f2f2; padding: 10px; text-align: middle;"

p_tag = soup.new_tag("p")
p_tag.string = "Disclaimer: The contents on this web site are altered from unique sources (BBC) utilizing AI. This web site is solely for instructional functions."

disclaimer_div.append(p_tag)

# Insert the disclaimer div after the h1 tag
h1_tag.insert_after(disclaimer_div)

return soup

def lambda_handler(occasion, context):
# Fetch the saved content material from S3
s3_bucket_name = 'fakebbc.com'
s3_source_bucket_name = 'SOURCEBUCKET'
s3_file_name = 'bbc_front_page.html'
s3_client = boto3.shopper('s3')
s3_file_new_name='index.html'

response = s3_client.get_object(Bucket=s3_source_bucket_name, Key=s3_file_name)
raw_html = response["Body"].learn().decode()

# Parse the content material with BeautifulSoup
soup = BeautifulSoup(raw_html, 'html.parser')

# Insert the disclaimer
soup = insert_disclaimer(soup)

# Find headlines
media_contents = soup.find_all('div', class_='media__content')

for media_content in media_contents:
headline_tag = media_content.discover('a', class_='media__link')
if headline_tag:
original_headline = headline_tag.get_text(strip=True)
opposite_headline = get_opposite_text(original_headline)
headline_tag.string.replace_with(opposite_headline)

summary_tag = media_content.discover('p', class_='media__summary')
if summary_tag:
original_summary = summary_tag.get_text(strip=True)
opposite_summary = get_opposite_text(original_summary)
summary_tag.string.replace_with(opposite_summary)

# Serialize the modified content material
modified_content = str(soup)

# Optionally, save the modified content material again to S3 or elsewhere
s3_client.put_object(Bucket=s3_bucket_name, Key=s3_file_new_name, Body=modified_content,ContentType='textual content/html',ACL='public-read')

return {
'standingCode': 200,
'physique': 'Content modified efficiently!'
}

  • Automating the entire course of: Once we had each our Lambda capabilities and our S3 buckets arrange. We used AWS step capabilities and AWS Eventbridge to automate this process at common intervals.
  • Publish the Content: Once the content material was prepared, we arrange AWS route53 to create and direct to the URL and content material. The consequence? A mirror web site that, at first look, appears to be like an identical to the BBC however carries fully completely different (and deceptive) information. see some examples.
comparision of faux disinformation utilizing AI

While our experiment had a goal of studying, the implications are far-reaching and scary. Imagine a world the place dangerous actors create complete faux information web sites, just about indistinguishable from the unique. Such disinformation can erode belief, incite panic, and even sway public opinion.

GenAI can craft information, critiques, or feedback that may artificially inflate or deflate inventory costs, create unwarranted well being scares, or manipulate election outcomes. The potentialities are infinite, and the results, dire.

The fakebbc.com experiment underscores a vital lesson: within the digital age, vigilance is paramount. Here’s how we will equip ourselves:

  1. Cross-Verify Information: Before believing or sharing information, be certain that it’s corroborated by a number of respected sources.
  2. Educate Ourselves: Awareness of instruments like GenAI and their capabilities could be our first line of protection.
  3. Be Skeptical: If a chunk of data appears too outlandish or too good to be true, it most likely is.
  4. Use Verification Tools: Several fact-checking web sites and instruments may also help authenticate information.
  5. Stay Updated: As AI evolves, so will the techniques to misuse it. Regularly updating ourselves on the most recent in expertise and cybersecurity can maintain us a step forward.

What I’ve realized from June’s undertaking is a nuanced understanding of the completely different capabilities of Generative AI (Good and Bad). It has additionally cemented the notion of expertise being a device that takes the aim of its wielder. #DoGood #AI4Good.

BONUS TECHNICAL CONTENT

While we’re on the subject. I needed to verify I captured all of the steps vital for growing a lambda domestically after which pushing it to the AWS setup.

  • Setup Python Virtual Environment: As earlier than, in your Visual Studio Code terminal, navigate to your undertaking listing and arrange a digital setting. This ensures the Lambda operate has all of the required dependencies packaged with it.
python3 -m venv venv supply venv/bin/activate 
# On Windows, it might be: venvScriptsactivate
  • Install Required Libraries: Install the libraries wanted for this Lambda operate.
pip set up boto3 requests beautifulsoup4
  • Write the Lambda Code: Save the supplied script as, for instance,
pythoncode_lambda.py.
  • Package the Lambda Function: Create a deployment package deal containing the code and the required libraries. First, you’ll need to deactivate the digital setting.
deactivate
  • Next, create a ZIP package deal:
cd venv/lib/python3.x/site-packages 
# Navigate to the site-packages listing of the venv
zip -r9 ${OLDPWD}/operate.zip . # Zip all of the dependencies
cd $OLDPWD # Navigate again to your undertaking listing
zip -g operate.zip modify_content_lambda.py # Add your lambda operate code to the ZIP
  • Upload to AWS Lambda:-Go to the AWS Management Console.-Navigate to Lambda.Click “Create operate”.-Fill within the vital particulars similar to operate identify, runtime (Python 3.x).-In the “Function code” part, add the operate.zip you created.-Set the handler as pythoncode_lambda.lambda_handler.-Assign an IAM position that has permissions to learn from and write to the S3 bucket, and make sure the Lambda can entry the web (to name the OpenAI API).-This would possibly imply organising a VPC with the proper safety group settings.-Increase the timeout as wanted, particularly should you’re processing a number of headlines/summaries.-Save the operate.
  • Set Up Environment Variables or AWS Secrets Manager: Instead of hardcoding the OpenAI API key, it’s safer to make use of AWS Lambda’s setting variables or AWS Secrets Manager to retailer the important thing.

You may also like

Leave a Comment