AI keyword clustering for SEO

Table of Contents

One of the tasks that you probably find most time consuming and annoying in SEO is keyword clustering.


If you’ve ever had to do this with thousands or tens of thousands of terms, you know what we’re talking about.


It’s a nightmare.


And a drain on hours and resources.


That’s why we’ve prepared a Python script so that thanks to Google Colab you can automate keyword clustering with AI.


Finally, you will avoid having to manually check each word of your keyword research one by one to group them.

Let’s see what we are talking about:

Keyword clustering through artificial intelligence with Python

To make use of the script, you will only need:


  1.  Your keyword list (at the end of this article you will find a template where to paste your keywords)
  2. and an OpenIA Api key.


As you can see, two very simple requirements.

Content script functions to categorise keywords:

Now, we are going to explain you what tasks are executed by the script programmed by our Head of SEO Alvaro Peña de Luna:

image3 1
  1. Import the keywords from your file “Keywords.csv”.
  2. Generate the categories to sort the set of keywords into
  3. Returns the name of the categories to group the keywords into
  4. Assigns the keyword to the category created in the previous step

Well, as you can see, the code performs 4 tasks that otherwise can take hours.


A great idea, don’t you think?


Now let’s see the steps you need to take advantage of something so powerful.

Steps before running the script to cluster keywords:

The first thing you need to do is run the Python code in your browser using Google Colab. 


We recommend you to check our article on How to get keyword search intent with AI, where we explain it step by step


Also in the next section we explain to you how to run it step by step or if you prefer you can go directly to the video.

Anyway, leave us a comment with your doubts if you don’t manage to run it correctly.

image2 3

We will use the same .csv template in a completely different scenario. 


But we will still use Natural Language Processing (NLP) with artificial intelligence, 


And remember…

Save a copy of .csv file as “keywords.csv”. Be careful not to include (1) if such a file already exists on your computer.

Let's go to our Colab and run script

Let’s get down to business… Quickly cluster a whole list of keywords. To do so, follow these points:
  1. Create a list of keywords: to run the script, you will need a .CSV file with a header called “keywords” (at the end of this article, you will find a template to download).
  2. Obtain an OpenAI key (you need to have an OpenAI account and API key to be able to use the GPT-3 language model) if you don’t already have one.
  3. Make a copy of the file we provide, save it as a CSV and run the code in Colab: you must access Colab in tools and run each cell by clicking on “Play” in the top left corner.
  4. Install the dependencies: you must install all the dependencies needed to run the code. This is done by clicking on the corresponding cell and waiting for it to run without errors.
  5. Upload the CSV file with your keywords: the CSV file with the keywords must be uploaded by clicking on “Upload” in the corresponding cell and selecting the file.
  6. Set the necessary parameters for the correct functioning of the script: This includes the OpenAI secret key and the modification of the CSV file format.
  7. Execute the first prompt: the first prompt must be executed to create an empty list of keyword categories and batch counters.
  8. Run the second prompt: once you have the list of keywords, run the second prompt to categorize the keywords according to their similarity.
  9. Call OpenAI: OpenAI must be called to obtain the categories to which the keywords belong.
  10. Format the response: the response obtained from OpenAI must be formatted to display the categories in a readable format.
  11. Iterate until all the keywords are used: iterate until all the keywords are used and all the categories are obtained.
Once you have done these steps, you will have clustered the keywords with a very high level of quality.

Written in this way, it seems very complicated, but we have prepared a short explanatory video with a demo of the process so that you can better understand the script and know how to execute it:

Script and template for clustering with AI Download

Here are the links to the script and the template for the keywords you will need:

What problems can I encounter when running content scripts?

  • Google Colab does not locate .csv file: Sometimes, the generated CSV file may have a different encoding or elements that corrupt it and make it unreadable. To solve this problem, a demo file can be used to test the tool.
  • OpenAI is not fully operational: sometimes it cannot cope with the multitude of requests it receives from all over the world. Be patient, it usually takes a short time to be at full capacity
Would you like to join us and join us in the analysis of clusters?

What is a cluster?

Simply put, a cluster is a group of objects or data that share similar features. 


In the case of keyword clustering, these groups are made up of words or terms that are highly semantically related to each other.


It is important to differentiate between classification and clustering.

  •  Classification refers to the assignment of an object to a predefined category.
  • Clustering involves grouping objects into categories that are not previously defined.


In this manner, we avoid observer bias.

So: What is keyword clustering with AI?

Keyword clustering is the process of grouping keywords into clusters based on their semantic similarities. This helps to organize and structure keyword data for SEO and content strategy purposes.


Thanks to AI tools, as you have seen, you can analyze huge keyword lists much faster and more accurately than with your own eyes.


This allows you to complete keyword clustering tasks fast and efficiently.

How AI improves keyword clustering

AI algorithms can learn from data and improve over time, making keyword clustering more accurate and relevant.


AI can understand the meaning of keywords and cluster them based on semantic similarities, facilitating finer, more accurate and more efficient work.


Some advantages of using AI for keyword clustering can be summarized as follows:

  • Better understanding of user intent
  • Improved SEO performance
  • Time and cost savings


In conclusion, keyword clustering with AI can greatly improve your SEO and marketing efforts by providing more accurate and relevant keyword data. 


By following the implementation steps outlined above, you can start using AI to improve your keyword clustering process today.

What are some applications of clustering?

Clustering has a multitude of applications in the real world and in marketing in particular. 

Here are some of the applications of clustering in marketing:

  • Customer segmentation:
  • Grouping of offers
  • Market research
  • Price optimization
  • Customer retention


And of course, it is especially relevant when it comes to SEO.  


Thanks to AI, these task that were so costly to perform have been simplified and in many cases made available to a wider range of professionals.


You will agree with us that this is very promising and that we can now execute sorting tasks at a fraction of the time and cost of just a few years ago.


Well, now that you know what clustering is all about, let’s have a little final test! 


Do you want to take the plunge?

Can you tell us which of the following statements you think is true?

We couldn’t make it that easy, and the correct answer was to cluster keywords. 


And the right answer is…, indeed, number 4! A good example is when a company wants to personalize its marketing strategy and needs to segment its customers into groups with similar characteristics and needs. Clustering is a super powerful tool.

Would you like to know more about the keyword clustering technique to identify the most relevant keywords for your business?

With our help, you can improve your website’s search engine rankings and increase your organic traffic, contact us for an effective and quality keyword strategy!
Dare to take your keyword strategy to the next level with our artificial intelligence and get effective and quality results to boost your business!
Improve your positioning with our advanced AI

If you liked it, please share it:

Related Posts