What it is
A word embedding turns a word into a list of numbers (a vector) so that words used in similar contexts get similar vectors. Words are placed on a map of meaning: "cat" ends up near "dog", far from "bridge". The vectors are learned from large amounts of text by predicting words from their neighbours.
What it is for
Giving text to any model that works with numbers: search by meaning instead of exact words, finding similar documents, clustering, recommendations. Embeddings of whole sentences and documents extend the same idea and power modern semantic search.
How to do it
- Pick an embedding model that fits your language (Italian text needs a model that covers Italian).
- Split your texts into the units you want to compare: words, sentences or paragraphs.
- Run each unit through the model to get its vector, and store the vectors.
- Compare vectors with cosine similarity: the closer to 1, the closer in meaning.
- To search, embed the query the same way and return the stored items with the highest similarity.
- Test it on pairs you know are similar or different, and watch for biases the model has absorbed from its training text.