Spaces:
Build error
Build error
File size: 4,375 Bytes
c96142f 88a8ed9 f3f3c13 c96142f a470245 f3f3c13 a470245 c96142f f3f3c13 c96142f f3f3c13 8972278 f3f3c13 c96142f f3f3c13 16e9f0f f3f3c13 c96142f f3f3c13 c96142f a470245 c96142f 375d7da | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | import os
import random
import string
from datetime import datetime
from supabase import create_client, Client
from transformers import pipeline, AutoModelForSequenceClassification,AutoModelForCausalLM, AutoTokenizer
from sentence_transformers import SentenceTransformer
from huggingface_hub import login
import gradio as gr
import os
from sentence_transformers import SentenceTransformer, util
from transformers import pipeline
from huggingface_hub import login
import gradio as gr
# Load environment variables (for Hugging Face integration)
from dotenv import load_dotenv
load_dotenv()
# Hugging Face Authentication (for private models)
huggingface_token = os.getenv("HUGGINGFACE_TOKEN")
login(token=huggingface_token) # Authenticate with Hugging Face
# Supabase setup
SUPABASE_URL = os.getenv("SUPABASE_URL")
SUPABASE_KEY = os.getenv("SUPABASE_KEY")
supabase: Client = create_client(SUPABASE_URL, SUPABASE_KEY)
# Load Sentence Transformer model
model = SentenceTransformer('all-MiniLM-L6-v2')
# Function to calculate skill matching score
def calculate_skill_score(jd, cv):
skills = [ # Core Programming Languages
'Python', 'Java', 'JavaScript', 'C++', 'C#', 'Ruby', 'Go',
'Rust', 'Swift', 'Kotlin', 'PHP', 'TypeScript',
# Web Technologies
'React', 'Angular', 'Vue.js', 'Node.js', 'Django',
'Flask', 'Spring', '.NET', 'Express.js', 'Laravel',
# Cloud & DevOps
'AWS', 'Azure', 'Google Cloud', 'Docker', 'Kubernetes',
'Jenkins', 'GitHub Actions', 'GitLab CI', 'Terraform',
# Databases
'SQL', 'MongoDB', 'PostgreSQL', 'MySQL', 'Cassandra',
'Redis', 'Oracle', 'SQLite', 'MariaDB',
# Data Science & AI
'Machine Learning', 'Data Analysis', 'Deep Learning',
'TensorFlow', 'PyTorch', 'Scikit-learn', 'Pandas',
'NumPy', 'Keras', 'Natural Language Processing',
# Big Data
'Hadoop', 'Spark', 'Apache Kafka', 'Elasticsearch',
# Cybersecurity
'Network Security', 'Penetration Testing', 'Ethical Hacking',
# Mobile Development
'Android', 'iOS', 'React Native', 'Flutter', 'Xamarin']
jd_skills = [skill for skill in skills if skill.lower() in jd.lower()]
cv_skills = [skill for skill in skills if skill.lower() in cv.lower()]
common_skills = set(jd_skills) & set(cv_skills)
return len(common_skills) / len(jd_skills) * 4 if jd_skills else 0
# Function to calculate role match score
def calculate_role_score(jd, cv):
roles = ['Software Engineer', 'Data Scientist', 'DevOps', 'Frontend Developer', 'Project Manager', 'Delivery Manager', 'Delivery Head', 'BI']
matched_roles = [role for role in roles if role.lower() in jd.lower() and role.lower() in cv.lower()]
return len(matched_roles) / len(roles) * 3 if roles else 0
# Function to calculate textual similarity (JD and CV)
def calculate_text_similarity(jd, cv):
jd_embedding = model.encode(jd, convert_to_tensor=True)
cv_embedding = model.encode(cv, convert_to_tensor=True)
cosine_sim = util.pytorch_cos_sim(jd_embedding, cv_embedding)
return cosine_sim.item()
# Function to calculate the overall rating
def calculate_profile_rating(jd, cv):
skill_score = calculate_skill_score(jd, cv)
role_score = calculate_role_score(jd, cv)
text_similarity = calculate_text_similarity(jd, cv)
text_similarity_score = text_similarity * 3
total_score = skill_score + role_score + text_similarity_score
total_score = min(total_score, 10) # Ensure score doesn't exceed 10
return round(total_score, 1)
# Gradio interface to interact with the model
def process_jd_cv(jd, cv):
# Truncate both JD and CV to the first 3500 characters
jd = jd[:3500]
cv = cv[:3500]
# Calculate the final rating
rating = calculate_profile_rating(jd, cv)
return f"Profile Rating: {rating}/10"
# Gradio interface to accept inputs from the user
iface = gr.Interface(fn=process_jd_cv,
inputs=["text", "text"], # JD and CV text inputs
outputs="text", # Display the rating score
live=True)
# Launch the Gradio interface
iface.launch(share=True) |