Vector Embeddings To Rank Your On-Page Content by Cosine Similarity
Vector embeddings are a way to convert words and sentences and other data into numbers that capture their meaning and relationships. They represent different data types as points in a multidimensional space, where similar data points are clustered closer together. These numerical representations help machines understand and process this data more effectively. – Elastic

I’ve been spending a lot of time experimenting with AI to analyze data and generate code. Here’s something interesting that could help with optimizing content for SEO. I wanted to optimize my article about “art for home staging” so I had Google AI Studio create a python script that generates vector embeddings from my content then rank the top 10 and bottom 10 most relevant sections for my keyword based on cosine similarity. After this, I ran the code through Google Colab to create an ordered list from this content. The idea here is that too much irrelevant or unclear language on a page can drag down the overall relevancy of the article to the main topic.
Ranking your on-page content by cosine similarity and rewriting the least relevant sections.


Here is the ordered list that I received after executing the Python script. I can immediately see why these content sections scored low in terms of similarity as some don’t mention home and none of these talk about art.
Bottom 10 Sections (Lowest Cosine Similarity)
- I’m here to answer your questions every day of the week. (Similarity: 0.0026)
- First impressions matter. (Similarity: 0.0397)
- Some were a mess. (Similarity: 0.0490)
- Home goes on sale while the owner is still occupying the property. (Similarity: 0.0705)
- Home goes on sale while owner is still occupying the property. (Similarity: 0.0779)
- Homes that stay on the market for too long inevitably either have to lower the asking price or get pulled from the market entirely to save face. (Similarity: 0.0885)
- A friend of mine sold his home which included an extensive wine collection to help close the sale. (Similarity: 0.0925)
- You want to motivate them to take the next step by putting in a good offer as soon as possible. (Similarity: 0.1194)
- Some of these homes were totally empty. (Similarity: 0.1338)
- Some homes had no other visitors. (Similarity: 0.1508)
AI Content Recommendations
Then I copy & pasted the bottom 10 sections back into Google AI Studio and asked it to rewrite those sections. Here are some of the best recommendations that I received from Google AI Studio. What’s interesting here is that I’ve been provided with a rationale for each recommendation as well which can be helpful for context especially if you’re not already an expert on the topic.
- Original: First impressions matter.
Rewritten: “In home staging, first impressions are everything. Tastefully chosen art can immediately elevate a room’s aesthetic, creating a positive and memorable impact on potential buyers viewing the property for the first time.”
Reasoning: Explicitly ties “first impressions” to home staging and the impact of art on potential buyers. - Original: Homes that stay on the market for too long inevitably either have to lower the asking price or get pulled from the market entirely to save face.
Rewritten: “To avoid prolonged time on the market and potential price reductions, strategic art staging can breathe new life into a listing, capturing the attention of discerning buyers and accelerating the sales process.”
Reasoning: Links the negative outcome of long market times to art staging as a solution to attract buyers. - Original: You want to motivate them to take the next step by putting in a good offer as soon as possible.
Rewritten: “By strategically showcasing compelling fine art photography, you can create an emotional connection with potential buyers, inspiring them to submit competitive offers quickly and confidently.”
Reasoning: Connects art to emotional connection and motivating buyers to make offers.
As with anything AI-related, you have to review the suggestions then decide what to do with it. You can’t take all of this verbatim and use it but some of these recommended rewrites are really good! At the least, I have a starting point here for how I might approach optimizing my on-page content.

Visualizing Cosine Similarity Scores
Update 2/7/25: I’ve updated the script to add several more tools including one that color codes all of the content by cosine similarity. This helps with visualizing the data. Green embeddings are the most relevant sections, yellow is average and red scored the lowest. The red sections are the areas where I would look to optimizing first.
