Skip to main content

Using Abstraction to Get Better Results From AI

· 8 min read
Eason Taylor
AppSec Specialist

The internet is built on layers upon layers of abstraction. This makes it possible for an immense variety of people and machines to communicate with one another. I want to share some ways I've used abstraction to help me get better results from artifical intelligence (AI).

Priorities

With the recent surge in the capabilities and prevalence of

GenAI
in the last two years, I've been looking for ways it can make me more productive.

GenAI vs Generalized AI

'GenAI' means Generative AI, which is a type of artificial intelligence (AI) that can create things like text, code, videos, etc. It is not to be confused with Generalized Artificial Intelligence (AGI), which refers to the theoretical concept of AI that demonstrates human-like intelligence and capabilities across multiple fields or domains. To learn more about AGI, read about it here!

Whenever I use GenAI to create something, I have two main priorities:

  1. Security

  2. Accuracy

    • AI has a remarkable ability to produce inaccurate content with astounding confidence. Carefully-crafted prompts can help you increase your chances of getting good results.

Because those two things are so important to me, I avoid sharing overly-specific information in my interactions with AI. This originally came from my desire to preserve privacy and security, but I found that it yielded unexpected improvements in the area of accuracy as well.

The power of abstraction

I recently watched a video interview in which computer scientist David J. Malan explained how the internet is built on layers upon layers of patterns and ideas, which he calls abstraction.

In the video, he talks about how everything we see on the internet comes from from data like 1s and 0s. That data follows certain patterns that allow it to become something much more rich and meaningful. Thanks to that technology, millions of different kinds of people and machines can communicate with one another in a way they can all understand. I highly suggest watching the 1-minute clip from that video below.

Watch the video

The clip I talked about — 'How do zeros and ones turn into the internet?' — lasts just over a minute.

By taking a similar approach to communicate with AI, using patterns instead of specific data, I have been able to achieve greater security and accuracy.

Examples

Here are two examples of how I've recently used this strategy to achieve desirable results with AI.

1) Manipulating a graph

I recently had to alter the structure of a large graph with tons of nodes with relationships between them. Essentially, my task was to take something that looked like this:

A picture of a graph with the old structure

and turn it into this:

A picture of a graph with the new structure

It seems like it wouldn't take too long, doesn't it? Well, the tricky part is the graph I had to alter looked more like this:

A picture of an insanely large graph

As I'm sure you can imagine, I knew that it would be impossible for me to do that task unaided. I would surely end up taking tons of time and committing countless errors along the way. So of course, I thought "Hey, I'll get AI to help!" But I couldn't just share the data with ChatGPT. First of all, it was way too much data to share with it directly, and second, the data was sensitive, so I had to protect the actual data in the graph.

To solve these problems, I asked AI to write a Python script to edit the data for me! I'm learning Python, but my skills aren't to the point where I could do this myself, and I knew that AI would be able to write and iterate upon the script much more quickly than I could. Here's what the process looked like:

  1. To start, I came up with an abstract example of the type of graph I wanted the script to alter (like the simplified examples I showed above). These simplified examples had all the sensitive information stripped out, with just enough structure to help the AI know what I needed it to do.
  2. I crafted a descriptive prompt explaining the type of data I was working with, included the example data, and carefully explained exactly the types of changes I wanted it to make, and the ones I wanted it not to make. In this explanation, I made sure to use patterns wherever possible to keep my instructions generalized.
  3. I tested the script and gave feedback, describing the results enough to help the AI understand what went wrong, and kept what worked.

After a little back-and-forth with the AI as I tested the script, I was able to achieve exactly what I needed with 100% accuracy, in a fraction of the time it would have taken me to do it myself, and without compromising the confidentiality of the graph data.

2) Organizing an email list

In another project recently, I had to take an unorganized list of 1800 email addresses and group them by domain. The list contained individual email addresses — in no particular order — of people that worked at different organizations. I needed to figure out which email addresses belonged to which organizations, and group them together by organization.

So, once again, I went to AI for help. And instead of giving it the raw data, I asked it for a Python script to help me organize the data. Here's how I did it:

  1. I gave the AI an example of the data I had with a general explanation.
    • "I have a spreadsheet with 1800 email addresses. They're all in a column titled email. . ."
  2. I included a thorough explanation of what I wanted with another example of the outcome data.
    • ". . . I want you to write a Python script to organize the emails by domain. The output file should have 1 column titled domain and another column called emails with the email addresses belonging to that domain separated by semicolons. For example: [email protected]; [email protected]; [email protected]
  3. And then I went back and forth with the AI to give it feedback.
    • In this particular example, I actually got exactly what I wanted on the first try! The iteration came later when my requirements changed, but I was able to simply follow the other steps again to revise my results to fit my needs.

The Process

This process I've developed has become one that I regularly follow in my work with AI. Here's how I would break it down:

  1. Create an abstract model of your desired outcome.
    • Give the AI somewhere to start. This helps it get the structure and format right, and helps you protect the specific details of your important data.
    • If you're manipulating existing data, give it examples of the before and after (again, like you saw with my example above.)
  2. Craft a descriptive prompt that uses patterns to outline requirements.
    • It's a good idea to give lots of guidance. The more guidance you give, the more reliable your results will be. Luckily, you can edit your prompt and try again if the AI doesn't give you the results you want the first time.
  3. Give feedback and work with the AI to revise your strategy
    • AI probably won't get it right on the first try. Keep working at it! Tell it what went wrong and what you want it to change. As you make small tweaks, you'll see improved results very quickly.

I encourage you to try out that process for yourself! I'm confident that it'll help you increase your productivity, security, and accuracy in your use of GenAI. Lastly, I'll include some bonus tips below that help me when I work with AI.

Bonus Tips

Ask for a script you can run on your computer if you're processing large amounts of data.

Asking AI to give you a script helps when you're processing large amounts of data, because I've found that AI will mess up and miss details when you ask it to process raw data on its own.

Tell it to write debugging statements into the script.

Most of the time, AI won't get the script right on the first try. Get it to write debugging statements into the script, and then if you encounter errors, send those errors right back to the AI for it to work on.

Save versions of your work as you go.

Sometimes when you ask AI to change something, and then change another thing later, it might get rid of previous changes it made based on your feedback. It can help to save a new copy of whatever it gives you every time it makes a change so you can go back to it if the AI messes up. You can also help it by sending the current version of the script again every time you ask for a new change. That way it'll start from where you're at and it's less likely to remove things it added previously.