WMD works by leveraging pre-trained word embeddings, such as Word2Vec or GloVe, to represent words as vectors in a high-dimensional space. It then calculates the minimum "transportation cost" required to transform one document's word embeddings into another document's word embeddings. This transportation cost is based on the Earth Mover's Distance (EMD), a measure used in optimal transport theory. The lower the cost, the more similar the two documents are in terms of their semantic content.