The concept of “semantic similarity” is different from the concept of “textual similarity”. Semantic similarity is about the closeness in meaning of the two texts, and lexical similarity is about the lexical closeness of the two texts.
Measuring semantic similarity is very difficult for an AI (artificial intelligence) system. Progress is being made. Here’s few tutorial articles.
Advances in Semantic Textual Similarity – Google Research (2018)
Evolution of Semantic Similarity – A Survey (January 2021)
Semantic Similarity of Two Phrases
Semantic Similarity Using Transformers
How to Rank Text Content by Semantic Similarity (Semantic similarity using GloVe)