Views
No views yet
pip install sentence-transformers1from sentence_transformers import SentenceTransformer
2import numpy as np
3
4# Load domain-specialized model
5model = SentenceTransformer('0xnbk/nbk-ats-domain-v1-en')
6
7# Example: Resume-Job domain matching
8resume_tech = """
9Senior Software Engineer with 8 years of experience in Python, Django, and React.
10Led development of microservices architecture serving 10M+ users. Expert in AWS,
11Docker, Kubernetes, and CI/CD pipelines. Strong background in agile methodologies
12and cross-functional team leadership.
13"""
14
15job_tech = """
16We're seeking a Senior Backend Engineer with 5+ years Python experience.
17Must have expertise in Django, microservices, and cloud platforms (AWS/GCP).
18Experience with containerization (Docker/Kubernetes) and modern DevOps practices required.
19"""
20
21job_healthcare = """
22Registered Nurse position in ICU requiring 3+ years critical care experience.
23Must have current RN license, ACLS certification, and experience with electronic
24medical records. Knowledge of patient monitoring systems and ventilator management essential.
25"""
26
27# Generate embeddings
28resume_emb = model.encode(resume_tech)
29tech_job_emb = model.encode(job_tech)
30healthcare_job_emb = model.encode(job_healthcare)
31
32# Calculate cosine similarity
33same_domain_similarity = np.dot(resume_emb, tech_job_emb) / (
34 np.linalg.norm(resume_emb) * np.linalg.norm(tech_job_emb)
35)
36cross_domain_similarity = np.dot(resume_emb, healthcare_job_emb) / (
37 np.linalg.norm(resume_emb) * np.linalg.norm(healthcare_job_emb)
38)
39
40print(f"Same Domain (Tech → Tech): {same_domain_similarity:.3f}") # Expected: >0.90
41print(f"Cross Domain (Tech → Healthcare): {cross_domain_similarity:.3f}") # Expected: <0.30 or negative
42
43# Domain matching logic
44def is_same_domain(similarity, threshold=0.5):
45 return similarity > threshold
46
47print(f"\nDomain Match: {is_same_domain(same_domain_similarity)}") # True
48print(f"Domain Match: {is_same_domain(cross_domain_similarity)}") # False1from sentence_transformers import SentenceTransformer
2from sklearn.metrics.pairwise import cosine_similarity
3
4model = SentenceTransformer('0xnbk/nbk-ats-domain-v1-en')
5
6# Multiple resumes from different domains
7resumes = [
8 "... technology resume ...",
9 "... healthcare resume ...",
10 "... finance resume ..."
11]
12
13# Single job description
14job = "... technology job description ..."
15
16# Batch encode
17resume_embeddings = model.encode(resumes, batch_size=8, show_progress_bar=True)
18job_embedding = model.encode(job)
19
20# Calculate similarities
21similarities = cosine_similarity([job_embedding], resume_embeddings)[0]
22
23# Rank by domain compatibility
24for idx, score in sorted(enumerate(similarities), key=lambda x: x[1], reverse=True):
25 domain_match = "✅ SAME DOMAIN" if score > 0.5 else "❌ DIFFERENT DOMAIN"
26 print(f"Resume {idx+1}: {score:.3f} {domain_match}")1from sentence_transformers import SentenceTransformer
2import numpy as np
3
4# Load both models
5semantic_model = SentenceTransformer('0xnbk/nbk-ats-semantic-v1-en')
6domain_model = SentenceTransformer('0xnbk/nbk-ats-domain-v1-en')
7
8def calculate_ats_score(resume_text, job_text):
9 # Semantic similarity (content quality)
10 resume_sem = semantic_model.encode(resume_text)
11 job_sem = semantic_model.encode(job_text)
12 semantic_similarity = np.dot(resume_sem, job_sem) / (
13 np.linalg.norm(resume_sem) * np.linalg.norm(job_sem)
14 )
15
16 # Domain compatibility (field alignment)
17 resume_dom = domain_model.encode(resume_text)
18 job_dom = domain_model.encode(job_text)
19 domain_similarity = np.dot(resume_dom, job_dom) / (
20 np.linalg.norm(resume_dom) * np.linalg.norm(job_dom)
21 )
22
23 # Hybrid scoring
24 base_score = semantic_similarity * 100
25
26 # Apply domain bonus/penalty
27 if domain_similarity > 0.5:
28 # Same domain: boost score
29 final_score = base_score * 1.2
30 else:
31 # Different domain: penalize
32 final_score = base_score * 0.6
33
34 return {
35 'final_score': np.clip(final_score, 0, 100),
36 'semantic_score': base_score,
37 'domain_similarity': domain_similarity,
38 'same_domain': domain_similarity > 0.5
39 }
40
41# Example usage
42result = calculate_ats_score(resume_text, job_text)
43print(f"Final ATS Score: {result['final_score']:.1f}%")
44print(f"Semantic Score: {result['semantic_score']:.1f}%")
45print(f"Domain Similarity: {result['domain_similarity']:.3f}")
46print(f"Same Domain: {result['same_domain']}")| Domain | Recognition | Cross-Domain Separation |
|---|---|---|
| Technology | ✅ >0.90 | ✅ Strong boundaries |
| Healthcare | ✅ >0.90 | ✅ Excellent isolation |
| Finance | ✅ >0.90 | ✅ Very strong separation |
| Education | ✅ >0.90 | ✅ Clear boundaries |
| Legal | ✅ >0.90 | ✅ Strong separation |
| Sales/Marketing | ✅ >0.90 | ✅ Realistic overlap handled |
| Human Resources | ✅ >0.90 | ✅ Good separation |
| Manufacturing/Operations | ✅ >0.90 | ✅ Clear distinction |
| Design | ✅ >0.90 | ✅ Nuanced UX/UI overlap |
| Retail/Hospitality | ✅ >0.90 | ✅ Service industry distinction |
| Construction/Real Estate | ✅ >0.90 | ✅ Strong boundaries |
| Government/Nonprofit | ✅ >0.90 | ✅ Public sector clarity |
| Media/Entertainment | ✅ >0.90 | ✅ Creative field separation |
1@model{nbk_ats_domain_v1,
2 author = {NBK},
3 title = {NBK ATS Domain Classifier v1 (English)},
4 year = {2025},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/0xnbk/nbk-ats-domain-v1-en}
7}1@dataset{resume_domain_triplets_v1,
2 author = {NBK},
3 title = {Resume-Domain Triplets Dataset v1 (English)},
4 year = {2025},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/datasets/0xnbk/resume-domain-triplets-train-v1-en}
7}1@model{nbk_ats_semantic_v1,
2 author = {NBK},
3 title = {NBK ATS Semantic Model v1 (English)},
4 year = {2025},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/0xnbk/nbk-ats-semantic-v1-en}
7}Copyright 2025 NBK (nbk.dev)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.