Update README.md
Browse files
README.md
CHANGED
@@ -189,7 +189,7 @@ import torch
|
|
189 |
import numpy as np
|
190 |
from tqdm.auto import tqdm
|
191 |
from sentence_transformers import SentenceTransformer
|
192 |
-
from sentence_transformers.util import batch_to_device
|
193 |
|
194 |
# Load the model
|
195 |
model = SentenceTransformer("TechWolf/JobBERT-v2")
|
@@ -230,11 +230,26 @@ job_titles = [
|
|
230 |
# Get embeddings
|
231 |
embeddings = encode(model, job_titles)
|
232 |
|
233 |
-
# Calculate similarity matrix
|
234 |
-
similarities =
|
235 |
print(similarities)
|
236 |
```
|
237 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
### Example Use Cases
|
239 |
|
240 |
1. **Job Title Matching**: Find similar job titles for standardization or matching
|
|
|
189 |
import numpy as np
|
190 |
from tqdm.auto import tqdm
|
191 |
from sentence_transformers import SentenceTransformer
|
192 |
+
from sentence_transformers.util import batch_to_device, cos_sim
|
193 |
|
194 |
# Load the model
|
195 |
model = SentenceTransformer("TechWolf/JobBERT-v2")
|
|
|
230 |
# Get embeddings
|
231 |
embeddings = encode(model, job_titles)
|
232 |
|
233 |
+
# Calculate cosine similarity matrix
|
234 |
+
similarities = cos_sim(embeddings, embeddings)
|
235 |
print(similarities)
|
236 |
```
|
237 |
|
238 |
+
The output will be a similarity matrix where each value represents the cosine similarity between two job titles:
|
239 |
+
|
240 |
+
```
|
241 |
+
tensor([[1.0000, 0.8723, 0.4821, 0.5447],
|
242 |
+
[0.8723, 1.0000, 0.4822, 0.5019],
|
243 |
+
[0.4821, 0.4822, 1.0000, 0.4328],
|
244 |
+
[0.5447, 0.5019, 0.4328, 1.0000]])
|
245 |
+
```
|
246 |
+
|
247 |
+
In this example:
|
248 |
+
- The diagonal values are 1.0000 (perfect similarity with itself)
|
249 |
+
- 'Software Engineer' and 'Senior Software Developer' have high similarity (0.8723)
|
250 |
+
- 'Product Manager' and 'Data Scientist' show lower similarity with other roles
|
251 |
+
- All values range between 0 and 1, where higher values indicate greater similarity
|
252 |
+
|
253 |
### Example Use Cases
|
254 |
|
255 |
1. **Job Title Matching**: Find similar job titles for standardization or matching
|