Fueling Generative Content with Keyword Research
Generative models have proven extremely useful in content idea generation. But they don’t take into account user search demand and trends. In this notebook, let’s see how we can solve that by adding keyword research into the equation.
Read the accompanying blog post here.
1 ! pip install cohere -q
1 import cohere 2 import numpy as np 3 import pandas as pd 4 from sklearn.cluster import KMeans 5 6 import cohere 7 co = cohere.Client("COHERE_API_KEY") # Get your API key: https://dashboard.cohere.com/api-keys
1 #@title Enable text wrapping in Google Colab 2 3 from IPython.display import HTML, display 4 5 def set_css(): 6 display(HTML(''' 7 8 ''')) 9 get_ipython().events.register('pre_run_cell', set_css)
First, we need to get a supply of high-traffic keywords for a given topic. We can get this via keyword research tools, of which are many available. We’ll use Google Keyword Planner, which is free to use.
1 import wget 2 wget.download("https://raw.githubusercontent.com/cohere-ai/cohere-developer-experience/main/notebooks/data/remote_teams.csv", "remote_teams.csv")
'remote_teams.csv'
1 df = pd.read_csv('remote_teams.csv') 2 df.columns = ["keyword","volume"] 3 df.head()
| keyword | volume | |
|---|---|---|
| 0 | managing remote teams | 1000 |
| 1 | remote teams | 390 |
| 2 | collaboration tools for remote teams | 320 |
| 3 | online games for remote teams | 320 |
| 4 | how to manage remote teams | 260 |
We now have a list of keywords, but this list is still raw. For example, “managing remote teams” is the top-ranking keyword in this list. But at the same time, there are many similar keywords further down in the list, such as “how to effectively manage remote teams.”
We can do that by clustering them into topics. For this, we’ll leverage Cohere’s Embed endpoint and scikit-learn.
Embed the Keywords with Cohere Embed
The Cohere Embed endpoint turns a text input into a text embedding.
1 def embed_text(texts): 2 output = co.embed( 3 texts=texts, 4 model='embed-v4.0', 5 input_type="search_document", 6 ) 7 return output.embeddings 8 9 embeds = np.array(embed_text(df['keyword'].tolist()))
Cluster the Keywords into Topics with scikit-learn
We then use these embeddings to cluster the keywords. A common term used for this exercise is “topic modeling.” Here, we can leverage scikit-learn’s KMeans module, a machine learning algorithm for clustering.
1 NUM_TOPICS = 4 2 kmeans = KMeans(n_clusters=NUM_TOPICS, random_state=21, n_init="auto").fit(embeds) 3 df['topic'] = list(kmeans.labels_) 4 df.head()
| keyword | volume | topic | |
|---|---|---|---|
| 0 | managing remote teams | 1000 | 0 |
| 1 | remote teams | 390 | 1 |
| 2 | collaboration tools for remote teams | 320 | 1 |
| 3 | online games for remote teams | 320 | 3 |
| 4 | how to manage remote teams | 260 | 0 |
Generate Topic Names with Cohere Chat
We use the Chat to generate a topic name for that cluster.
1 topic_keywords_dict = {topic: list(set(group['keyword'])) for topic, group in df.groupby('topic')}
1 def generate_topic_name(keywords): 2 # Construct the prompt 3 prompt = f"""Generate a concise topic name that best represents these keywords.\ 4 Provide just the topic name and not any additional details. 5 6 Keywords: {', '.join(keywords)}""" 7 8 # Call the Cohere API 9 response = co.chat( 10 model='command-a-03-2025', # Choose the model size 11 message=prompt, 12 preamble="") 13 14 # Return the generated text 15 return response.text
1 topic_name_mapping = {topic: generate_topic_name(keywords) for topic, keywords in topic_keywords_dict.items()} 2 3 df['topic_name'] = df['topic'].map(topic_name_mapping) 4 5 df.head()
| keyword | volume | topic | topic_name | |
|---|---|---|---|---|
| 0 | managing remote teams | 1000 | 0 | Remote Team Management |
| 1 | remote teams | 390 | 1 | Remote Team Tools and Tips |
| 2 | collaboration tools for remote teams | 320 | 1 | Remote Team Tools and Tips |
| 3 | online games for remote teams | 320 | 3 | Remote Team Fun |
| 4 | how to manage remote teams | 260 | 0 | Remote Team Management |
1 for topic, name in topic_name_mapping.items(): 2 print(f"Topic {topic}: {name}")
Topic 0: **Effective Leadership and Management of Remote Teams** Topic 1: **Essential Tools and Software for Remote Team Collaboration and Productivity** Topic 2: **Remote Team Engagement and Team Building Activities** Topic 3: **Remote Team Engagement Games**
Now that we have the keywords nicely grouped into topics, we can proceed to generate the content ideas.
Take the Top Keywords from Each Topic
Here we can implement a filter to take just the top N keywords from each topic, sorted by the search volume. In our case, we use 10.
1 TOP_N = 10 2 3 top_keywords = (df.groupby('topic') 4 .apply(lambda x: x.nlargest(TOP_N, 'volume')) 5 .reset_index(drop=True)) 6 7 8 content_by_topic = {} 9 for topic, group in top_keywords.groupby('topic'): 10 keywords = ', '.join(list(group['keyword'])) 11 topic2name = topic2name = dict(df.groupby('topic')['topic_name'].first()) 12 topic_name = topic2name[topic] 13 content_by_topic[topic] = {'topic_name': topic_name, 'keywords': keywords}
1 content_by_topic
{0: {'topic_name': '**Effective Leadership and Management of Remote Teams**', 'keywords': 'managing remote teams, remote teams, how to manage remote teams, leading remote teams, managing remote teams best practices, remote teams best practices, scrum remote teams, best practices for managing remote teams, manage remote teams, slack best practices for remote teams'}, 1: {'topic_name': '**Essential Tools and Software for Remote Team Collaboration and Productivity**', 'keywords': 'collaboration tools for remote teams, best collaboration tools for remote teams, tools for remote teams, zapier remote teams, best communication tools for remote teams, free collaboration tools for remote teams, free retrospective tools for remote teams, project management tools for remote teams, best tools for remote teams, collaboration tool for remote teams'}, 2: {'topic_name': '**Remote Team Engagement and Team Building Activities**', 'keywords': 'team building activities for remote teams, team building for remote teams, retrospective ideas for remote teams, team building ideas for remote teams, fun retrospective ideas for remote teams, retro ideas for remote teams, team building exercises for remote teams, trust building exercises for remote teams, activities for remote teams, communication exercises for remote teams'}, 3: {'topic_name': '**Remote Team Engagement Games**', 'keywords': 'online games for remote teams, games for remote teams, retrospective games for remote teams, virtual games for remote teams, agile games for remote teams, fun games for remote teams, icebreaker games for remote teams, best games for remote teams, best online games for remote teams, bingo for remote teams'}}
Create a Prompt with These Keywords
Next, we use the Chat endpoint to produce the content ideas. The prompt we’ll use is as follows
1 def generate_blog_ideas(keywords): 2 prompt = f"""{keywords}\n\nThe above is a list of high-traffic keywords obtained from a keyword research tool. 3 Suggest three blog post ideas that are highly relevant to these keywords. 4 For each idea, write a one paragraph abstract about the topic. 5 Use this format: 6 Blog title: <text> 7 Abstract: <text>""" 8 9 response = co.chat( 10 model='command-a-03-2025', 11 message = prompt) 12 return response.text
Generate Content Ideas
Next, we generate the blog post ideas. It takes in a string of keywords, calls the Chat endpoint, and returns the generated text.
1 for key,value in content_by_topic.items(): 2 value['ideas'] = generate_blog_ideas(value['keywords']) 3 4 5 for key,value in content_by_topic.items(): 6 print(f"Topic Name: {value['topic_name']}\n") 7 print(f"Top Keywords: {value['keywords']}\n") 8 print(f"Blog Post Ideas: {value['ideas']}\n") 9 print("-"*50)
Topic Name: **Effective Leadership and Management of Remote Teams** Top Keywords: managing remote teams, remote teams, how to manage remote teams, leading remote teams, managing remote teams best practices, remote teams best practices, scrum remote teams, best practices for managing remote teams, manage remote teams, slack best practices for remote teams Blog Post Ideas: **Blog Title: Mastering Remote Team Management: Best Practices for Leaders** **Abstract:** Leading a remote team comes with unique challenges, from communication barriers to maintaining team cohesion. This blog post dives into the essential best practices for managing remote teams effectively, including setting clear expectations, leveraging the right tools, and fostering a culture of trust and accountability. Whether you're new to remote leadership or looking to refine your approach, these actionable strategies will help you build a productive and engaged remote workforce. **Blog Title: Scrum for Remote Teams: Adapting Agile Practices for Virtual Collaboration** **Abstract:** Agile methodologies like Scrum are powerful frameworks for project management, but how do they translate to remote teams? This post explores how to adapt Scrum practices for virtual environments, focusing on tools like Slack, Zoom, and Jira to facilitate daily stand-ups, sprint planning, and retrospectives. Learn how to overcome common challenges, such as time zone differences and reduced face-to-face interaction, while maintaining the agility and efficiency Scrum is known for. **Blog Title: Slack Best Practices for Remote Teams: Boosting Communication and Productivity** **Abstract:** Slack has become a cornerstone of remote team communication, but without the right strategies, it can lead to overwhelm and inefficiency. This blog post outlines the best practices for using Slack in remote teams, including channel organization, etiquette guidelines, and integration with other tools. Discover how to create a streamlined communication workflow that keeps your team aligned, reduces noise, and enhances productivity in a remote work setting. -------------------------------------------------- Topic Name: **Essential Tools and Software for Remote Team Collaboration and Productivity** Top Keywords: collaboration tools for remote teams, best collaboration tools for remote teams, tools for remote teams, zapier remote teams, best communication tools for remote teams, free collaboration tools for remote teams, free retrospective tools for remote teams, project management tools for remote teams, best tools for remote teams, collaboration tool for remote teams Blog Post Ideas: **Blog Title: The Ultimate Guide to the Best Collaboration Tools for Remote Teams in 2023** **Abstract:** As remote work continues to rise, finding the right collaboration tools is essential for maintaining productivity and team cohesion. This comprehensive guide explores the top collaboration tools for remote teams, including project management platforms, communication apps, and automation tools like Zapier. Whether you're a small startup or a large enterprise, this post will help you identify the best tools to streamline workflows, enhance communication, and ensure your team stays aligned, regardless of their location. **Blog Title: 10 Free Collaboration Tools Every Remote Team Should Be Using** **Abstract:** Budget constraints shouldn't hinder your remote team's ability to collaborate effectively. This blog post highlights 10 free collaboration tools that cater to various needs, from project management and communication to retrospectives and file sharing. Discover how tools like Trello, Slack, and Miro can empower your team without breaking the bank, and learn tips for maximizing their features to foster seamless remote collaboration. **Blog Title: How to Choose the Right Project Management Tool for Your Remote Team** **Abstract:** With countless project management tools available, selecting the perfect one for your remote team can be overwhelming. This post breaks down the key factors to consider, such as team size, project complexity, and integration capabilities, to help you make an informed decision. From Asana and Monday.com to ClickUp and Notion, explore the pros and cons of popular tools and find the one that best aligns with your team's unique needs and workflows. -------------------------------------------------- Topic Name: **Remote Team Engagement and Team Building Activities** Top Keywords: team building activities for remote teams, team building for remote teams, retrospective ideas for remote teams, team building ideas for remote teams, fun retrospective ideas for remote teams, retro ideas for remote teams, team building exercises for remote teams, trust building exercises for remote teams, activities for remote teams, communication exercises for remote teams Blog Post Ideas: **Blog Title: 10 Fun and Engaging Team Building Activities for Remote Teams** Abstract: Remote work can sometimes make team bonding challenging, but with the right activities, you can foster connection and collaboration. This blog post explores 10 creative and interactive team building ideas tailored for remote teams, from virtual escape rooms to online trivia nights. Each activity is designed to strengthen relationships, improve communication, and boost morale, ensuring your team stays connected and motivated, no matter the distance. **Blog Title: Retro Reimagined: 7 Fun Retrospective Ideas for Remote Teams** Abstract: Retrospectives are essential for remote teams to reflect, learn, and grow, but they don't have to be boring. This post introduces 7 fun and effective retrospective ideas that go beyond the standard meeting format. From "Virtual Appreciation Boards" to "Future Visioning" exercises, these ideas encourage open communication, celebrate successes, and identify areas for improvement in an engaging and interactive way. **Blog Title: Building Trust and Communication: 5 Essential Exercises for Remote Teams** Abstract: Trust and communication are the cornerstones of successful remote teams, but they require intentional effort to develop. This blog post highlights 5 powerful exercises designed to strengthen trust and enhance communication among remote team members. From "Virtual Coffee Chats" to "Pair Programming" and "Empathy Mapping," these activities create safe spaces for vulnerability, foster understanding, and ensure everyone feels heard and valued in the remote workspace. -------------------------------------------------- Topic Name: **Remote Team Engagement Games** Top Keywords: online games for remote teams, games for remote teams, retrospective games for remote teams, virtual games for remote teams, agile games for remote teams, fun games for remote teams, icebreaker games for remote teams, best games for remote teams, best online games for remote teams, bingo for remote teams Blog Post Ideas: **Blog Title: 10 Best Online Games to Boost Team Bonding and Productivity for Remote Teams** Abstract: Remote work can sometimes feel isolating, but the right online games can transform virtual interactions into engaging, team-building experiences. This blog post explores the top 10 online games specifically designed to enhance collaboration, communication, and morale among remote teams. From icebreakers like virtual escape rooms to strategic games like Codenames, discover how these activities can foster a sense of unity while keeping your team productive and entertained. **Blog Title: Agile Retrospective Games for Remote Teams: Making Remote Sprints More Effective and Fun** Abstract: Retrospectives are a cornerstone of Agile methodology, but conducting them remotely can be challenging. This post introduces a collection of virtual retrospective games tailored for remote teams, such as "Start, Stop, Continue" and "Sailboat," to make these sessions more interactive and insightful. Learn how these games can help your team reflect on past sprints, identify areas for improvement, and plan for future success in a fun and engaging way. **Blog Title: Virtual Icebreaker Games for Remote Teams: Breaking the Awkward Silence in Minutes** Abstract: Starting meetings with remote teams can often feel awkward, but icebreaker games are the perfect solution to ease tension and encourage participation. This blog post highlights creative and easy-to-implement virtual icebreakers, such as "Two Truths and a Lie" and "Virtual Scavenger Hunt," that can quickly warm up your team. Whether you're onboarding new members or just looking to spice up daily stand-ups, these games will help your remote team connect on a personal level and build stronger relationships. --------------------------------------------------