Remember the days when we all spent hours analyzing keywords in Excel or OpenRefine? Scrolling through thousands of rows, manually categorizing and evaluating relevance... Fortunately, those days are behind us. AI can now incredibly simplify and streamline this entire process.

Below I'm sharing a practical script that will help you get started with AI-powered keyword research.

Just copy it into Jupyter Notebook and you can start experimenting. If you're not an experienced programmer, don't worry - when you get stuck, use ChatGPT or another AI assistant to help customize the script exactly to your needs.

What's the magic in this?

The main advantage is the ability to process huge amounts of data at once. You can take a complete keyword export from Ahrefs or another SEO tool (easily tens of thousands of items) and let AI automatically classify them for you. You then work only with the filtered output, saving you hours of manual work.

AI often reveals connections between keywords that you might easily overlook during manual analysis. This helps you better understand user intent and structure your content more effectively.

How to get started with this script?

  1. Install Jupyter Notebook - the easiest way is to download the Anaconda distribution, which includes Jupyter and all the necessary libraries
  2. Create a new notebook and copy the code below into it
  3. Get an API key from OpenAI:
    • Register on the OpenAI Platform
    • Generate a new key in the API keys section
    • Save the key to a .env file in the same directory as your notebook (format: OPENAI_API_KEY=your_key_here). Alternatively, you can enter the key directly when prompted by the script
  4. Prepare your data - save your keyword file as keywords.csv in the same directory (make sure it contains a column named "Keyword")
  5. Adjust the prompt - customize the product categories and domain description in the configuration section of the script. If you're unsure, let ChatGPT modify the prompt according to your needs. You can work real magic with this.
  6. Run the script and watch AI automatically classify your keywords

Within moments, you'll have the foundation for professional keyword research that would otherwise take hours of manual work. All it takes is a few clicks and a bit of experimentation!

And now, the promised code:

Step 1: Install Packages

# Run this cell first to install required packages
!pip install python-dotenv pydantic tqdm pandas openai

Step 2: Configuration

Here you'll customize the prompt as needed. Let your imagination run wild.

This post is for subscribers only

Sign up now to read the post and get access to the full library of posts for subscribers only.

Sign up now Already have an account? Sign in