Spaces:
Sleeping
Sleeping
Download app.py from VANOOOO/Talentiq-AI-api: direct link, hf CLI and curl.
- Browser
- Download file 40.5 kB
-
https://huggingface.co/spaces/VANOOOO/Talentiq-AI-api/resolve/main/app.py
- Command line
-
hf download hf://spaces/VANOOOO/Talentiq-AI-api/app.py
-
curl -L -o app.py https://huggingface.co/spaces/VANOOOO/Talentiq-AI-api/resolve/main/app.py
40.5 kB
| import os | |
| # Matikan fitur OneDNN dan batasi thread agar PyTorch (dari SentenceTransformers) tidak bentrok dengan TensorFlow | |
| os.environ["TF_ENABLE_ONEDNN_OPTS"] = "0" | |
| os.environ["OMP_NUM_THREADS"] = "1" | |
| os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3" | |
| import numpy as np | |
| from fastapi import FastAPI, HTTPException | |
| from pydantic import BaseModel | |
| import tensorflow as tf | |
| from sentence_transformers import SentenceTransformer | |
| import re | |
| from typing import List, Dict, Any, Set | |
| CANONICAL_SKILL_MAP = { | |
| # ========================================================================== | |
| # PROGRAMMING LANGUAGES | |
| # ========================================================================== | |
| "python": ["python", "py"], | |
| "javascript": ["javascript", "js", "es6", "es2015", "ecmascript"], | |
| "typescript": ["typescript", "ts"], | |
| "java": ["java 8", "java 11", "java spring", "java development", "java developer", "java ee", "java se", "java programming"], | |
| "kotlin": ["kotlin"], | |
| "php": ["php"], | |
| "c#": ["c#", "csharp", ".net", "asp.net", "dotnet"], | |
| "c++": ["c++ programming", "c++ developer", "c/c++", "cpp", "pemrograman c++"], | |
| "c": ["c language", "bahasa c", "pemrograman c"], | |
| "go": ["golang", "go lang", "go programming"], | |
| "rust": ["rust programming", "rust lang"], | |
| "ruby": ["ruby on rails", "ruby"], | |
| "swift": ["swift", "swiftui"], | |
| "dart": ["dart", "dart language"], | |
| "scala": ["scala"], | |
| "r": ["r programming", "r language", "rstudio", "r studio"], | |
| "cobol": ["cobol"], | |
| "bash/shell": ["bash", "shell script", "shell scripting", "powershell", "zsh"], | |
| "matlab": ["matlab"], | |
| "groovy": ["groovy"], | |
| # ========================================================================== | |
| # WEB FRONTEND | |
| # ========================================================================== | |
| "html": ["html", "html5"], | |
| "css": ["css", "css3", "stylesheet", "tailwind", "bootstrap"], | |
| "react.js": ["react.js", "reactjs", "react js", "react hooks", "redux", "react router", "next.js", "nextjs"], | |
| "vue.js": ["vue.js", "vuejs", "vue js", "vuex", "nuxt.js", "nuxtjs"], | |
| "angular": ["angular", "angularjs", "angular.js"], | |
| "svelte": ["svelte"], | |
| "jquery": ["jquery"], | |
| "webpack": ["webpack"], | |
| "vite": ["vite"], | |
| # ========================================================================== | |
| # WEB BACKEND & FRAMEWORKS | |
| # ========================================================================== | |
| "node.js": ["node.js", "nodejs", "node js", "express.js", "expressjs", "hapi.js", "fastify", "nest.js", "nestjs"], | |
| "laravel": ["laravel"], | |
| "django": ["django"], | |
| "flask": ["flask"], | |
| "fastapi": ["fastapi", "fast api"], | |
| "spring boot": ["spring boot", "spring framework", "spring mvc"], | |
| "asp.net": ["asp.net", "aspnet", ".net core"], | |
| "ruby on rails": ["ruby on rails", "rails framework"], | |
| "codeigniter": ["codeigniter"], | |
| "symfony": ["symfony"], | |
| "rest api": ["rest api", "restful api", "restful", "api rest", "http api", "web service", "web services"], | |
| "graphql": ["graphql", "graph ql"], | |
| "grpc": ["grpc"], | |
| "websocket": ["websocket", "web socket", "socket.io"], | |
| "microservices": ["microservices", "microservice", "micro service"], | |
| "wordpress": ["wordpress"], | |
| "magento": ["magento"], | |
| "shopify": ["shopify"], | |
| # ========================================================================== | |
| # MOBILE DEVELOPMENT | |
| # ========================================================================== | |
| "android": ["android sdk", "android development", "android studio", "android app", "jetpack compose", "android kotlin"], | |
| "ios": ["ios development", "xcode", "uikit", "ios app"], | |
| "flutter": ["flutter"], | |
| "react native": ["react native"], | |
| "jetpack": ["jetpack", "navigation component", "livedata", "viewmodel", "room database"], | |
| # ========================================================================== | |
| # DATABASES | |
| # ========================================================================== | |
| "mysql": ["mysql"], | |
| "postgresql": ["postgresql", "postgres"], | |
| "mongodb": ["mongodb", "mongo db"], | |
| "redis": ["redis"], | |
| "sqlite": ["sqlite"], | |
| "oracle db": ["oracle db", "oracle database", "oracle sql"], | |
| "microsoft sql server": ["sql server", "mssql", "ms sql"], | |
| "elasticsearch": ["elasticsearch", "elastic search"], | |
| "cassandra": ["cassandra"], | |
| "dynamodb": ["dynamodb"], | |
| "firebase": ["firebase", "firestore", "realtime database"], | |
| "sql": ["sql query", "sql joins", "stored procedure", "sql optimization", "structured query language", "query sql"], | |
| "nosql": ["nosql", "no-sql"], | |
| # ========================================================================== | |
| # DATA SCIENCE & MACHINE LEARNING | |
| # ========================================================================== | |
| "machine learning": ["machine learning", "ml model", "supervised learning", "unsupervised learning", "classification", "regression model", "clustering"], | |
| "deep learning": ["deep learning", "neural network", "dnn", "cnn", "rnn", "lstm", "transformer model"], | |
| "tensorflow": ["tensorflow", "tensor flow", "keras", "tf.keras"], | |
| "pytorch": ["pytorch", "torch"], | |
| "scikit-learn": ["scikit-learn", "sklearn", "scikit learn"], | |
| "nlp": ["nlp", "natural language processing", "text mining", "text classification", "sentiment analysis", "named entity recognition", "transformers nlp", "bert", "gpt", "llm", "large language model"], | |
| "computer vision": ["computer vision", "image recognition", "object detection", "opencv", "image processing", "yolo"], | |
| "pandas": ["pandas"], | |
| "numpy": ["numpy", "num py"], | |
| "data visualization": ["matplotlib", "seaborn", "plotly", "data visualization", "visualisasi", "dashboard"], | |
| "mlops": ["mlops", "ml ops", "model deployment", "model serving", "model monitoring"], | |
| "data analysis": ["data analysis", "data analyst", "analisis data", "exploratory data analysis", "eda", "statistical analysis", "data wrangling", "data cleaning", "analytics"], | |
| "statistics": ["statistics", "statistik", "probability", "hypothesis testing", "a/b testing", "regression analysis"], | |
| "big data": ["big data", "hadoop", "spark", "apache spark", "hive", "kafka", "databricks", "data lake"], | |
| # ========================================================================== | |
| # DATA ENGINEERING & BI | |
| # ========================================================================== | |
| "etl": ["etl", "extract transform load", "data pipeline", "data ingestion", "airflow", "luigi"], | |
| "data warehouse": ["data warehouse", "data warehousing", "snowflake", "redshift", "bigquery", "dbt"], | |
| "power bi": ["power bi", "powerbi", "dax", "power query"], | |
| "tableau": ["tableau"], | |
| "looker": ["looker", "looker studio"], | |
| "google analytics": ["google analytics", "ga4", "universal analytics"], | |
| "excel": ["microsoft excel", "ms excel", "excel", "pivot table", "vlookup", "macro excel", "spreadsheet"], | |
| "business intelligence": ["business intelligence", "reporting dashboard", "kpi dashboard"], | |
| # ========================================================================== | |
| # CLOUD & DEVOPS | |
| # ========================================================================== | |
| "aws": ["aws", "amazon web services", "ec2", "s3 bucket", "lambda aws", "rds aws", "cloudfront", "eks", "ecs"], | |
| "google cloud": ["google cloud", "gcp", "bigquery", "vertex ai", "cloud run", "cloud storage", "cloud functions"], | |
| "microsoft azure": ["azure", "microsoft azure", "azure devops", "azure functions"], | |
| "docker": ["docker", "dockerfile", "containerization", "docker compose"], | |
| "kubernetes": ["kubernetes", "k8s", "helm chart", "container orchestration"], | |
| "ci/cd": ["ci/cd", "cicd", "continuous integration", "continuous deployment", "continuous delivery", "github actions", "gitlab ci", "jenkins", "circle ci", "travis ci"], | |
| "terraform": ["terraform", "infrastructure as code", "iac"], | |
| "ansible": ["ansible"], | |
| "linux": ["linux", "ubuntu", "centos", "debian", "unix", "linux cli", "terminal linux", "bash scripting"], | |
| "nginx": ["nginx"], | |
| "apache": ["apache server", "apache http"], | |
| "devops": ["devops", "dev ops", "sre", "site reliability"], | |
| # ========================================================================== | |
| # UI/UX DESIGN | |
| # ========================================================================== | |
| "figma": ["figma"], | |
| "adobe xd": ["adobe xd"], | |
| "sketch": ["sketch app", "sketch"], | |
| "invision": ["invision", "in vision"], | |
| "prototyping": ["prototyping", "prototype", "wireframe", "wireframing", "mockup"], | |
| "ux research": ["ux research", "user research", "usability testing", "user testing", "user interview", "heuristic evaluation", "user persona"], | |
| "ux design": ["ux design", "user experience design", "interaction design", "user experience", "ui ux", "ui/ux design", "uiux", "ui dan ux", "ux designer", "ui designer"], | |
| "design thinking": ["design thinking"], | |
| "user journey": ["user journey", "customer journey map", "empathy map", "affinity diagram"], | |
| "information architecture": ["information architecture", "site map", "navigation design"], | |
| "interaction design": ["interaction design", "microinteraction", "motion design"], | |
| "design system": ["design system", "component library", "style guide", "atomic design"], | |
| # ========================================================================== | |
| # GRAPHIC DESIGN & CREATIVE TOOLS | |
| # ========================================================================== | |
| "adobe photoshop": ["adobe photoshop", "photoshop"], | |
| "adobe illustrator": ["adobe illustrator", "illustrator"], | |
| "adobe indesign": ["adobe indesign", "indesign"], | |
| "adobe premiere pro": ["adobe premiere", "premiere pro"], | |
| "adobe after effects": ["adobe after effects", "after effects"], | |
| "coreldraw": ["coreldraw", "corel draw"], | |
| "canva": ["canva"], | |
| "blender": ["blender"], | |
| "cinema 4d": ["cinema 4d", "c4d"], | |
| "davinci resolve": ["davinci resolve", "da vinci resolve"], | |
| "lightroom": ["lightroom", "adobe lightroom"], | |
| "sketchup": ["sketchup", "sketch up"], | |
| "autocad": ["autocad", "auto cad"], | |
| "graphic design": ["graphic design", "desain grafis", "design grafis", "visual design", "tipografi", "typography", "design software"], | |
| "illustration": ["illustration", "ilustrasi", "key visual", "visual communication", "komunikasi visual", "digital illustration", "hand lettering"], | |
| "logo design": ["logo design", "brand identity design", "visual identity", "branding design"], | |
| "video editing": ["video editing", "video editor", "pengeditan video", "color grading", "color correction"], | |
| "photography": ["photography", "fotografi", "photo editing"], | |
| "3d modeling": ["3d modeling", "3d modelling", "3d design", "3d render", "rendering"], | |
| # ========================================================================== | |
| # DIGITAL MARKETING | |
| # ========================================================================== | |
| "digital marketing": ["digital marketing", "pemasaran digital", "online marketing", "internet marketing", "marketing online"], | |
| "seo": ["seo", "search engine optimization", "on-page seo", "off-page seo", "technical seo", "keyword research"], | |
| "sem": ["sem", "search engine marketing", "pay per click", "ppc"], | |
| "google ads": ["google ads", "google adwords", "google ad", "adwords"], | |
| "meta ads": ["facebook ads", "instagram ads", "meta ads", "fb ads"], | |
| "tiktok ads": ["tiktok ads", "tiktok for business", "tiktok advertising"], | |
| "email marketing": ["email marketing", "email campaign", "mailchimp", "newsletter"], | |
| "content marketing": ["content marketing", "strategi konten", "content creation", "content planning"], | |
| "content strategy": ["content strategy", "editorial strategy", "content roadmap"], | |
| "social media marketing": ["social media marketing", "manajemen sosial media", "sosial media marketing", "smm"], | |
| "social media management": ["social media management", "pengelolaan sosial media"], | |
| "marketing communications": ["marketing communications", "marcomm", "marketing comm"], | |
| "performance marketing": ["performance marketing", "conversion rate", "cpa", "cpl", "roas"], | |
| "affiliate marketing": ["affiliate marketing", "affiliate"], | |
| "influencer marketing": ["influencer marketing", "kol", "key opinion leader"], | |
| "brand management": ["brand management", "brand strategy", "brand identity", "brand awareness", "brand equity"], | |
| "market research": ["market research", "riset pasar", "competitive analysis", "competitor analysis", "consumer insight", "market analysis", "analisis pasar", "tren pasar", "category marketing", "customer insights"], | |
| "growth hacking": ["growth hacking", "growth marketing", "growth strategy", "user acquisition"], | |
| "trade marketing": ["trade marketing", "modern trade", "traditional trade", "channel marketing", "fmcg", "fast moving consumer goods", "msl", "merchandising program"], | |
| "brand activation": ["brand activation", "aktivasi merek", "event activation", "field activation", "in-store activation"], | |
| "visual merchandising": ["visual merchandising", "planogram", "merchandise display", "store layout", "retail display", "posm"], | |
| "field operations": ["field canvassing", "canvassing", "outlet visit", "kunjungan outlet", "field work", "lapangan", "roadshow", "face-to-face marketing"], | |
| # ========================================================================== | |
| # SOCIAL MEDIA | |
| # ========================================================================== | |
| "social media": ["social media", "sosial media", "instagram", "linkedin", "facebook", "tiktok", "youtube channel"], | |
| "content creation": ["content creation", "content creator", "pembuatan konten", "content calendar", "editorial calendar"], | |
| "community management": ["community management", "community manager", "online community"], | |
| # ========================================================================== | |
| # SALES & CRM | |
| # ========================================================================== | |
| "salesforce": ["salesforce", "sales cloud", "crm salesforce"], | |
| "hubspot": ["hubspot"], | |
| "crm": ["crm", "customer relationship management"], | |
| "sales": ["sales strategy", "sales target", "sales funnel", "sales pipeline", "lead generation", "closing deal", "b2b sales", "b2c sales", "penjualan produk", "purna jual"], | |
| "relationship management": ["relationship management", "relationship manager", "account management", "key account management", "wealth management", "private banking", "hnwi", "client portfolio", "portfolio management"], | |
| "negotiation": ["negotiation", "negosiasi"], | |
| "partnership": ["partnership development", "partnership management", "partnership marketing", "business partnership", "kerjasama", "mitra", "strategic alliance"], | |
| "business development": ["business development", "pengembangan bisnis", "pengembangan pasar", "perluasan pasar", "new market", "prospek klien", "akuisisi klien"], | |
| # ========================================================================== | |
| # PROJECT MANAGEMENT & AGILE | |
| # ========================================================================== | |
| "agile": ["agile", "agile methodology", "agile development"], | |
| "scrum": ["scrum", "sprint planning", "sprint review", "daily standup", "scrum master"], | |
| "kanban": ["kanban"], | |
| "jira": ["jira", "atlassian jira"], | |
| "trello": ["trello"], | |
| "notion": ["notion"], | |
| "project management": ["project management", "manajemen proyek", "project planning", "gantt chart", "project charter"], | |
| "okr": ["okr", "objective and key result"], | |
| "pmp": ["pmp certification", "project management professional"], | |
| # ========================================================================== | |
| # FINANCE & ACCOUNTING | |
| # ========================================================================== | |
| "financial modeling": ["financial modeling", "financial model", "financial analysis", "dcf", "valuation"], | |
| "accounting": ["accounting", "akuntansi", "general ledger", "accounts payable", "accounts receivable", "journal entry"], | |
| "sap": ["sap", "sap erp", "sap abap", "sap fico", "sap mm", "sap sd", "sap hana"], | |
| "erp": ["erp", "enterprise resource planning", "oracle erp", "odoo"], | |
| "audit": ["auditing", "audit", "internal audit", "financial audit"], | |
| "taxation": ["pajak", "taxation", "bpjs", "pph", "ppn"], | |
| "banking operations": ["cash management system", "trade finance", "digital banking", "wholesale banking", "commercial banking", "retail banking", "islamic banking", "bank syariah", "kredit", "lending", "pembiayaan", "perbankan"], | |
| "actuarial": ["actuarial", "aktuaria", "profit testing", "insurance pricing", "reserving", "life insurance", "general insurance", "asuransi"], | |
| # ========================================================================== | |
| # HR & PEOPLE | |
| # ========================================================================== | |
| "recruitment": ["recruitment", "recruiting", "talent acquisition", "headhunting", "sourcing kandidat", "job posting", "rekrutmen", "rekrut"], | |
| "hr management": ["human resource", "hr management", "hrm", "employee relations", "industrial relations"], | |
| "training & development": ["training and development", "learning and development", "l&d", "employee training", "pelatihan", "training program", "training design", "program pelatihan"], | |
| "training needs analysis": ["training needs analysis", "tna", "competency management", "people development", "learning management system", "lms", "kirkpatrick", "training effectiveness"], | |
| "payroll": ["payroll", "penggajian", "kompensasi"], | |
| "performance management": ["performance management", "performance review", "kpi", "key performance indicator", "key performance indicators"], | |
| # ========================================================================== | |
| # CYBERSECURITY | |
| # ========================================================================== | |
| "cybersecurity": ["cybersecurity", "cyber security", "information security", "infosec"], | |
| "penetration testing": ["penetration testing", "pentest", "ethical hacking", "vulnerability assessment"], | |
| "network security": ["network security", "firewall", "vpn", "ids/ips"], | |
| "siem": ["siem", "splunk", "security operations", "soc analyst"], | |
| "cryptography": ["cryptography", "encryption", "ssl/tls", "pki"], | |
| # ========================================================================== | |
| # NETWORKING & SYSADMIN | |
| # ========================================================================== | |
| "networking": ["networking", "tcp/ip", "dns", "dhcp", "routing", "switching", "cisco", "network infrastructure"], | |
| "system administration": ["system administrator", "sysadmin", "windows server", "active directory", "ldap"], | |
| "it support": ["it support", "helpdesk", "technical support", "service desk", "troubleshooting"], | |
| # ========================================================================== | |
| # TESTING & QA | |
| # ========================================================================== | |
| "software testing": ["software testing", "unit testing", "integration testing", "manual testing", "qa testing", "test case", "bug reporting", "regression testing"], | |
| "test automation": ["test automation", "automated testing", "selenium", "cypress", "jest", "junit", "pytest", "playwright", "appium"], | |
| "api testing": ["api testing", "postman", "insomnia", "swagger"], | |
| # ========================================================================== | |
| # VERSION CONTROL & TOOLS | |
| # ========================================================================== | |
| "git": ["git", "github", "gitlab", "bitbucket", "version control", "git flow", "git repository"], | |
| "confluence": ["confluence", "atlassian confluence"], | |
| # ========================================================================== | |
| # SOFT SKILLS & GENERAL | |
| # ========================================================================== | |
| "communication": ["communication skills", "kemampuan komunikasi", "public speaking", "presentasi", "presentation skills", "komunikasi"], | |
| "teamwork": ["teamwork", "team player", "kolaborasi", "collaboration", "cross-functional"], | |
| "problem solving": ["problem solving", "analytical thinking", "critical thinking", "pemecahan masalah", "systems thinking"], | |
| "time management": ["time management", "manajemen waktu", "deadline oriented", "multitasking"], | |
| "leadership": ["leadership", "kepemimpinan", "team leader", "mentoring", "coaching", "team lead"], | |
| "adaptability": ["adaptability", "adaptif", "fast learner", "belajar cepat"], | |
| "attention to detail": ["attention to detail", "teliti", "detail oriented", "ketelitian"], | |
| "english proficiency": ["english proficiency", "bahasa inggris", "english communication", "toefl", "ielts", "bilingual", "good english", "fluent english", "english writing", "english speaking"], | |
| "creativity": ["creativity", "creative thinking"], | |
| "product management": ["product management", "product roadmap", "user story", "backlog", "product lifecycle", "go-to-market", "product owner", "product strategy"], | |
| # ========================================================================== | |
| # SOFTWARE DEVELOPMENT GENERAL | |
| # ========================================================================== | |
| "software development": ["software development", "web development", "application development", "pengembangan aplikasi", "pengembangan sistem", "coding", "debugging", "software architecture", "scalability", "systems architecture", "memory management"], | |
| "frontend development": ["front end developer", "frontend developer", "front-end developer", "frontend development"], | |
| # ========================================================================== | |
| # DOMAIN-SPECIFIC | |
| # ========================================================================== | |
| "blockchain": ["blockchain", "web3", "smart contract", "solidity", "ethereum", "nft", "defi", "cryptocurrency", "crypto"], | |
| "iot": ["iot", "internet of things", "embedded system", "arduino", "raspberry pi", "mqtt"], | |
| "ar/vr": ["augmented reality", "virtual reality", "ar/vr", "mixed reality", "unity xr"], | |
| "game development": ["game development", "unity engine", "unreal engine", "game design", "game mechanic", "level design"], | |
| "e-commerce": ["e-commerce", "ecommerce", "marketplace", "tokopedia", "shopee", "lazada", "online store"], | |
| "supply chain": ["supply chain", "rantai pasok", "logistics", "inventory management", "procurement", "warehouse"], | |
| "ux writing": ["ux writing", "microcopy", "copywriting", "content writing", "technical writing", "dokumentasi teknis"], | |
| "operations": ["operations management", "process improvement", "lean", "six sigma", "sop", "standard operating procedure", "kpi monitoring", "business efficiency", "risk management"], | |
| "legal": ["legal research", "legal analysis", "legal compliance", "corporate legal", "hukum", "regulasi", "regulatory compliance", "contract drafting", "legal review", "peraturan", "kepatuhan"], | |
| "event management": ["event management", "event organizer", "event strategy", "pengelolaan event", "mall promotion", "event planning", "event execution"], | |
| "proofreading": ["proofreading", "copyediting", "copy editing", "grammar editing", "subtitle", "subtitling", "localization", "translation", "penerjemahan"], | |
| "creative writing": ["creative writing", "penulisan kreatif", "storytelling", "content evaluation", "writing evaluation", "editorial feedback"], | |
| "maritime": ["ship building", "galangan kapal", "maritime", "docking", "shipyard", "kapal", "naval", "perkapalan", "teknik kapal"], | |
| "medical/life science": ["medical device", "life science", "pharmaceutical", "healthcare", "alat kesehatan", "clinical", "medis"], | |
| "merchandising": ["merchandiser", "merchandising", "display produk", "penataan display", "product display", "sampling produk", "stock monitoring", "stok produk"], | |
| "stakeholder management": ["stakeholder management", "stakeholder engagement", "internal stakeholders", "cross-team", "cross functional", "koordinasi divisi", "koordinasi antar tim"], | |
| "vendor management": ["vendor management", "vendor selection", "vendor evaluation", "procurement vendor", "managing vendor"], | |
| # ========================================================================== | |
| # SUSTAINABILITY, ENGINEERING & RESEARCH | |
| # ========================================================================== | |
| "sustainable development": ["sustainable development", "sustainable design", "sustainable systems", "sustainable technologies", "sustainable architecture"], | |
| "civil engineering": ["civil engineering"], | |
| "environmental science": ["environmental science", "environmental engineering", "natural resource management", "climate change mitigation"], | |
| "building design": ["building design", "architectural design"], | |
| "community development": ["community development"], | |
| "land management": ["land management", "land development"], | |
| "materials science": ["materials science"], | |
| "chemistry": ["chemistry"], | |
| "laboratory testing": ["laboratory testing"], | |
| "research": ["research", "case studies", "policy analysis", "public policy"], | |
| } | |
| def normalize_text(text: str) -> str: | |
| text = str(text).lower() | |
| text = text.replace("/", " ") | |
| text = re.sub(r"[^a-z0-9+#.\-\s]", " ", text) | |
| text = re.sub(r"\s+", " ", text).strip() | |
| return text | |
| def extract_skills_from_text(text: str, skill_map: Dict[str, List[str]]) -> Set[str]: | |
| normalized = normalize_text(text) | |
| found_skills = set() | |
| for canonical_skill, aliases in skill_map.items(): | |
| for alias in aliases: | |
| alias_norm = normalize_text(alias) | |
| if len(alias_norm) <= 2: | |
| pattern = r"(?<![a-z0-9+#.])" + re.escape(alias_norm) + r"(?![a-z0-9+#.])" | |
| else: | |
| pattern = r"\b" + re.escape(alias_norm) + r"\b" | |
| if re.search(pattern, normalized): | |
| found_skills.add(canonical_skill) | |
| break | |
| return found_skills | |
| def detect_focus_area(skill: str) -> str: | |
| ai_data = { | |
| "machine learning", "deep learning", "tensorflow", "pytorch", "scikit-learn", | |
| "pandas", "numpy", "data analysis", "data visualization", "nlp", "computer vision", | |
| "statistics", "big data", "mlops", "etl", "data warehouse", "power bi", "tableau", | |
| "looker", "google analytics", "business intelligence" | |
| } | |
| software = { | |
| "python", "java", "javascript", "typescript", "php", "go", "c++", "c#", "c", "rust", | |
| "ruby", "swift", "dart", "scala", "r", "cobol", "bash/shell", "matlab", "groovy", | |
| "kotlin", "html", "css", "react.js", "vue.js", "angular", "svelte", "jquery", | |
| "webpack", "vite", "node.js", "laravel", "django", "flask", "fastapi", "spring boot", | |
| "asp.net", "ruby on rails", "codeigniter", "symfony", "rest api", "graphql", "grpc", | |
| "websocket", "microservices", "wordpress", "magento", "shopify", "sql", "nosql", | |
| "mysql", "postgresql", "mongodb", "redis", "sqlite", "oracle db", "microsoft sql server", | |
| "elasticsearch", "cassandra", "dynamodb", "firebase", "git", "software development", | |
| "frontend development", "android", "ios", "flutter", "react native", "jetpack", | |
| "software testing", "test automation", "api testing" | |
| } | |
| devops = { | |
| "docker", "kubernetes", "aws", "google cloud", "microsoft azure", "ci/cd", | |
| "terraform", "ansible", "linux", "nginx", "apache", "devops", "networking", | |
| "system administration", "it support", "cybersecurity", "penetration testing", | |
| "network security", "siem", "cryptography" | |
| } | |
| design = { | |
| "figma", "adobe xd", "sketch", "invision", "prototyping", "ux research", "ux design", | |
| "design thinking", "user journey", "information architecture", "interaction design", | |
| "design system", "adobe photoshop", "adobe illustrator", "adobe indesign", | |
| "adobe premiere pro", "adobe after effects", "coreldraw", "canva", "blender", | |
| "cinema 4d", "davinci resolve", "lightroom", "sketchup", "autocad", "graphic design", | |
| "illustration", "logo design", "video editing", "photography", "3d modeling" | |
| } | |
| marketing = { | |
| "digital marketing", "seo", "sem", "google ads", "meta ads", "tiktok ads", | |
| "email marketing", "content marketing", "content strategy", "social media marketing", | |
| "social media management", "marketing communications", "performance marketing", | |
| "affiliate marketing", "influencer marketing", "brand management", "market research", | |
| "growth hacking", "trade marketing", "brand activation", "visual merchandising", | |
| "field operations", "social media", "content creation", "community management" | |
| } | |
| business = { | |
| "project management", "communication", "leadership", "problem solving", "product management", | |
| "agile", "scrum", "kanban", "jira", "trello", "notion", "okr", "pmp", "teamwork", | |
| "time management", "adaptability", "attention to detail", "english proficiency", | |
| "creativity", "stakeholder management", "vendor management", "event management", | |
| "operations", "legal", "proofreading", "creative writing", "ux writing", | |
| "crm", "salesforce", "hubspot", "sales", "relationship management", "negotiation", | |
| "partnership", "business development", | |
| "financial modeling", "accounting", "sap", "erp", "audit", "taxation", | |
| "banking operations", "actuarial", "excel", | |
| "recruitment", "hr management", "training & development", "training needs analysis", | |
| "payroll", "performance management" | |
| } | |
| domain = { | |
| "blockchain", "iot", "ar/vr", "game development", "e-commerce", "supply chain", | |
| "maritime", "medical/life science", "merchandising", "sustainable development", | |
| "civil engineering", "environmental science", "building design", "community development", | |
| "land management", "materials science", "chemistry", "laboratory testing", "research" | |
| } | |
| if skill in ai_data: return "Data/AI" | |
| if skill in software: return "Software Engineering" | |
| if skill in devops: return "Cloud/DevOps" | |
| if skill in design: return "Design & Creative" | |
| if skill in marketing: return "Marketing" | |
| if skill in business: return "Business & Soft Skill" | |
| if skill in domain: return "Domain Specific" | |
| return "General" | |
| def build_rule_based_skill_gap_recommendation( | |
| model_probability: float, | |
| predicted_text: str, | |
| cv_text: str, | |
| job_text: str, | |
| skill_map: Dict[str, List[str]] = CANONICAL_SKILL_MAP | |
| ) -> Dict[str, Any]: | |
| cv_skills = extract_skills_from_text(cv_text, skill_map) | |
| job_skills = extract_skills_from_text(job_text, skill_map) | |
| matched_skills = sorted(cv_skills.intersection(job_skills)) | |
| missing_skills = sorted(job_skills.difference(cv_skills)) | |
| extra_skills = sorted(cv_skills.difference(job_skills)) | |
| if len(job_skills) > 0: | |
| rule_skill_coverage = len(matched_skills) / len(job_skills) | |
| else: | |
| rule_skill_coverage = 0.0 | |
| hybrid_readiness_score = (0.50 * model_probability) + (0.50 * rule_skill_coverage) | |
| if hybrid_readiness_score >= 0.80: | |
| readiness_level = "Sangat Kuat" | |
| elif hybrid_readiness_score >= 0.65: | |
| readiness_level = "Cukup Kuat" | |
| elif hybrid_readiness_score >= 0.50: | |
| readiness_level = "Perlu Penguatan" | |
| else: | |
| readiness_level = "Belum Siap" | |
| grouped_gaps = {} | |
| for skill in missing_skills: | |
| area = detect_focus_area(skill) | |
| grouped_gaps.setdefault(area, []).append(skill) | |
| if not missing_skills: | |
| main_recommendation = ( | |
| "Kandidat sudah memiliki skill utama yang relevan dengan kebutuhan lowongan. " | |
| "Fokus berikutnya adalah memperkuat portofolio, bukti proyek, dan pengalaman praktis." | |
| ) | |
| learning_plan = [ | |
| "Minggu 1-2: Rapikan CV dengan bukti proyek, metrik capaian, dan link portofolio.", | |
| "Minggu 3-4: Latihan interview teknis dan studi kasus sesuai role yang dilamar." | |
| ] | |
| cv_improvements = [ | |
| "Pertahankan kata kunci skill yang sudah relevan dan tambahkan dampak terukur dari setiap pengalaman." | |
| ] | |
| else: | |
| priority_skills = missing_skills[:5] | |
| main_recommendation = ( | |
| "Kandidat perlu memprioritaskan penguatan skill berikut: " | |
| + ", ".join(priority_skills) | |
| + ". Skill tersebut muncul pada kebutuhan pekerjaan tetapi belum terdeteksi kuat pada profil CV." | |
| ) | |
| learning_plan = [] | |
| for week, skill in enumerate(priority_skills[:4], start=1): | |
| learning_plan.append(f"Minggu {week}: Pelajari dan buat mini project terkait '{skill}'.") | |
| cv_improvements = [ | |
| "Tambahkan pengalaman, sertifikasi, atau project yang membuktikan skill gap prioritas.", | |
| "Gunakan kata kunci skill yang relevan dengan lowongan agar ATS/recruiter lebih mudah membaca kecocokan." | |
| ] | |
| return { | |
| "model_probability": model_probability, | |
| "predicted_text": predicted_text, | |
| "cv_skills": sorted(cv_skills), | |
| "job_skills": sorted(job_skills), | |
| "matched_skills": matched_skills, | |
| "missing_skills": missing_skills, | |
| "extra_skills": extra_skills, | |
| "rule_skill_coverage": rule_skill_coverage, | |
| "hybrid_readiness_score": hybrid_readiness_score, | |
| "readiness_level": readiness_level, | |
| "grouped_gaps": grouped_gaps, | |
| "main_recommendation": main_recommendation, | |
| "learning_plan": learning_plan, | |
| "cv_improvements": cv_improvements | |
| } | |
| # === HACK KERAS: MENGABAIKAN QUANTIZATION_CONFIG === | |
| # Model ini dilatih di Colab dengan Keras versi sangat baru, | |
| # sementara server HF menggunakan versi lebih lama. | |
| # Kode ini memaksa Keras untuk mengabaikan parameter yang tidak dia kenal. | |
| original_layer_init = tf.keras.layers.Layer.__init__ | |
| def patched_layer_init(self, *args, **kwargs): | |
| kwargs.pop("quantization_config", None) | |
| original_layer_init(self, *args, **kwargs) | |
| tf.keras.layers.Layer.__init__ = patched_layer_init | |
| # =================================================== | |
| # === DEFINISI CUSTOM LAYER === | |
| # Wajib ditaruh di sini agar file .keras bisa mengenali layer buatan temanmu | |
| class TalentIQFeatureInteraction(tf.keras.layers.Layer): | |
| def __init__(self, include_cosine: bool = True, **kwargs): | |
| super().__init__(**kwargs) | |
| self.include_cosine = include_cosine | |
| def call(self, inputs, training=None): | |
| cv_vector, job_vector = inputs | |
| abs_diff = tf.abs(cv_vector - job_vector) | |
| squared_diff = tf.square(cv_vector - job_vector) | |
| product = cv_vector * job_vector | |
| features = [abs_diff, squared_diff, product] | |
| if self.include_cosine: | |
| cv_norm = tf.nn.l2_normalize(cv_vector, axis=-1) | |
| job_norm = tf.nn.l2_normalize(job_vector, axis=-1) | |
| cosine = tf.reduce_sum(cv_norm * job_norm, axis=-1, keepdims=True) | |
| features.append(cosine) | |
| return tf.concat(features, axis=-1) | |
| def get_config(self): | |
| config = super().get_config() | |
| config.update({"include_cosine": self.include_cosine}) | |
| return config | |
| class TalentIQGatedDense(tf.keras.layers.Layer): | |
| def __init__(self, units: int, activation: str = "relu", dropout_rate: float = 0.0, **kwargs): | |
| super().__init__(**kwargs) | |
| self.units = units | |
| self.activation = tf.keras.activations.get(activation) | |
| self.dropout_rate = dropout_rate | |
| self.projection = tf.keras.layers.Dense(units, activation=self.activation) | |
| self.gate = tf.keras.layers.Dense(units, activation="sigmoid") | |
| self.dropout = tf.keras.layers.Dropout(dropout_rate) | |
| self.norm = tf.keras.layers.LayerNormalization(epsilon=1e-6) | |
| def call(self, inputs, training=None): | |
| projected = self.projection(inputs) | |
| gate_values = self.gate(inputs) | |
| gated_output = projected * gate_values | |
| gated_output = self.dropout(gated_output, training=training) | |
| return self.norm(gated_output) | |
| def get_config(self): | |
| config = super().get_config() | |
| config.update({ | |
| "units": self.units, | |
| "activation": tf.keras.activations.serialize(self.activation), | |
| "dropout_rate": self.dropout_rate | |
| }) | |
| return config | |
| # ============================= | |
| # Inisialisasi API | |
| app = FastAPI(title="TalentIQ AI Matcher") | |
| # Lokasi file Keras (Kita buat dinamis, bisa baca dari folder Model atau root) | |
| if os.path.exists("Model/talentiq_model.keras"): | |
| MODEL_PATH = "Model/talentiq_model.keras" | |
| elif os.path.exists("talentiq_model.keras"): | |
| MODEL_PATH = "talentiq_model.keras" | |
| else: | |
| MODEL_PATH = "model.keras" | |
| model = None | |
| encoder = None | |
| model_load_error = None | |
| print(f"Mencoba memuat model dari: {MODEL_PATH}") | |
| try: | |
| # Memuat model Keras melalui TensorFlow | |
| model = tf.keras.models.load_model(MODEL_PATH) | |
| # Memuat model NLP untuk mengubah Teks -> Angka | |
| encoder = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2') | |
| print("✅ Model AI & NLP berhasil dimuat!") | |
| except Exception as e: | |
| import traceback | |
| model_load_error = traceback.format_exc() | |
| print(f"⚠️ Error memuat model:\n{model_load_error}") | |
| # Format Input dari Node.js (Sekarang menerima TEKS, bukan list angka) | |
| class PredictRequest(BaseModel): | |
| cv_text: str | |
| job_text: str | |
| threshold: float = 0.5 | |
| def predict_match(req: PredictRequest): | |
| if model is None or encoder is None: | |
| raise HTTPException(status_code=500, detail=f"Model gagal dimuat saat server menyala. Error detail:\n{model_load_error}") | |
| try: | |
| # 1. Ubah teks dari Node.js menjadi list 384 angka (Embedding) | |
| cv_emb = encoder.encode(req.cv_text) | |
| job_emb = encoder.encode(req.job_text) | |
| # 2. WAJIB DI-NORMALIZE (L2) karena model dilatih dengan data yang sudah di-normalize! | |
| # Jika tidak, nilai probabilitas akan selalu 0.999 karena nilainya kebesaran. | |
| cv_norm = cv_emb / np.linalg.norm(cv_emb) | |
| job_norm = job_emb / np.linalg.norm(job_emb) | |
| # 3. Sesuaikan bentuk array agar diterima oleh model Keras: format (1, 384) | |
| cv_input = np.expand_dims(cv_norm, axis=0) | |
| job_input = np.expand_dims(job_norm, axis=0) | |
| # 4. Lakukan prediksi kecocokan | |
| prediction = model.predict([cv_input, job_input]) | |
| # Ambil skor probabilitas (contoh: 0.85) | |
| prob = float(prediction[0][0]) | |
| # Tentukan hasil akhir (Match atau Tidak) berdasarkan model DL saja sebagai label awal | |
| is_match = prob >= req.threshold | |
| text_label = "Match" if is_match else "Not Match" | |
| # Analisis Skill Gap | |
| gap_report = build_rule_based_skill_gap_recommendation( | |
| model_probability=prob, | |
| predicted_text=text_label, | |
| cv_text=req.cv_text, | |
| job_text=req.job_text | |
| ) | |
| return gap_report | |
| except Exception as e: | |
| raise HTTPException(status_code=500, detail=str(e)) | |
| def health_check(): | |
| return {"message": "TalentIQ AI API (dengan text to embedding) siap digunakan!"} | |