Introduction to Machine Learning for SEO
- Practical: Keyword Clustering with KeyBERT
- Practical: Query Entity Extraction with Google NLP and Entity ML-enabled data analysis
NEW: AI Search Optimisation and Agentic SEO Course by Beatrice Gamba -> Immediate start, on-demand learning for how to optimise for discovery in agentic search ✨ ✨
Tools & Platforms
In shortOpen-source Python library (also called SBERT) for turning text into embeddings and scoring similarity; it powers many MLforSEO notebooks.
Sentence Transformers is an open-source Python library for computing and training embedding models: it turns keywords, sentences, paragraphs or pages into embeddings you can compare, cluster and search. It grew out of the Sentence-BERT (sBERT) research, was created by UKP Lab and is now maintained by Hugging Face. It is the library behind many MLforSEO Colab notebooks, from keyword-to-topic mapping to BERTopic and KeyBERT.
You load a pretrained model by name from the Hugging Face Hub, pass it a list of texts, and get back one vector per text. The documentation lists more than 25,000 pretrained Sentence Transformers models on Hugging Face. The one MLforSEO uses most is all-MiniLM-L6-v2: small, free, English-only, 384 dimensions and trained on over a billion sentence pairs, which makes it fast enough for Google Colab.
The core pattern from MLforSEO’s keyword mapping notebook:
from sentence_transformers import SentenceTransformermodel = SentenceTransformer('all-MiniLM-L6-v2')keyword_embeddings = model.encode(keywords)
You then compare vectors with cosine similarity (the library’s default similarity function, also available through scikit-learn). As of its 2026 documentation, the library also covers cross-encoder rerankers and sparse encoders for retrieval, alongside standard embedding models.
In MLforSEO’s meta description tutorial, the page is split into candidate sentences of 70 to 155 characters, each is encoded with all-MiniLM-L6-v2, and the winner is the sentence closest to both the whole page and the query it ranks for, with a small bonus for appearing early. It is still extractive, but you can see and steer why each sentence was chosen (semantic similarity in practice).