Model Pipeline - Semantic similarity with embeddings
This pipeline shows how we use word or sentence embeddings to find how similar two pieces of text are. We turn text into numbers, then compare those numbers to get a similarity score.
This pipeline shows how we use word or sentence embeddings to find how similar two pieces of text are. We turn text into numbers, then compare those numbers to get a similarity score.
Loss
0.5 |****
0.4 |****
0.3 |****
0.2 |****
0.1 |
+----
1 2 3 Epochs| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 0.45 | 0.6 | Model starts learning to map sentences to vectors that reflect meaning. |
| 2 | 0.3 | 0.75 | Loss decreases and accuracy improves as embeddings better capture similarity. |
| 3 | 0.2 | 0.85 | Model converges with good semantic similarity detection. |
from sklearn.metrics.pairwise import cosine_similarity import numpy as np emb1 = np.array([[1, 0, 0]]) emb2 = np.array([[0, 1, 0]]) sim = cosine_similarity(emb1, emb2) print(sim[0][0])
from sklearn.metrics.pairwise import cosine_similarity emb1 = [0.1, 0.2, 0.3] emb2 = [0.1, 0.2, 0.3] sim = cosine_similarity(emb1, emb2) print(sim)
Pass the test and this pattern moves unknown